most likly they were following the scnet left by the previous ant who found the food.
a really cool ant simulation is the fractal varient. a single (or muliple, but no collision detection, communication, etc) ants move using the following rules:
1. the ant reverses the color of the pixel he is on (ie black goes to white, white goes to black).
2. if the pixel is white (odd) the ant turns left 90 degrees.
3. if the pixel is black (even) the ant turns right 90 degrees.
4. the ant moves forward one pixel
i am pretty sure that is the right order for things. its not a "true" ant simulation, but quite interesting due to the infinite pattern that is created (if implemneted correctly) that a single ant will produce after a while. though with some tweaking, very cool looking images can be created. especially if you use different start images to work with.
ants behaviour
hi,
ohhhhh crazy ant behavior story...
ants use the shortest time path not the shortest physical path.
good point!!!
With this new element I think that we can say that the ants tends to find the shortest path in distance because the shortest time path is in general the shortest distance.
consider a nest A and two places of foods (F1 and F2). In distance AF1 < AF2. the ants start to move randomly. they have equal chances to find F1 or F2. but AF1 is the smallest distance so if we consider that when a ant find some foods they put pheromon on the ground from F1 to A then the path AF1 will have more pheromon than AF2. So the ants will follow the shortest path in distance.
is it a good reasoning?
I would like also share with you the finite state machine and the rules that I should use for the simulation.
FSM
search food
follow pheromon path
go home
the rules
1 - if a ant has no food then search food
2 - if a ant find food then bring it back to the nest
3 - if an ant find pheromon then follow pheromon (which direction?)
4 - if an ant is in a nest and has some food then put food.
5 - if an ant is in a nest and has no food then search food.
any comment?
ohhhhh crazy ant behavior story...
ants use the shortest time path not the shortest physical path.
good point!!!
With this new element I think that we can say that the ants tends to find the shortest path in distance because the shortest time path is in general the shortest distance.
consider a nest A and two places of foods (F1 and F2). In distance AF1 < AF2. the ants start to move randomly. they have equal chances to find F1 or F2. but AF1 is the smallest distance so if we consider that when a ant find some foods they put pheromon on the ground from F1 to A then the path AF1 will have more pheromon than AF2. So the ants will follow the shortest path in distance.
is it a good reasoning?
I would like also share with you the finite state machine and the rules that I should use for the simulation.
FSM
search food
follow pheromon path
go home
the rules
1 - if a ant has no food then search food
2 - if a ant find food then bring it back to the nest
3 - if an ant find pheromon then follow pheromon (which direction?)
4 - if an ant is in a nest and has some food then put food.
5 - if an ant is in a nest and has no food then search food.
any comment?
May 08, 2002 09:08 AM
I''d wonder do ants communicate in some way about the distance/time-distance that they took to get to food?
If they do, they would communicate to other ants "Hey, my path took x time to get there, do you know of a shorter path?"
Can they remember (at least to the point of being able to compare between several paths) which is the shortest path they have followed so far?
If none of the above, how do they know which is the shortest path, and therefore follow it, and therefore make the pheromones strongest along that path? It would seem that ants must, somehow, be able to keep track of time.
Just another idea there.
If they do, they would communicate to other ants "Hey, my path took x time to get there, do you know of a shorter path?"
Can they remember (at least to the point of being able to compare between several paths) which is the shortest path they have followed so far?
If none of the above, how do they know which is the shortest path, and therefore follow it, and therefore make the pheromones strongest along that path? It would seem that ants must, somehow, be able to keep track of time.
Just another idea there.
I think each ant follows the path with the largest quantity of pheromons. as I said previously there is a good luck that the shortest path = the path with the largest quantity of pheromon.
So the ant follows the shortest path (in general )
So the ant follows the shortest path (in general )
yup, all social ants base their foraging on pheromone trails. They do have more than one sort of pheromone however...
Jari Komppa wrote a great little demo for the Flipcode bugs programming contest which illustrates this simple principal very nicely. I think Flipcode should still have the demo but if not you can contact the man himself here:
solar@icon.fi
http://iki.fi/sol
icq 44620217
Well worth looking at if you like ants.
Stimulate
Jari Komppa wrote a great little demo for the Flipcode bugs programming contest which illustrates this simple principal very nicely. I think Flipcode should still have the demo but if not you can contact the man himself here:
solar@icon.fi
http://iki.fi/sol
icq 44620217
Well worth looking at if you like ants.
Stimulate
My Website: ai-junkie.com | My Books: 'Programming Game AI by Example' & 'AI Techniques for Game Programming'
hi,
I can see 3 classes :
ants, nest and garden
I would like to represent pheromon on the ground. each time that a ant find some food it goes back to the nest putting the pheromon on the ground. ButI don''t know how to store the information about the pheromon on the ground of the garden.
should I have an array of position corresponding to the position where there is some pheromon?
any other suggestion?
thank you!
I can see 3 classes :
ants, nest and garden
I would like to represent pheromon on the ground. each time that a ant find some food it goes back to the nest putting the pheromon on the ground. ButI don''t know how to store the information about the pheromon on the ground of the garden.
should I have an array of position corresponding to the position where there is some pheromon?
any other suggestion?
thank you!
3 ways...
1)pheromon is an object. a vector corresponding to a position. you store it in a container. for example you could have the pheromons call to the ants. for example you iterate through a stack right. and for each p you give it a chance to operate on the ant. this is a pretty common way to do things but it seems and prolly is conceptually backwards.
2)*reject this* you can store pheromon as a value in a 2d array/ dumb matrix. good cause its easy to search all the pheromons in a radius. or is it. compared to the above its prolly more expensive. easier however since they are values. but reject this cause its a memory hog.
3) there are classes out there called. hmm what is the name. loosely populated matrixes. what they are are matrixes that assume that most values will be 0. they dont take up alot of room cause of that. guess it would be like a map,float> in a way. noting that a map lets of check for a pair by value in log(n) time. think there are better sparsly popped matrix classes out there though. map prolly work just as well however since we dont need matrix ops.
so basically its 1 or 3. 1 is easiest as long as you push to keep it simple. 2 is prolly the simpliest. 3 aint much harder had we the class already on your computer. *makes mental note to find a good sparse matrix*
[edited by - declspec on May 8, 2002 6:18:00 PM]
1)pheromon is an object. a vector corresponding to a position. you store it in a container. for example you could have the pheromons call to the ants. for example you iterate through a stack right. and for each p you give it a chance to operate on the ant. this is a pretty common way to do things but it seems and prolly is conceptually backwards.
2)*reject this* you can store pheromon as a value in a 2d array/ dumb matrix. good cause its easy to search all the pheromons in a radius. or is it. compared to the above its prolly more expensive. easier however since they are values. but reject this cause its a memory hog.
3) there are classes out there called. hmm what is the name. loosely populated matrixes. what they are are matrixes that assume that most values will be 0. they dont take up alot of room cause of that. guess it would be like a map,float> in a way. noting that a map lets of check for a pair by value in log(n) time. think there are better sparsly popped matrix classes out there though. map prolly work just as well however since we dont need matrix ops.
so basically its 1 or 3. 1 is easiest as long as you push to keep it simple. 2 is prolly the simpliest. 3 aint much harder had we the class already on your computer. *makes mental note to find a good sparse matrix*
[edited by - declspec on May 8, 2002 6:18:00 PM]
hello,
Thank you everybody for your answer. I still need your help:
I would like to know how the ants choose the right direction when they find pheromons. Imagine the following situation:
an ant finds some pheromons on the ground. So it has to follow the path. But how can it find the direction? basically there is two directions: one direction through the nest and the other through the food.
I have an data structure which stores the quantity of pheromons for each square. So when an ant find some pheromon we can represent the situation like this:
5 4 2
0 3 5
2 1 0
each number represents the quantity of pheromon. The ant is in the square with the number 3. I have to find out which direction the ant has to take. I can find the two biggest numbers. here it is 5. but how can I define which 5 the ant has to go to find the food?
Any suggestion would be very nice!!!
thank you
Thank you everybody for your answer. I still need your help:
I would like to know how the ants choose the right direction when they find pheromons. Imagine the following situation:
an ant finds some pheromons on the ground. So it has to follow the path. But how can it find the direction? basically there is two directions: one direction through the nest and the other through the food.
I have an data structure which stores the quantity of pheromons for each square. So when an ant find some pheromon we can represent the situation like this:
5 4 2
0 3 5
2 1 0
each number represents the quantity of pheromon. The ant is in the square with the number 3. I have to find out which direction the ant has to take. I can find the two biggest numbers. here it is 5. but how can I define which 5 the ant has to go to find the food?
Any suggestion would be very nice!!!
thank you
well i would first off use two different pheromones for home and food. makes more sense and follows nature a bit better (i think). now if the ant has no food, he would follow food pheromone trail. in situtaions where two equally strong scents are availble you could do the following:
1. "look" at a larger grid. then average values so that each box around the ant contains the avg of all surround boxes of that box. i hope that makes sense.
2. have the ant choose the path that requires the least turning. you could also implement a smoothing function which during the fade of the scent would also will avg surrounding boxes. this would help simulate scent dispersion that would occer naturally. i would not try implementing wind since that could make things more difficult. instead go for getting the behavior you want, then play around with adding extras.
1. "look" at a larger grid. then average values so that each box around the ant contains the avg of all surround boxes of that box. i hope that makes sense.
2. have the ant choose the path that requires the least turning. you could also implement a smoothing function which during the fade of the scent would also will avg surrounding boxes. this would help simulate scent dispersion that would occer naturally. i would not try implementing wind since that could make things more difficult. instead go for getting the behavior you want, then play around with adding extras.
You could also base it on distance from nest. If your looking for food, most likely you woul''d take the trail that leads you away from the nest, and vice versa.
[My site|SGI STL|Bjarne FAQ|C++ FAQ Lite|MSDN|Jargon]
Ripped off from various people
[My site|SGI STL|Bjarne FAQ|C++ FAQ Lite|MSDN|Jargon]
Ripped off from various people
[size=2]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement