Programming 'Eaters' in Pacman

Hello Everybody! I have loggged on after a very looooooong time ...so please cooperate!

I am making a game of PacMan (in 2D graphics) for my school project. Its almost complete but i am stuck in one place. I CAN'T DEVISE A STRATEGY TO PROGRAM THE 'EATERS'(i hope you know 'eaters' in Pacman) ....i.e. How they Chase Them????How They Move Automatically on their own to chase pacman???? How I program its AI?? Please help me out before this vacation ends..... If you require some useful part of my code ..please reply... THANK YOU (atleast for 'READING!')

Comments

This sounds like fun.If I remember right, the eaters only change direction when they get to certain points, i.e. they don't change direction at any position on the screen. They get to these points and when they do, a function is called to determine which directions are available, up, down, left or right. Out of these possible directions, it will decide which will reach you the quickest.

A basic AI is to use this as if you were stationary and find the shortest path from the eaters position to you.

A more complex function is to assume that PacMan is going to be heading in the same direction he is now. i.e. PacMan is travelling upwards, whenever the AI function is called, take this in and then decide which is the shortest path on the assumption that PacMan is heading up at a constant speed.

I'll be really interested to know how you're able to create these images in C++. People keep linking me to sample code but it just doesn't seem to work on my computer. (I'm using C++ BuilderX)

If you're confused by my description, imagine you're chasing someone in a car and you know where they are. When you arrive at a junction in the road, you want to take the shortest route to catch the target.

: Hello Everybody! : I have loggged on after a very looooooong time ...so please cooperate! : : I am making a game of PacMan (in 2D graphics) for my school project. : Its almost complete but i am stuck in one place. : I CAN'T DEVISE A STRATEGY TO PROGRAM THE 'EATERS'(i hope you know 'eaters' in Pacman) ....i.e. : How they Chase Them????How They Move Automatically on their own to chase pacman???? : How I program its AI?? : Please help me out before this vacation ends..... : If you require some useful part of my code ..please reply... : THANK YOU (atleast for 'READING!') :

I would let each one of them use a shortest-path algorithm (shouldn't be hard to find the source for one on the net) to calculate the fastest way to move between themself and pacman. But they would be too smart if they used that algorithm all the time, the player wouldn't have a chance. So you need to add somekind of random behaviour to them. Perhaps if they are close to pacman, they will turn smarter and chase him, but if they are far from him they just fool around.

The easier alternative is to make them move around randomly all the time - have them move in one direction and let them make a new decision at every intersection they come to in the maze.

: Hello Everybody! : I have loggged on after a very looooooong time ...so please cooperate! : : I am making a game of PacMan (in 2D graphics) for my school project. : Its almost complete but i am stuck in one place. : I CAN'T DEVISE A STRATEGY TO PROGRAM THE 'EATERS'(i hope you know 'eaters' in Pacman) ....i.e. : How they Chase Them????How They Move Automatically on their own to chase pacman???? : How I program its AI?? : Please help me out before this vacation ends..... : If you require some useful part of my code ..please reply... : THANK YOU (atleast for 'READING!') : : : :

This is how I would do it:

When an eater get to an intersection:if pacman has higher x value and it's possible to go right set dx to 1if pacman has lower x value and it's possible to go left set dx to -1if pacman has higher y value and it's possible to go down set dy to 1if pacman has lower y value and it's possible to go up set dy to -1

hey this is a really interesting project...are u going to put the final code up anywhere? i would be interested in viewing it...

about ur problem...i think u shud program the eaters to move around the screen randomly then if they get within a certain distance of pacman, they begin to chase him...if they are constantly chasing him it would get too hard because they would constantly hone in on his position...imagine the situation while ur playing the game...if all the eaters jus keep moving to u...

it myt also be interesting if u program them to do the reverse...when he's powered up (as in when he can eat them) , and they are nearby, they could run away from him...