# How could an AI detect whether an enemy in a game can be blocked off/trapped?

Imagine a game played on a 10x10 grid system where a player can move up down left or right and imagine there are two players on this grid: An enemy and you. In this game, there are walls on the grid which you can't go through. The objective of this game is to block the enemy in so he can't move around the rest of the board and is effectively "trapped".

I want to write an algorithm that detects which nodes on the board I as a player need to put blocks in, in order to trap the enemy. There are also some other considerations to think about. You have to be able to place the blocks before the enemy place can get out of the box. Also note more thing: You can move AND place a block in the position that you're moving to at the same time.

Here's a picture as an example of the game.

EDIT: note that the board in the picture is 5x5, but that's okay for the purposes of the example

In this example, I could go up, then right and place a block, then right and place a block, then up and place a block. If there's more than one way of blocking off the enemy, then I should use the way that's going to give my enemy the least amount of space.

Researching on google couldn't find me anything relevant, although it may have been because I wasn't using relevant search terms. I also thought about using a monte Carlo search tree algorithm for simultaneous games, but I would need to research into that more.

• Any progress on this problem statement as I'm looking for an algorithm to do the same? I've already implemented A* algorithm to find the shortest path to the enemy but not sure how to go about trapping the enemy in its own space. Nov 6, 2021 at 15:40
• @SakthiSomaskandan Nope, I ended up giving up on it. It seemed like any solution I would end up with was either a heuristic or its runtime was unacceptable for my time constraints. Good luck with your own work. Please let me know if you find something promising in your research. I'm still curious about this. Nov 16, 2021 at 17:24