AI issue

Hello, in my SDL 2D game, my enemy bot needs AI for "1: running away" and "2: chasing me".
When he is it, the col3 bool will be true. when im it, the col1 bool is true and col3 bool is false. Basically so far, he just follows my moves and it works OK but i need to expand. I am myX and the bot is botx. sme with the Y coordinates.
1
2
3
4
5
6
7
   if (col3 ==true)
{
if (boty < myY) boty+=0.44;//if im above him, he moves up, if Im left, he moves //left
else if(boty > myY) boty-=0.44;
//^^ same with the X position.
//Basically the same if he is running away, but opposite,
}

When he hits an obstacle, im on one side and he's on the other, he needs to move toward me but the obstacle is there. So he just waits untill i got above the obstacle and he get me...
thankyou
You have a very interesting world just opening up in front of you.

http://en.wikipedia.org/wiki/Pathfinding
and
http://en.wikipedia.org/wiki/A*_search_algorithm

should get you going. Experiment and have fun :)
jeez thanks man! this helped i was looking for some site like this
I got the start but didnt really understand how to do it. . .
could u maybe summarise it and how i could do it ?
will this make my bot have like its own mind or just navigate around and no how to avoid me?
will iit be hard to do?
Pathfinding will give you the path between two points on your map. When you have the path you can make your enemy follow it. You probably have to recalculate the path from time to time when the player moves.

I think this article about A* is quite good:
http://www.gamedev.net/page/resources/_/technical/artificial-intelligence/a-pathfinding-for-beginners-r2003
Topic archived. No new replies allowed.