|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--SimModel
A SimModel is a basic simulation framework for simulations of collections of objects. SimThings can be added to the model, and SimViewers can ask to be notified regularly so they can display the world.
The simulation repeats the following cycle as many times as requested:
Birth - anything added to the simulation on the previous cycle
is added to the world.
Action - all SimThings are asked to perform their action() method
in some unpredictable order.
View - all SimViewers are notified
The birth and action operations are separated so new things added to the simulation in the middle of one cycle don't affect other actions on the same cycle (i.e., all actions on one cycle should be carried out with the existing population of things, without newly created things interacting with old ones in unexpected ways). Based on simulation framework developed by Ben Dugan for CSE142/3. Simplified to illustrate key points. CSE143 demo Au01, Sp03
Constructor Summary | |
SimModel()
Constructor for objects of class SimModel |
Method Summary | |
void |
add(SimThing t)
Add the given SimThing to the world after this cycle is complete. |
void |
addView(SimView v)
Add the given SimView to the list of viewers to be notified each cycle. |
java.util.List |
getThings()
Return a copy of the list of Things in the simulation at the beginning of the current cycle. |
void |
go()
Run the simulation indefinitey |
void |
go(int nCycles)
Run the simulation for the requested number of cycles |
void |
pause()
Pause the simulation |
void |
resume()
Resume the simulation |
void |
stop()
Stop the simulation |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SimModel()
Method Detail |
public void add(SimThing t)
t
- the SimThing to be addedpublic void addView(SimView v)
v
- the new viewerpublic java.util.List getThings()
public void go()
public void go(int nCycles)
nCycles
- number of cycles to runpublic void pause()
public void resume()
public void stop()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |