I am designing a game solver. I have a binary $m*n$ Matrix, where $0$ stands for a free space, while $1$ stands for an occupied space. In the game we move a ball that we will call $x$. The ball can only move UP, DOWN, RIGHT or LEFT (no diagonal).Imagine the following matrix:$1 0 0\\0 1 0\\x 0 1$We see that the ball is in the lower left corner -- which is trapped.What efficient algorithm can I use to decide if the ball is trapped, that is if there is no way to get to the other side (like the example given above)?Another example where the ball is not trapped:$1 0 0\\1 0 0\\x 0 1$I am using bits matrices, I would rather not use graphs if possible.
Efficient algorithm to decide if a location is reachable
algorithms;complexity theory;search problem