sim.app.tutorial4.Tutorial4 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.tutorial4;
import sim.engine.*;
import sim.field.grid.*;
import sim.util.*;
public class Tutorial4 extends SimState
{
public DoubleGrid2D trails;
public SparseGrid2D particles;
public int collisions;
public double collisionRate;
public double getCollisionRate() { return collisionRate; }
public int gridWidth = 100;
public int gridHeight = 100;
public int numParticles = 500;
public int getWidth() { return gridWidth; }
public void setWidth(int val) { if (val > 0 ) gridWidth = val; }
public int getHeight() { return gridHeight; }
public void setHeight(int val) { if (val > 0 ) gridHeight = val; }
public int getNumParticles() { return numParticles; }
public void setNumParticles(int val) { if (val >= 0) numParticles = val; }
public Tutorial4(long seed)
{
super(seed);
}
public void start()
{
super.start();
trails = new DoubleGrid2D(gridWidth, gridHeight);
particles = new SparseGrid2D(gridWidth, gridHeight);
Particle p;
for(int i=0 ; isome serialVersionUID...
private static final long serialVersionUID = 1;
};
schedule.scheduleRepeating(Schedule.EPOCH,2,decreaser,1);
}
public static void main(String[] args)
{
doLoop(Tutorial4.class, args);
System.exit(0);
}
// contains an anonymous class -- here's the serialVersionUI (see tutorial3)
// by the way, notice it's DIFFERENT from tutorial3's due to new names of stuff.
// No biggie -- as long as you have some serialVersionUID...
private static final long serialVersionUID = 1;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy