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?
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 - . , , , .
( , ) , "" - , , "" , .
, " ", , - ? • ? • ? - // ?
, . , , " ", , " "...
Pacman , ( ) Pacman, AI .
, , -, . . , , Pacman. , , . , , , 1, 2, 3 4 . . , . , , . , , , . , , . , , , . -, - . , , . , , . , , !
, "", , , 4 , , . , .
2 1 2 2, ( ). , , , .
BFS Dijkstra 3 4, Pacman . BFS Dijkstra. , , , , 3 4. , , BFS Dijkstra, , .
Source: https://habr.com/ru/post/1751375/More articles:Getting Access database table names with Matlab - ms-accessDFS в Perl (или Java или С++...) - depth-first-searchHow to add error in Spring MVC simpleformcontroller? - springWPF высокопроизводительный чертеж - должен ли я группироваться по цвету кисти? - performancehow to detect idle user in iphone-sdk - iphoneКлавиатура WPF HwndHost - winapiDatabase crash in SQL Server using template - sql-server-2008How to suppress a warning in protected IE mode - uacWindows Services and Multiple Registered Users - .netHow to get related item from ASP.NET repeater - c #All Articles