A RePast Tutorial by John T. Murphy, University of Arizona & Arizona State University (contact)
For demonstration and pedagogical purposes, add the bolded output lines as below:
// CarryDropModel
package demo;
import uchicago.src.sim.engine.Schedule;
import uchicago.src.sim.engine.SimInit;
import uchicago.src.sim.engine.SimModelImpl;
public class CarryDropModel extends SimModelImpl {
// Default Values
private static final int NUMAGENTS = 100;
private static final int WORLDXSIZE = 40;
private static final int WORLDYSIZE = 40;
private int numAgents = NUMAGENTS;
private int worldXSize = WORLDXSIZE;
private int worldYSize = WORLDYSIZE;
private Schedule schedule;
public String getName(){
return "Carry And Drop";
}
public void setup(){
System.out.println("Running setup");
}
public void begin(){
buildModel();
buildSchedule();
buildDisplay();
}
public void buildModel(){
System.out.println("Running BuildModel");
}
public void buildSchedule(){
System.out.println("Running BuildSchedule");
}
public void buildDisplay(){
System.out.println("Running BuildDisplay");
}
public Schedule getSchedule(){
return schedule;
}
public String[] getInitParam(){
String[] initParams = { "NumAgents" , "WorldXSize", "WorldYSize" };
return initParams;
}
public int getNumAgents(){
return numAgents;
}
public void setNumAgents(int na){
numAgents = na;
}
public int getWorldXSize(){
return worldXSize;
}
public void setWorldXSize(int wxs){
worldXSize = wxs;
}
public int getWorldYSize(){
return worldYSize;
}
public void setWorldYSize(int wys){
worldYSize = wys;
}
public static void main(String[] args) {
SimInit init = new SimInit();
CarryDropModel model = new CarryDropModel();
init.loadModel(model, "", false);
}
}
// CarryDropAgent
package demo;
public class CarryDropAgent {
}
// CarryDropSpace
package demo;
public class CarryDropSpace {
}
With these lines of code in place, run the model again. Note that when the model runs, the 'Setup' routine runs. Press 'Begin' and the Build subroutine runs, calling successively BuildModel, BuildSchedule, and BuildDisplay. Keep this sequence in mind as we move forward. We can leave those lines of code in- they're harmless.
Previous: Default Values for User-Settable Parameters
Go to Table of Contents
A RePast Tutorial by John T. Murphy, University of Arizona & Arizona State University (contact)