import java.util.*; import java.io.*; import java.awt.*; public class GCA extends CA { RandomSet[] S; // one for each species double[] totalBirthRate; double[] totalDeathRate; double tau; // output in increments of tau double deltaT; // used in outputting results public GCA(int n,int m,double tau,boolean draw){ super(n,m,draw); this.tau = tau; S = new RandomSet[m]; totalBirthRate = new double[m]; totalDeathRate = new double[m]; deltaT = 0.0; for (int i=0;i= lwb && p < pBirth[species]+lwb){birth(species); break;} lwb = lwb + pBirth[species]; if (p >= lwb && p < pDeath[species]+lwb){death(species); break;} lwb = lwb + pDeath[species]; } while (deltaT >= tau){ time = time + tau; deltaT = deltaT - tau; if (draw){plot(); pause(100);} show(); if (time >= maxTime) break; } } public static void main(String[] args) { int n = Integer.parseInt(args[0]); // size of grid int maxTime = Integer.parseInt(args[1]); // number of iterations double tau = Double.parseDouble(args[2]); // the click of the clock int m = (args.length/3) - 1; // n species boolean draw = args[args.length-1].equals("draw"); // do we draw? boolean trace = args[args.length-1].equals("trace"); // do we trace and draw? int reps = 1; if (args[args.length-1].equals("ten")) reps = 10; if (args[args.length-1].equals("hundred")) reps = 100; while (reps > 0){ GCA gca = new GCA(n,m,tau,draw); for (int i=1;i<=m;i++){ int species = i-1; int popn = Integer.parseInt(args[3*i]); gca.setBirthRate(species,Double.parseDouble(args[3*i+1])); gca.setDeathRate(species,Double.parseDouble(args[3*i+2])); for (int j=0;j