<div dir="ltr">I haven't really checked the Clojure code that closely but it seems like a reasonable problem.<br><br>Do you know if it "turn based" or do the all the ants just move after their own clocks in a parallel way?<br>
<br>A first approximation would be to have one process per ant and one for the world. The only problem would be handling atomic look-at-the-immediate-world-around-me-and-make-a-move.<br><br>The really difficult bit is displaying it. :-)<br>
<br>Robert<br><br><div class="gmail_quote">2008/10/9 Brian Zhou <span dir="ltr"><<a href="mailto:b88zhou@gmail.com">b88zhou@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Let me try to reverse engineer some kind of spec:<br>
<br>
* On a world of 80x80 cells, there are 49 ants, and 35 scattered cells<br>
with food.<br>
* Initially the ants are in their home, a square from (20, 20) to (26,<br>
26), facing random directions.<br>
<br>
* An ant can move ahead, turn 45 degree left, or 45 degree right, every 40ms.<br>
* Ant should not move ahead if there is another ant in the ahead cell.<br>
* Whenever ant make a move, it leaves a pheromone trail by increment<br>
pheromone amount by 1.0 in the previous cell.<br>
<br>
* For an ant without food,<br>
** If ahead is not home, and there is food ahead, move ahead, take<br>
food and turn around;<br>
** Among cells that are ahead, ahead-left (45 degree), ahead-right (45<br>
degree), turn/move to the one with the most (if (contain-food?) 1 0) +<br>
pheromone score, if all equal, turn/move randomly;<br>
<br>
* For an ant with food,<br>
** If ahead is home, move ahead, drop food and turn around;<br>
** Among cells that are ahead, ahead-left (45 degree), ahead-right (45<br>
degree), turn/move to the one with the most (if (at-home?) 1 0) +<br>
pheromone score, if all equal, turn/move randomly;<br>
<br>
* Every 1 second, the pheromone in all cells evaporate to 99% of the<br>
previous amount;<br>
<br>
* If a graphical animation is provided, the animation is refreshed every 100ms.<br>
<br>
* Hard-coded numbers are used above to make description easier. They<br>
are actually adjustable.<br>
<br>
;dimensions of square world<br>
(def dim 80)<br>
;number of ants = nants-sqrt^2<br>
(def nants-sqrt 7)<br>
;number of places with food<br>
(def food-places 35)<br>
;range of amount of food at a place<br>
(def food-range 100)<br>
;evaporation rate<br>
(def evap-rate 0.99)<br>
<br>
(def animation-sleep-ms 100)<br>
(def ant-sleep-ms 40)<br>
(def evap-sleep-ms 1000)<br>
<br>
Anyone feel free to correct me if my understanding is not right.<br>
<br>
-Brian<br>
<br>
On Wed, Oct 8, 2008 at 7:46 PM, Richard O'Keefe <<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>> wrote:<br>
> Bearing in mind that it really isn't practical<br>
> for someone in NZ to watch videos over the international net,<br>
> can you tell me what the ant simulation problem is?<br>
<div><div></div><div class="Wj3C7c">><br>
><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>