Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

I found a lot of references to the AI of the ghosts in Pacman, but none of them mentioned how the eyes find their way back to the central ghost hole after a ghost is eaten by Pacman.

In my implementation, I implemented a simple but awful solution. I just hardcoded on every corner which direction should be taken.

Is there any better/or the best solution? Maybe a generic one that works with different level designs?

1 Answer

0 votes
by (107k points)
edited by

You can implement the following steps:

  1. Firstly, detect the location of eyes with respect to the gate. Usually, we have only one gate located either on the right below of the game or on the left above.

  2. Move the position of the eye in either of the two directions(make it move right if the position of the gate is left above or move to the left direction if the position of the gate is right below). Also, check the walls that are preventing you from doing so.

  3. If the walls are preventing then move in the opposite direction. For example, if the coordinates of the eyes are right north and it was currently moving left but there is a wall in the way then make it move in the south direction.

  4. Keep an eye on the time track and check where the eyes are in respective of the gate. Also, check there should be no latitudinal coordinates. The latitudinal coordinates are those points that are located exactly above the gate.

  5. If you see the latitudinal coordinates then move down. If there is any wall in between then move left or right. Repeat this move until the eyes are in the monster hole.

If you want to make your career in Artificial Intelligence then go through this video:

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...