Path finding algorithm for 2 Pakmans

I am trying to implement Pacman. It works fine, but still ghosts do not use any path, but instead they just randomly determine on each connection path which path to take. Thus, you can imagine that Pacman is not difficult to win the game;)

So, I read a little about path finding algorithms in Pacman, and here, on SO, I found a really good answer: Pathfinding algorithm for Pacman

Answers relate to http://home.comcast.net/~jpittman2/pacman/pacmandossier.html#Chapter%204

Everything is fine, but in my Pacman implementation there are two Pacmans who play two different players. Therefore, I am wondering how to adapt path-finding algorithms so that ghosts do not always chase one player.

Any thoughts on how to change the algorithm so that the ghosts are more or less equally true for both players?

+3
source share
5 answers

I think the simplest strategy is to get every ghost to chase the player closest to him. Proximity can be calculated using the Manhattan distance (there was a link to it in the matter of finding the path) or Euclidean distance or the length of the path to the players. The latter option means that you have to calculate the paths for both players. Try all of these options and choose one to your liking.

, . , pathfinding, , BFS:), . , A * BFS n , n . Dijkstra , . . , Dijkstra - . , , , .

+5

( , ) , "" - , , "" , .

, " ", , - ? • ? • ? - // ?

, . , , " ", , " "...

+3

Pacman , ( ) Pacman, AI .

+2

, , -, . . , , Pacman. , , . , , , 1, 2, 3 4 . . , . , , . , , , . , , . , , , . -, - . , , . , , . , , !

+1

, "", , , 4 , , . , .

2 1 2 2, ( ). , , , .

BFS Dijkstra 3 4, Pacman . BFS Dijkstra. , , , , 3 4. , , BFS Dijkstra, , .

+1

Source: https://habr.com/ru/post/1751375/


All Articles