A RePast Tutorial by John T. Murphy, University of Arizona & Arizona State University (contact)

Adding User-Settable Parameters

Let's consider what will be the user-settable parameters. For now we will use:

For now, to make this change we need to do three things:

The code, thus modified, is:

CarryDropModel

// CarryDropModel
package demo;

import uchicago.src.sim.engine.Schedule;
import uchicago.src.sim.engine.SimModelImpl;

public class CarryDropModel extends SimModelImpl {

  private int numAgents;
  private int worldXSize;
  private int worldYSize;

  private Schedule schedule;

  public String getName(){
    return "Carry And Drop";
  }

  public void setup(){
  }

  public void begin(){
    buildModel();
    buildSchedule();
    buildDisplay();
  }

  public void buildModel(){
  }

  public void buildSchedule(){
  }

  public void 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) {
  }

}

CarryDropAgent

// CarryDropAgent
package demo;

public class CarryDropAgent {

}

CarryDropSpace

// CarryDropSpace
package demo;

public class CarryDropSpace {

}

Previous: The CarryDrop Model

Next: Compiling and Running the Basic Model

Go to Table of Contents


A RePast Tutorial by John T. Murphy, University of Arizona & Arizona State University (contact)