[erlang-questions] write the ant simulation in Erlang?
Brian Zhou
b88zhou@REDACTED
Thu Oct 9 06:46:29 CEST 2008
Let me try to reverse engineer some kind of spec:
* On a world of 80x80 cells, there are 49 ants, and 35 scattered cells
with food.
* Initially the ants are in their home, a square from (20, 20) to (26,
26), facing random directions.
* An ant can move ahead, turn 45 degree left, or 45 degree right, every 40ms.
* Ant should not move ahead if there is another ant in the ahead cell.
* Whenever ant make a move, it leaves a pheromone trail by increment
pheromone amount by 1.0 in the previous cell.
* For an ant without food,
** If ahead is not home, and there is food ahead, move ahead, take
food and turn around;
** Among cells that are ahead, ahead-left (45 degree), ahead-right (45
degree), turn/move to the one with the most (if (contain-food?) 1 0) +
pheromone score, if all equal, turn/move randomly;
* For an ant with food,
** If ahead is home, move ahead, drop food and turn around;
** Among cells that are ahead, ahead-left (45 degree), ahead-right (45
degree), turn/move to the one with the most (if (at-home?) 1 0) +
pheromone score, if all equal, turn/move randomly;
* Every 1 second, the pheromone in all cells evaporate to 99% of the
previous amount;
* If a graphical animation is provided, the animation is refreshed every 100ms.
* Hard-coded numbers are used above to make description easier. They
are actually adjustable.
;dimensions of square world
(def dim 80)
;number of ants = nants-sqrt^2
(def nants-sqrt 7)
;number of places with food
(def food-places 35)
;range of amount of food at a place
(def food-range 100)
;evaporation rate
(def evap-rate 0.99)
(def animation-sleep-ms 100)
(def ant-sleep-ms 40)
(def evap-sleep-ms 1000)
Anyone feel free to correct me if my understanding is not right.
-Brian
On Wed, Oct 8, 2008 at 7:46 PM, Richard O'Keefe <ok@REDACTED> wrote:
> Bearing in mind that it really isn't practical
> for someone in NZ to watch videos over the international net,
> can you tell me what the ant simulation problem is?
>
>
More information about the erlang-questions
mailing list