Pacman: how do the eyes find their way back to the monster hole?

后端 未结 22 1819
南方客
南方客 2021-01-29 17:53

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 Pa

22条回答
  •  感情败类
    2021-01-29 18:03

    1. Before the game begins save the nodes (intersections) in the map
    2. When the monster dies take the point (coordinates) and find the nearest node in your node list
    3. Calculate all the paths beginning from that node to the hole
    4. Take the shortest path by length
    5. Add the length of the space between the point and the nearest node
    6. Draw and move on the path

    Enjoy!

提交回复
热议问题