Seeking

From Scalable Game Design wiki
Jump to: navigation, search

The diffusion pattern can be extended to allow an agent to move towards some objective in a complex environment like a maze. For example, the ghosts in Pacman can easily be made to chase the Pacman character more effectively than is seen in common versions of that gamelet.

To implement this behavior, floor of the maze is made up of agents; think of these as floor tiles. The carpet tiles have the hot attribute as called for in the diffusion pattern, set initially to zero. The Pacman character sets the hot attribute of whatever floor tile it is on top of to a large value. As the program runs, each tile resets its hot attribute to the average of any neighboring tiles. Adjacent barriers have no hot attribute, and contribute zero to this average. Now higher values of hot diffuse out through the maze from the current location of the Pacman, and change as the Pacman moves around.

The seeking behavior of a ghost can be guided by these hot values. The ghost should compare the hot values of the tiles it could move onto, and choose the tile that is hottest. This hill climbing behavior, moving up the gradient of hotness, moves the ghost closer to the Pacman, no matter how complex the maze is between the ghost and the Pacman. For example, the ghost will actually move away from the Pacman, if this is needed to go around obstacles between it and the Pacman. Ghosts in common Pacman implementations aren’t this clever.

This approach to programming seeking behavior is an example of the antiobjects idea see http://en.wikipedia.org/wiki/Antiobjects). Rather than being located in the active seeker agent, seeking behavior is largely implemented in the programming for the seemingly passive floor tiles: it’s the diffusion carried on by the floor tiles that guides what the seeker does.

Games/Simulations that use this pattern