Basic A.I. Research

By | April 14, 2006

Some time back, well roughly half a year back, I was in charge of designing and implementing a ocean simulator. A small portion of this meant researching some basic A.I. And I do mean basic. In this summarized article I will try and shed some light on how to research and build a basic A.I. system.

Ok so now what?
Good question! I had the same one when I started. Ok so I need some sort of A.I. to make my fish ‘seem’ intelligent. You noticed the word seem didn’t you. Let me bust a myth for you. No matter how good you build A.I. it only simulates real intelligence and it is not intelligent, but then again some claim the same about me.

Where was I, oh yeah your first step into researching what to do. Ok this is what I did and it worked pretty well for me. I contacted a guy who new a lot about oceans and fish life. Did some questioning on what type of behaviour the little buggers had and how they interacted with each other. Write a list, this is important you hear! Without kidding you will need to know some basic behaviour. For my fishies (hmm hungry) these were simple:

  • Be able to track fishy of the same species
  • Have sex (I guess you’d prefer reproduce but the result is the same)
  • Chase food when they are hungry
  • Flee when chased by hungry fish (doh)
  • Create patterns specific to the species and generation of the fishy
  • Remember locations and forget (well I guess they weren’t so smart)

Of course it gets somewhat more complicated because I left out speed calculations and calculating health, but this little list will do for the example.

Defining each behaviour
Ready for the next step, well I am. Take your list and write down IN WORDS what you expect the objects to do when they experience the behaviour. Why in words, simple any monkey can translate those words into formulas or behavioural models. Its a lot harder to say what the fish is to do then make a formula. Besides if you don’t know what its supposed to do how do you create the formula? I’ll describe one for you, yeah I know I’m lazy:

Tracking fishes of same species
When a fish comes into proximity of a fish of the same species this fish will start swimming towards it until it is a preset distance removed from the fish. Once at this distance it will start moving tracking the fish, which means moving towards it until the proximity is again met. One constraint in this is the distance and the hunger the fish has. The farther the groups is removed and the more hungry a fish is the less chance it will start tracking. The same goes for health, the lower this is the more likely the chances of tracking as this will protect the fish.

Now that was easy wasn’t it. This is a basic representation of what any fish should do in case of tracking. You might have noticed but I used a case in which there is a gradient scale. The amount of health in comparison to the amount of hunger combined with distance. To solve this you could do two things. Apply fuzzy logic, which is the option I choose. Or you can create a neural network.

Translate into formula’s & state machines
This is the point where the techies start getting exited. Yes you can get out your calculators and other stuff you think you need (though I didn’t use any of that and you don’t need to). Start translating the descriptions you’ve just made into formula’s or state machines. Granted I picked a too complex example for this but I’ll try anyway. Please not I’ll limit it to the tracking part not the gradient deciding if the tracking is going to be applied. You can achieve this by defining a step scheme.
Tracking fishes of same species
1. Normalize the vector containing direction and distance between the two fishes
2. Recalculate the direction vector for the fish that will track using formula fish.dx = R * dr.dx (same for dy)
3. Check the speed of the fish does not exceed the maximum level allowed
4. Add some noise to simulate drift and streams in the water. This can be anything between -1 and 1.
In this calculation R is a speed factor that is previously calculated using other behavioural functions.

Nice he. Now you have a more technical approach to the word track of the description you made earlier. You’ll still have to do this for the gradient selection process, but that goes way beyond this article.

You’re done
Well not exactly but this article was only about doing some research into basic A.I. not actually implement it. Maybe I’ll write something about that in the future. You’re always free to ask for some advice on the fuzzy logic, I wrote it in C# and if I can help you I will.

Leave a Reply