uchicago.src.repastdemos.sugarscape
Class SugarModel

java.lang.Object
  extended by uchicago.src.sim.engine.SimModelImpl
      extended by uchicago.src.repastdemos.sugarscape.SugarModel
All Implemented Interfaces:
DescriptorContainer, SimEventProducer, SimModel

public class SugarModel
extends SimModelImpl

An partial implementation of the Sugar Scape simulation from _Growing Artificial Societies_ by Epstein, Joshua M and Axtell, Robert. This implements rules G, R, and M from chapter II. The source code is heavily annotated as example of a simulation built using the Repast toolkit. See the html API documentation for the details of the framework objects.

Version:
$Revision: 1.1 $ $Date: 2005/08/12 20:04:53 $
Author:
Nick Collier adapted from Nelson Minar's Swarm code

Field Summary
 
Fields inherited from class uchicago.src.sim.engine.SimModelImpl
descriptors, modelManipulator
 
Constructor Summary
SugarModel()
           
 
Method Summary
 void addNewAgent()
           
 void agentBirth(SugarAgent agent)
           
 void agentDeath(SugarAgent agent)
           
 void begin()
          Begins a simulation run.
 void birthAgents()
           
 SugarAgent getAgentAt(int x, int y)
           
 java.lang.String[] getInitParam()
          Gets the names of the initial model parameters to set.
 int getMaxDeathAge()
           
 int getMaxInitialSugar()
           
 int getMaxMetabolism()
           
 int getMaxVision()
           
 int getMinDeathAge()
           
 int getMinInitialSugar()
           
 java.lang.String getName()
          Gets the name of the model/simulation.
 int getNumAgents()
           
 boolean getReplacement()
           
 Schedule getSchedule()
          Gets the Schedule created by the model.
 boolean isWrite()
           
static void main(java.lang.String[] args)
           
 void moveAgent(SugarAgent agent, int x, int y)
           
 void reapAgents()
           
 void setMaxDeathAge(int age)
           
 void setMaxInitialSugar(int maxInitSugar)
           
 void setMaxMetabolism(int maxMeta)
           
 void setMaxVision(int maxVis)
           
 void setMinDeathAge(int age)
           
 void setMinInitialSugar(int minInitSugar)
           
 void setNumAgents(int num)
           
 void setReplacement(boolean isReplaced)
           
 void setup()
          Prepares a model for a new run, typically by deallocating objects or setting them to some reasonable default.
 void setWrite(boolean write)
           
 void shuffleAgents()
           
 
Methods inherited from class uchicago.src.sim.engine.SimModelImpl
addPropertyListener, addSimEventListener, clearMediaProducers, clearPropertyListeners, fireBooleanPropertyEvent, fireEndSim, fireNumericPropertyEvent, fireObjectPropertyEvent, firePauseSim, fireSimEvent, fireStopSim, fireStringPropertyEvent, generateNewSeed, getController, getMediaProducers, getModelManipulator, getParameterDescriptors, getPropertiesValues, getRngSeed, getTickCount, pause, registerDisplaySurface, registerMediaProducer, removePropertyListener, removeSimEventListener, setController, setRngSeed, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SugarModel

public SugarModel()
Method Detail

isWrite

public boolean isWrite()
Returns:
Returns the write.

setWrite

public void setWrite(boolean write)
Parameters:
write - The write to set.

shuffleAgents

public void shuffleAgents()

addNewAgent

public void addNewAgent()

agentBirth

public void agentBirth(SugarAgent agent)

birthAgents

public void birthAgents()

agentDeath

public void agentDeath(SugarAgent agent)

getAgentAt

public SugarAgent getAgentAt(int x,
                             int y)

reapAgents

public void reapAgents()

moveAgent

public void moveAgent(SugarAgent agent,
                      int x,
                      int y)

getNumAgents

public int getNumAgents()

setNumAgents

public void setNumAgents(int num)

getMaxMetabolism

public int getMaxMetabolism()

setMaxMetabolism

public void setMaxMetabolism(int maxMeta)

getMaxVision

public int getMaxVision()

setMaxVision

public void setMaxVision(int maxVis)

getMaxInitialSugar

public int getMaxInitialSugar()

setMaxInitialSugar

public void setMaxInitialSugar(int maxInitSugar)

getMinDeathAge

public int getMinDeathAge()

setMinDeathAge

public void setMinDeathAge(int age)

getMaxDeathAge

public int getMaxDeathAge()

setMaxDeathAge

public void setMaxDeathAge(int age)

getReplacement

public boolean getReplacement()

setReplacement

public void setReplacement(boolean isReplaced)

getMinInitialSugar

public int getMinInitialSugar()

setMinInitialSugar

public void setMinInitialSugar(int minInitSugar)

getInitParam

public java.lang.String[] getInitParam()
Description copied from interface: SimModel
Gets the names of the initial model parameters to set. These names must have get and set methods supplied by the model. For example, for the parameter maxAge, the model must have getMaxAge and setMaxAge methods.

Returns:
a String[] of the initial parameter names

begin

public void begin()
Description copied from interface: SimModel
Begins a simulation run. All initialization, building the model, diplay, etc. should take place here. This method is called whenever the start button (or the step button if the run has not yet begun) is clicked. If running in batch mode this is called to kick off a new simulation run.


setup

public void setup()
Description copied from interface: SimModel
Prepares a model for a new run, typically by deallocating objects or setting them to some reasonable default. Called whenever the setup button is clicked or if operating in batch mode whenever a single run has ended in preparation for the next. Also called when the model is first loaded.


getSchedule

public Schedule getSchedule()
Description copied from interface: SimModel
Gets the Schedule created by the model.

Returns:
the schedule created by the model

getName

public java.lang.String getName()
Description copied from interface: SimModel
Gets the name of the model/simulation.

Returns:
the name of the model/simulation

main

public static void main(java.lang.String[] args)