# What AI algorithm could I use to trap an agent in a game?

Imagine a game with grid size 10x10, there is a good guy and a bad guy and obstacles in the grid, i.e. essentially a maze. The goal of the bad guy is to find the good guy and trap him by erecting walls around him. The good guy is able to move in the maze using a simple random movement, only in 4 directions - up, down, right or left.

I've used the A* algorithm to find the shortest path to the good guy but am still unsure as to how to go about trapping the good guy in his own space?

• The good guy is able to move in the maze using a simple random movement, only in 4 directions - up, down, right or left. Commented Nov 7, 2021 at 21:08
• What do you mean by "erecting walls around him"? It seems that you imply that the bad guy has more actions than up, down, right and left. It has also the actions of building walls. But how? You need to explain more in detail how this works.
– nbro
Commented Nov 8, 2021 at 15:37
• Agree you need to define how the "bad guy" builds walls (can he build in adjacent cells, or anywhere?), and what it means to trap the "good guy" (seal him in a 1x1 cell, seal him in a 2x1 with the bad guy, cut him off from the bad guy?). Commented Nov 8, 2021 at 15:42