sim.app.swarmgame.SwarmGame 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.swarmgame;
import sim.engine.*;
import sim.util.*;
import sim.field.continuous.*;
public class SwarmGame extends SimState
{
private static final long serialVersionUID = 1;
public Continuous2D agents;
public double width = 100;
public double height = 100;
public int numAgents = 100;
public double jump = 0.5; // how far do we move in a timestep?
public double stalker_v = 0.5;
public double avoider_v = 0.5;
public double defender_v = 0.0;
public double aggressor_v = 0.0;
public double random_v = 0.0;
// some properties to appear in the inspector
public double getGoTowardsA() { return stalker_v; }
public void setGoTowardsA(double val) { stalker_v = val; }
public double getGoAwayFromB() { return avoider_v; }
public void setGoAwayFromB(double val) { avoider_v = val; }
public double getGoBetweenAAndB() { return defender_v; }
public void setGoBetweenAAndB(double val) { defender_v = val; }
public double getGetBehindBFromA() { return aggressor_v; }
public void setGetBehindBFromA(double val) { aggressor_v = val; }
public double getMoveRandomly() { return random_v; }
public void setMoveRandomly(double val) { random_v = val; }
/** Creates a SwarmGame simulation with the given random number seed. */
public SwarmGame(long seed)
{
super(seed);
}
public void start()
{
super.start();
// set up the agents field
agents = new Continuous2D(width,width,height);
// make a bunch of agents and schedule 'em
for(int x=0;x
© 2015 - 2025 Weber Informatics LLC | Privacy Policy