public class Model extends java.util.Observable
Model(AnimatorBuilder, int, int).| Modifier and Type | Field and Description |
|---|---|
private java.util.List<Agent> |
agents |
private Animator |
animator |
private boolean |
disposed |
private double |
time |
| Constructor and Description |
|---|
Model(AnimatorBuilder builder,
int rows,
int columns)
Creates a model to be visualized using the
builder. |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Throw away this model.
|
void |
run(double duration)
Run the simulation for
duration model seconds. |
private void |
setup(AnimatorBuilder builder,
int rows,
int columns)
Construct the model, establishing correspondences with the visualizer.
|
public Model(AnimatorBuilder builder, int rows, int columns)
builder.
If the builder is null, no visualization is performed.
The number of rows and columns
indicate the number of Lights, organized as a 2D
matrix. These are separated and surrounded by horizontal and
vertical Roads. For example, calling the constructor with 1
row and 2 columns generates a model of the form:
| |
--@--@--
| |
where @ is a Light, | is a
vertical Road and -- is a horizontal Road.
Each road has one Car.
The AnimatorBuilder is used to set up an Animator.
AnimatorBuilder.getAnimator() is registered as
an observer of this model.
public void run(double duration)
duration model seconds.public void dispose()
private void setup(AnimatorBuilder builder, int rows, int columns)