You are making a puzzle game where the world is divided into cells. There are coins scattered through the board that the player needs to collect. There are also trap cells on which the character is not allowed to stand on. The board is of configurable square size X*Y. The game is turn based and in one turn the character you control can only move in a particular pattern: 2 units in one direction on one axis and then 1 on another axis in another direction, or 1 unit first and then 2 units. The character is not allowed to step out of the board, but they are allowed to take as many turns as they need. Given a board configuration and the character's initial starting location, write a function that returns if the player is able to collect all the coins through some set of valid moves.
I understand it is a recursive algorithm but I am wondering about the exit condition. When do we stop traversing the matrix in a case where the character is unable to collect all the coins?