[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Swarm-Support] setting flags for agents
From: |
Paul Johnson |
Subject: |
Re: [Swarm-Support] setting flags for agents |
Date: |
Wed, 27 Jun 2007 01:04:10 -0500 |
User-agent: |
Thunderbird 2.0.0.4 (X11/20070615) |
address@hidden wrote:
I am trying to give agents memory of where they have walked. To do this I am
creating a flag in a class Cell (similar to HabitatCell in StupidModel).
Currently, all agents can set and get this flag by:
Cell flags = (cell) cellWorld.getObjectAtX$Y(myX, myY);
flags.setFlag(num);
flags.getFlag(num);
As each agent walks through the Grid2dImpl space they change the flag from a 0
to one. The agents can then see where others have walked and not walk on those
spaces. I do not want this feature. I would like the agents to set and get
their own flags, which will allow them to only see where they have walked. Any
suggestions on how to do this with Java Swarm 2.2.
Thanks
Shawn
Instead of creating one Grid2dImpl that all agents share, just create
one inside each agent. Let them keep records on that Grid2d. If you
want privacy without doing a ton of work, do that. Since you already
have a working piece of code for the grid, it will be easy to copy that
inside the agent class...
Steve's idea of keeping a list of cells you have been to is OK, except
the program may start to run really slow once the agents have been
around and they start asking "have I been here" over and over. If the
cells were stored in a fast searchable collection, say a binary tree or
hash, then it might address that. But if you just put markers on the
grid, it works.
I also like the idea Glen had where the cell keeps information on all
agents that have been there, and then each agent can just ask for info
on itself. You could avoid some slow down there by using a swarm Array
to keep the agent records and put the agents in by an integer ID
number. Fast! Fast!
pj
_______________________________________________
Support mailing list
address@hidden
http://www.swarm.org/mailman/listinfo/support
--
Paul E. Johnson email: address@hidden
Professor, Political Science http://pj.freefaculty.org
1541 Lilac Lane, Rm 504
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66044-3177 FAX: (785) 864-5700