Help with A.I

Blitz3D Forums/Blitz3D Programming/Help with A.I

A simple A.I. pseudocode fo rabbits:
for rabbit.t_rabbit = each t_rabbit
if rabbit\status = S_IDLE then
if entitydistance(rabbit,player) < 10 then

   ;change rabbit status
   rabbit\status = S_MOVE

   ;generate a target pivot where the rabbit should move to
   x = entityx(rabbit\entity)
   z = entityz(rabbit\entity)
   rabbit\target = createpivot(x,z)

endif
endif

play_rabbit(rabbit)

next

function play_rabbit(rabbit.t_rabbit)
;move the rabbit until he reaches the target
if entitydistance(rabbit\entity,rabbit\target) > 10 then

   ;turn the rabbit toward the target
   pointentity(rabbit\entity,rabbit\target)

   ;move the rabbit on the z axis
   moveentity rabbit\entity,0,0,0.5
else
   ;reset the status
   rabbit\status = S_IDLE
endif
end function


Hope this helps...

Sergio.