Archived

This topic is now archived and is closed to further replies.

ants behaviour

This topic is 5685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, I would like to create a simulation about the ants ''s behaviour. I would like to know if someone has knowledges about that or know some web sites where I could find information. thank you for your help!

Share this post


Link to post
Share on other sites
I would like to create a simulation about the ants ''s behaviour.

that sort of thing will make you sooo much stronger of a programmer then following recipes/tuts/biting off huge game chunks. find things that you are interested in.

you want to bring ant behavior to a simulation. think your buzz word that you might find interesting is "ALife". if you knew that sorry.

google.com had intersting results but i cant say i know the turf.
http://www.google.com/search?hl=en&q=Alife+Ants

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Long post ahead, but some good stuff (I think)...

I''m sure you could find some good biology/zoology books on ant and/or insect behaviour. The main emphasis on ant behaviour is social interaction and group based behaviour, a single ant on its own is not too intelligent, but the colony as a whole (like a living organism) is!

----- ANT PATHFINDING --------

For pathfinding, Ants lay down pheremone trails (as more Ants move along a certain path, the stronger the pheremone trail). Pathfinding around an object is done purely by trial and error, but once the pheremone track is strong enough it will be maintained. If the food source at the end of the path dries up, then so does the pheremone trail, and a new trail will be laid down to a new food source. Ants which do not adhere to the pheremone trail much, and vere off can be regarded as less intelligent (and maybe die off, allowing a genetic evolution of your colony to become stronger!)

------ ANT COMMUNICATION ----------

Leaf-cutting Ants (found mainly in South and Central America), also communicate by rubbing a file against their abdomens, to create a sound (audible to humans). They also carry out a form of division of labour to tend their mushroom gardens. Some ants find leaves, some maintain a compost heap, others expand the nest.

Further research shows a wide range of signalling abilities. Including signals for:

* warning
* attraction
* grooming
* recognition
* discrimination
* caste determination
* territorial indicators
* sexual communication

The medium for all of these signals is also chemical based, ''it appears that a colony operates most effectively when its members are genetically tightly knit''. Therefore, an Ant which strays onto foreign territory is killed by the other colony (for those gruesome ones out there, it is held by its mandibles whilst it is stung or sprayed with a toxic substance such as formic acid!)

------- OTHER FACTS -----------

studies also indicate that orientaion is also achieved through memorising visual landmarks, they also make use of the suns location for navigation when the pheremone trail has been removed by sandstorms or winds.

Most of this stuff has been taken from a book written by my tutor at uni:

"QI: The quest for intelligence"
By Professor Kevin Warwick, Department of Cybernetics, University of Reading

That should be plenty to get you started, along with a little imagination, you should be able to come up with a good start.

I''ve developed a more crude system of cells which genetically evolve, based on three types of cell, varying in strength, and with mutations being generated which actually kill weaker cells, which not only strengthens the overall conlony, but also prevents the colony growing at an exponential rate, and keeps it at some reasonable optimum. You might want to consider either predators, or severe punishments for un-intelligent ants.

Hope this helped, and if you''re still reading, then sorry it was so long!

cheers

Matt

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
For a interesting simulation you would want to make each ant a seperate entity, I think the word is single celled automaton. So don''t have a outside class that just tells all the ants to walk in a line towards the food, but give each ant a few possible states one of which is current, and a few actions and communications. After programming what a individual ant should do, then throw a bunch of them together in a simulator with food, tunnels and a queen ant and try to see if they can work together. Then tweak the ant class code until they will work together nicely. Really when you program what goes through a ants mind and what influences his decisions, you probably don''t need much technical info, you just have to know what a ant priorities are, you can almost bet they want sex first if horny, then food next with foods with higher suger being preferred, and then have to rest every so often. And if the chunk of food is more then 500 times the ants weight, it must break it into smaller pieces to carry. You also want to make sure they can tell other ants a direction of a food source or say follow me.

Share this post


Link to post
Share on other sites
ya the general thing to keep in mind is its the little rules making complicated behavior.

dont have a hive class that decides that we need to expand.

tweak the rules for the individual ants then see what happens in mass.

Share this post


Link to post
Share on other sites
hi,

thank you for your answers.


----- ANT PATHFINDING --------

For pathfinding, Ants lay down pheremone trails (as more Ants move along a certain path, the stronger the pheremone trail). Pathfinding around an object is done purely by trial and error, but once the pheremone track is strong enough it will be maintained. If the food source at the end of the path dries up, then so does the pheremone trail, and a new trail will be laid down to a new food source. Ants which do not adhere to the pheremone trail much, and vere off can be regarded as less intelligent (and maybe die off, allowing a genetic evolution of your colony to become stronger!)

this is exactly what I would like to simulate. after a while, we should be able to see what is the shortest way between the colony and the food. I m going to read several articles about taht and I will give a feedback.

thank you



Share this post


Link to post
Share on other sites
ohhhhh crazy ant behavior story...

ants use the shortest time path not the shortest physical path.

i was walking along one day heading to school bout two years ago. i notice this string of ants. now this string was running along the edge of some grass on the concrete right. but the concrete took a corner. a walk way up to a church.

but picture the scene the ants werent using straight line shortest distance through the grass. if they had been it would have been atleast a 45 degree junt off into the grass to clip the corner since the path was strong 10 feet in each direction along the concrete.

conclusion ants use fastest routes not shortest distance. but how does an ant figure out which way is faster? im sure its not magic. but its still interesting.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?








Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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 )

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
great!!
thank you very much!!!!! Note that for the scent dispersion I use a time function. every ten loops, the quantity of pheromon decrements by one.(quantity>0)

Share this post


Link to post
Share on other sites
Two things :
I dont remember exactly the actual facts, as I have read the book a while ago, but here is a way it can be done.
When looking for food, the ant leave a light trail of pheromones, until it find food.
Then, depending on how much food has been found, the ant goes back to the nest, marking its trail again, with an intensity depending on the amount of food found.
When an ant find an existing path and is in wandering mode, it has two choices : follow the trail and see what''s there, or follow your own path. The probability for following the trail increase with the intensity of the trace.
Note that the pheromone must evapourate gradually ! Not totally after a while, but a little bit every unit of time.
I have some ideas about what would happen, but I must say without a picture it''s hard to explain.

Second, how do you know you are going home or towards the food ?
Simply put, ants dont look just in front of them, they also know which way they are facing. So you just need to have a method to figure out which way is your nest, because really, you dont care where you are goind when you are in "wandering mode", and you dont really care either when you are following a trail. Using a fixed reference point, like the sun, would help, I guess (I should check out my book again).

Ah, and something very cool that you can try :
create a world (tile based), with cells containing food spread randomly. Then put a few randomly placed, randomly moving "ants".
(ants can walk on cells containing food, but not on other ants).
They have only two rules :
-if I dont carry anything, if there is food in front of me, take food with probability of taking the food inversely proportional to the amount of food nearby (the more food against this piece of food we want, the less we want to take it).
-if we carry food and there is food around us, drop the food, with the probability of dropping the food proportional to the amount of food nearby (the more food, the more we want to drop the food we carry here).
It''s REALLY simple to implement, and the results should be pretty cool try it and behold the power of Emergent Behaviour !




Sancte Isidore ora pro nobis !

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Anonymous Poster
Ants which do not adhere to the pheremone trail much, and vere off can be regarded as less intelligent (and maybe die off, allowing a genetic evolution of your colony to become stronger!)


No, cos those ants don''t reproduce.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Ants which do not adhere to the pheremone trail much, and vere off can be regarded as less intelligent (and maybe die off, allowing a genetic evolution of your colony to become stronger!)


Actually, you NEED ants that will vere off. That''s the power of ants : because one will try something different for no good reason, suddenly they will find something new. If they all followed each others blindly, they would all end up doing the same just like stupid lemmings.
It''s actually the ones that stray away that give the nest the potential for new discoveries (metaphorically and literally speaking).

Also be careful when you talk about genes and ants, remember that they are all born from a queen, and if my memory serves me well, workers only have half of the set of genes, I think they are all clones, actually, except the princes/princesses. (correct me if I am wrong, I am a bit rusty on myrmecology).

Also did anyone try my ants gathering routine ? I would love to know what you guys think. It''s a really cool emergent behaviour demo that I discovered in a programming article way before there was all that fuss about boids, and I still think it rules





Sancte Isidore ora pro nobis !

Share this post


Link to post
Share on other sites
interesting.

not enough strays == no discoveries.. not enough search of the problem space.

to many strays == to many discoveries.. not enough work done period.

wonder how it comes into balance.

Share this post


Link to post
Share on other sites