PDA

Click to See Complete Forum and Search --> : AI, Ants and Monsters


ChuckB
Jun 10th, 2002, 11:31 PM
Hi,
I want to submit this idea for discussion. It was not appropriate for our other thread running on AI.

I was watching some ants the other day busily moving food from point A to their nest. There was a long line of ants working very steadily.

Their behavior as a group appeared highly complex which would make one think they are very smart...all of this without computers, internet, banking, etc.

However, if you were to study the behavior of EACH ant you would find they are following some very, very simple rules.
1. Leave nest. Leave smell on ground so it can find it's way back to nest.
2. Look for food or a trail for food left by another ant (smell).
3. Upon finding food, leave a second smell on ground and take food to nest one piece at a time.

Eventually enough ants find this food trail and begin getting and returning food to nest. The appearance is that they are very bright! Not really, just following a few rules.

My point is that the world appears complex, but at it's heart, it consists of a lot of simple rules at work.

So, if you want to program AI into your 3D games that is modeled after animal behavior like sharks or lions here are some general thoughts. Assume you are the human player in a world of monsters.

1. As you move around the maze the human leaves a scent in the room or passageway that diminishes after several minutes (say 30).
2. Build monsters that wander and look for food.
3. When a monster smells the human scent it gets excited and begins leaving a scent of it's own for other monsters of similar types to follow.
4. The monster follows the food scent trail.
5. As more monsters pursue the food trail, they leave stronger and stronger scents for others which drive them into a fenzy.
6. Your human player is now being stalked by a group of monsters.

The overall view from an outsider is that this highly organized group of monsters is coordinating an attack to get the human, when they are all simply following a set of basic rules.

Add a few twists or behaviors so that a monster will try to attack, get shot at and if it lives now approaches only with a second monster. It can do this be changing scent to indicate caution.

Now, create second set of monsters which like to eat the first group but finds humans distasteful. Now the food chain is at work in your game. The cool part is these monsters may be just stuff on the side while your real focus is chasing human bad guys in your game...of course these virtual guys leave human scents so they too can be pursued. Now you can lead monsters hot on your tail to these other guys and then set them up.

Oh yeah, your human enemy needs some AI so they will work to set you up as well.

I have written code where 'agents' purse your guy by doing some 2D/3D math and closing the distance. However, this is a bit unreal for most animals in the animal kingdom and monster kingdom. ;-)

A note on practical programming for this model. An array can track human and monster scents from room to room. A timer can allow the scent values to be diminished over time. A user defined type may be sufficient for defining all monsters. In fact a class with some useful methods may be even better.

Regards,

Zaei
Jun 11th, 2002, 10:18 AM
How about instead of using the word scent, we use the word presence? There are other ways of determining that the player was around without smell, and it would generalize the model =).

Then, for implementation, as the player moves he drops "ghosts", which are basically invisible entites, spaced so that each one is visible from the last one dropped. They begin to fade, and then are removed after a certain period of time. When the player is running full out, these can last from a half hour to an hour, for instance, but while they are sneaking, they might only last for a few minutes. Enemy agents can then track the player by following these entites, and trying to find the one with the most presence. Similarly, the following monsters drop these entities as well.

Another good idea you might want to look into for seemingly complex behavior is flocking (boids).

Z.

Jotaf98
Jun 16th, 2002, 04:21 PM
A presence map would be particularly useful in an RTS - so the AI knows where the player's base is, where it usually attacks, where it usually harvests resources... :)

ChuckB
Jun 16th, 2002, 05:51 PM
Hi,
What does RTS mean in relation to gaming/programming?

Presence map. Do you mean an array (1D,2D) or a user defined type that contains several variables pointing toward the player/agent?

I can see a large one dimensional array which is indexed to rooms, corridors, etc. How does one normally track their location while playing inside 3D space? 3D coordinates?

Regards,

Zaei
Jun 16th, 2002, 06:15 PM
RTS, Real Time Strategy... ie, Warcraft, AOE, etc.

There was a good article on RTS AI over on the Ensemble Studios (makers of AOE) web page... http://www.ensemblestudios.com/news/devnews/terrain1.shtml . Try that out.

Z.

ChuckB
Jun 16th, 2002, 06:15 PM
Hi,
What does RTS mean in relation to gaming/programming?

Presence map. Do you mean an array (1D,2D) or a user defined type that contains several variables pointing toward the player/agent?

I can see a large one dimensional array which is indexed to rooms, corridors, etc. How does one normally track their location while playing inside 3D space? 3D coordinates?

Regards,

jim mcnamara
Jun 16th, 2002, 07:48 PM
The presence map dates from (and I'm dating myself) the simulation called Life. circa 1972.

Jotaf98
Jun 17th, 2002, 05:29 PM
Hey nice link Zaei... I didn't know that Ensemble Studios released that sort of stuff ;)
(Looks like I found something to read for the next few days :D )

Chuck yes I guess that's they way they do it (if they use this at all), subdividing the map into small parts and having an array with the "presence values" :)

Jim... huh... nice... :)
Heh those old games remind me of the not-so-old-yet-old games like UFO, Tyrian, LBA, Abuse (ok the last 2 are from 1995 but back then I was still a kid and I was addicted to them :D ) , Heroes of Might and Magic, One Must Fall 2097, Settlers, Radix, Wolfenstein, Worms, I dunno they're so many :p