AUTOMATED GHOST MOVEMENT LIKE IN PACMAN

Hi, my name is Michael. I have been working on a game that is similar to pac man…Ive got everything set up except the movement for the “Ghost.” I have tried many different ways to set up this movement but I cant seem to get the “ghost” to navigate the maze. Any Ideas?

Ok so i think the scripts/codes won’t bother me much in the game i’m trying to make but i got a big problem,i’m not very good at making sprites(i tried MS Paint but it didn’t work out so well :frowning:) so is there any free and good Sprite making tools out there,i tried searching it but i can’t find a good one,so anyone here can give me a good sprite making tool ? Thx in advance

On google you can find plenty of good sprite making freeware. However, generally what works for some wont work for others. MS Paint and photoshop have worked well for me. IF your looking for something that will have premade sprites, it doesn’t really exist. At least not something you wont have to pay a crap ton of royalties to. Doing the art yourself or having someone do it for you are your best options.

The IA algorithm for that goes like this:

  1. Choose a random direction (up, down, right, left).
  2. Check if the next cell of the grid located in that direction (relative to the current cell) is a wall.
  3. If the cell located in that direction is a wall return to step 1.
  4. If the cell located in that direction is open road then move the ghost to that cell and return to step 2.

That’s the basics, try to implement it.

that’s the algorithm for the pathfinding automatism yes?

No. That’s more similar to the depth-first algorithm than the A* algorithm.

Maybe the “go anywhere if you can” algorithm? :laughing:
From Wikipedia, one of the ghosts works like that (the orange one), taking a walk randomly over the entire map.

But the others follow another rules, a standard ghost AI could be performed through the Pathfinding Automatism, I think :slight_smile:
Give it a try, and let us know is something crashes (I seem to remember that this automatism was a bit broken) :smiley:

Yes, it’s a free implementation of the depth-first algorithm, and the result is “go anywhere if you can”; I don’t know what other rules follow other ghosts; but for example you can modify that algorithm to change the direction of the ghost towards the player if the player and the ghost are in the same column or row, without obstacles between them (that will be the “go anywhere if you can but chase the player if you see it”) algorithm.

I was working recently on a game that uses the pathfinding automatism to move user-player/IA-enemy units accross a random map and once correctly configured, the automatism works well… except for it’s velocity; when you have a bunch of units making use of it (8-12), the game horribly lags.

There’s a logistic problem with dynamic movement trough A*, and the problem is you need to constantly “re-calibrate” the rute for each unit that have moving targets. I restricted that process to only happen every 2 seconds for each unit and only if the target has moved since. But it’s not enough. So, I’m not enturely sure if the pathfinfing automatism worths the effort, at least by now. Because that automatism was the core mechanic behind my idea and now I’m facing the perspective of move my game to another platform or make my own implementation of the A* algorithm in the game or abandon it.

But for the user who is asking: don’t believe me. Try it. Maybe it works for you and make your life simplier. Maybe a pac-man engine is a lot less heavier than mine.

Doing a good file dialog is really difficult: did you even saw the MacOS file dialog? It has tons of way to display files, shortcuts everywhere, dozens of context menus and menu items. If you want to see one day GD on MacOS, better keep the system provided file dialog.


Usman

A* search is total overkill here. You can make decent Pacman ghosts like this:

If not moving: Check if we can move in each of the four directions. Select one a random and move in that direction.

If moving: Check which directions are legal.

-If only forward and backwards are legal, continue moving forward.
-If only backwards is legal, turn around and move that way (dead end),
-If more than two directions are legal (junction), pick a direction at random that is not the direction we just came from.