Pacman game using A* algorithm ? (756504)

Hello, I’m new here.
huft I so flustrated right now because my homework.. I want to make game like pacman using A* algorithm, the ghost can chase player with the short path, can I have some suggestion..pleaseeeee :(??

What exactly is the issue? I mean the process is something like:

  • Create a Tile, can have a enum like Empty, pellet, wall
  • Create a TileMap basiclaly a 2D array of tiles (although you should use 1D array and access as though its 2D)
  • Add an A* Path finding class that takes a TileMap and runs the algorithm creating path nodes out of tiles as it goes.
  • Add a small State Machine just a basic switch one you can make a fancy graph later down the line.

Im pretty sure unity has alot built in like a TileMap class to simplify things.

http://gameinternals.com/understanding-pac-man-ghost-behavior

You don’t really need to use A* for this, the original didn’t. In the original, the ghosts only plan exactly one tile in the future, and may not reverse their direction unless under special circumstances (being chased by player for example).

As the maze doesn’t have dead ends and shortest path isn’t the most fun path, you can simply use a basic AI.

Chase:
If target tile is right and I can go right, I should go right whenever the next tile allows me to. Similar rules for forward and left. I should avoid reversing my direction.

Wander:
Each tile I reach, I will make a random decision so long as it’s never going back the way I came.

General rambling:

So for Pacman, A* is grotesque and probably will not lead to a better game. It should also give you a much better feel about how simple real game AI is, and how valuable that is. For instance you probably don’t want Unity navmesh to be sampled all the time in a 3rd person game: you only want to use it to solve a problem you couldn’t with regular movement such as generally going toward the player but have lost sight of the player, so you would want to move to where the player was last seen. Or perhaps the AI has got to a dead end, things like that are better use-cases of when to use a big solution like A*, and even then one should be conservative about it for natural gameplay.

What I’m illustrating is that it’s a great idea to KISS as long as possible then only add complexity if forced to.