public class Simulation { // Number of particles (N), the xy location of each, and color. static int N = 10; static double[] x; static double[] y; static boolean[] isRed; // The bounds of the region. static double size = 10; static int numSteps = 100; // How close do you have to be to get infected? static double infectionDistance = 0.5; public static void main (String[] argv) { DrawTool.display (); DrawTool.setXYRange (0, size, 0, size); DrawTool.startAnimationMode (); initialize (); for (int step=1; step<=numSteps; step++) { // Spread. infectionSpread (); // Move each particle and draw for (int i=0; i size) ) { return false; } if ( (y1 < 0) || (y1 > size) ) { return false; } return true; } static double distance (double x1, double y1, double x2, double y2) { return Math.sqrt ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); } static double randomDouble (double low, double high) { double u = Math.random (); double v = low + u * (high-low); return v; } static int randomInt (int low, int high) { double u = randomDouble (low, high+1); int k = (int) Math.floor (u); return k; } }