Enemy A.I. Code???

Blitz3D Forums/Blitz3D Programming/Enemy A.I. Code???

For what kind of game?

AI is going to be totally different for different games.
Simple AI is IF [Certain conditions] then [do stuff]

Of course take this a stage further and you get something like
IF [certain conditions] and [in a certain state] then [go into this state]
If [in a certain state] then [do stuff]

Makeing it more flexible still
if [certain conditions] then [change state on a sliding scale]
Then you have actions based on sliding scales rather than specific states.

In my lander game, for the bad guy fighter AI, they have fixed states of Retreat, Roam, defend, evade and attack.

So you end up with stuff like

If roaming and can see a goodguy then attack said goodguy
If attacking and health low then retreat
if attacking and a goodguy is in my sights then shoot the bugger
If I can see someone attacking another badguy then defend said badguy
If retreating and getting shot then evade
if retreating and can't see any goodguy then roam
if roaming and can't see anyone then find a newpoint to roam to

on top of this you had the non state ai that was:
If too close to the ground then pull up
If too high then push down
if too far off course then turn back on course
if there is a mountain in front of me pull up

and so on.

The scouts had a different set of states and ai conditions, likewise the defence cannons.


I hope that helps some!?