Exit quickly from a maze with a local view of the maze
The fact that the exit is in the bottom right and has coordinates $(49, 49)$, while the player has coordinates $(1,1)$ makes me think that the maze has a fixed size of $49 \times 49$. If that's the case the exit can be found in constant time.
In fact, there is a fixed strategy (i.e., a sequence of moves) that uses a constant number of moves and exits the maze, regardless of the maze layout!
You can construct this strategy as follows: enumerate all possible maze layouts $L_1, L_2, \dots$ (a crude upper bound on the number of mazes is $2^{49^2}$).
You can construct the sequence $S$ of moves iteratively. Initially $S$ is the empty sequence. Then, for each $L_i$ you can extend $S$ as follows:

Assume that the maze layout is $L_i$, and compute the position $p$ in which the player would end up by following the steps in $S$ from position $(1,1)$ in $L_i$.
Find a sequence $S_i$ of at most $49^2$ moves that make the player walk from $p$ to $(49,49)$ in $L_i$. This sequence always exists and can be found, e.g., with a breadth first search from $p$ in the graph induced by $L_i$.
Append $S_i$ to $S$.

The resulting sequence $S$ has length at most $2^{49^2} \cdot 49^2 &lt; 2^{2413} = O(1)$.
Notice that the above algorithm is only needed to construct $S$ once and for all.
An algorithm that solves your original problem can just output the hardcoded strategy $S$, without even looking at its input.