[erlang-questions] write the ant simulation in Erlang?
jm
jeffm@REDACTED
Fri Oct 10 02:51:38 CEST 2008
Richard O'Keefe wrote:
> I was wondering about dividing the world into patches.
>
>
This was my first reaction when seeing a description of the problem. To
create a process for each square and then use a naming convention for
the processes, eg world_x_y where x, y are the co-ordinates of the
square. For an 80 x 80 world this would be 6400 processes just for the
world plus 49 ant processes which I thought might be a bit of an over
kill. I was also concerned that the process name look up may be a bottle
neck.
The API for the square processes might be something along the lines of
* look return the status of the square. Presents of ant, food, etc.
* take move to this tile. Returns success or failure.
The ant would look at the square to see if it was empty and if there was
any food. If the square was chosen as the next location the ant would
attempt to move there by attempting to take the square which could fail
if another ant had taken the square in the interim. In which case it
would look for a new square, otherwise it would up date its own status
to reflect the new location.
Jeff.
More information about the erlang-questions
mailing list