[erlang-questions] write the ant simulation in Erlang?
Fri Oct 10 08:47:04 CEST 2008
On Thu, Oct 9, 2008 at 2:47 PM, Robert Virding <rvirding@REDACTED> wrote:
> I haven't really checked the Clojure code that closely but it seems like a
> reasonable problem.
> Do you know if it "turn based" or do the all the ants just move after their
> own clocks in a parallel way?
The clojure implementation uses one thread for each ant. Each ant has
their own clock.
> A first approximation would be to have one process per ant and one for the
> world. The only problem would be handling atomic
Strictly speaking, the world state should be version'ed, the world
process should reject the move if the world has changed since the ant
looked, the ant process then should retry
look-decide-and-request-move. As an optimization, I guess the world
process can just check whether the FPA (food, pheromone, ant) value of
the target cell has changed.
I wrote a rough first cut based on the above idea:
http://pastebin.ca/1224362 - It's not completed yet, TODO:
1. pheromone evaporation
2. initialization of the world, spawn world process, spawn ant processes
3. scoring candidate cells
Am I on the right track?
> The really difficult bit is displaying it. :-)
I'm not there yet.
More information about the erlang-questions