On Mar 4, 2011, at 9:41 AM, Yang, Ming wrote:
> So the answer also means one does not need to register all agents
> individually at "setupPortrayals()" in the GUIState object to make
> show up at the display.
> Where should one lets the environment know how
> to portray the new created agents?
By "agents" in this context, I think you mean arbitrary objects. At
the risk of being pedantic, this is an important point. When I mean
"agent" I mean things which are scheduled on the Schedule to have
events called on them (have their step() methods called). These
things are the elements which change the model world. The stuff
that's stored in the world -- typically in fields -- are arbitrary
objects or values. Often these objects can be and are agents, but
they don't have to be.
Here's how object portrayal works.
At the GUI level you will assign (typically) one Field Portrayal for
each of your fields. Its job is to draw and let the user inspect and
optionally manipulate the field. Multiple Field Portrayals will be
attached to a Display (a window).
Field Portrayals come in two flavors:
- "Fast" Field Portrayals, which draw the objects or values stored in
the field using something simple like a rectangle of a given color,
and handle inspection and manipulation of objects on their own.
- General Field Portrayals, which draw/inspect/manipulate objects or
values stored in the field by calling forth certain Simple Portrayals
registered with the Field Portrayal to draw/inspect/manipulate those
MASON has a bunch of SimplePortrayals aready written for you which
draw objects as circles, squares, etc., or which "wrap" around other
SimplePortrayals to provide additional functionality, such adding a
label or hilighting an agent or making the agent movable or adding a
trail showing where he's been.
You can also create your own SimplePortrayals. And it's not uncommon
for various objects in the fields to simply subclass SimplePortrayal
themselves and thus portray themselves without the help of anyone else.