sim.app.virus.Agent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mason Show documentation
Show all versions of mason Show documentation
MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations, and also to provide more than enough functionality for many lightweight simulation needs. MASON contains both a model library and an optional suite of visualization tools in 2D and 3D.
The newest version!
/*
Copyright 2006 by Sean Luke and George Mason University
Licensed under the Academic Free License version 3.0
See the file "LICENSE" for more information
*/
package sim.app.virus;
import sim.engine.*;
import sim.util.Double2D;
import sim.portrayal.*;
import java.awt.geom.*;
public abstract /*strictfp*/ class Agent extends SimplePortrayal2D implements Steppable
{
private static final long serialVersionUID = 1;
public String id;
public Double2D agentLocation;
public int intID = -1;
public Agent( String id, Double2D location )
{
this.id = id;
this.agentLocation = location;
}
double distanceSquared( final Double2D loc1, Double2D loc2 )
{
return( (loc1.x-loc2.x)*(loc1.x-loc2.x)+(loc1.y-loc2.y)*(loc1.y-loc2.y) );
}
// Returns "Human", "Evil", or "Good"
public abstract String getType();
public boolean hitObject(Object object, DrawInfo2D info)
{
double diamx = info.draw.width*VirusInfectionDemo.DIAMETER;
double diamy = info.draw.height*VirusInfectionDemo.DIAMETER;
Ellipse2D.Double ellipse = new Ellipse2D.Double( (int)(info.draw.x-diamx/2),(int)(info.draw.y-diamy/2),(int)(diamx),(int)(diamy) );
return ( ellipse.intersects( info.clip.x, info.clip.y, info.clip.width, info.clip.height ) );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy