You are given an existing grid-based maze solver with bugs and several requested feature extensions. The maze uses the following symbols:
-
S
: start
-
E
: exit
-
#
: wall
-
.
: open cell
-
*
: rendered path overlay
-
>
and
<
: direction-forcing cells
-
lowercase letters
a
to
z
: keys
-
uppercase letters
A
to
Z
: locked doors that require the matching lowercase key
-
B
: bomb cell
Complete the following tasks in the same codebase:
-
Fix path rendering so that
S
and
E
are never overwritten by
*
when printing the final route.
-
Fix the traversal algorithm so it does not loop forever because of incorrect visited-state handling in BFS or DFS.
-
Update movement rules so that when the current cell is
>
the next move must go right, and when it is
<
the next move must go left.
-
Extend the solver to support keys and doors. Reaching the same coordinate with different sets of collected keys must be treated as different search states.
-
Add bomb behavior: when the agent steps on
B
, all walls within Manhattan distance 2 are destroyed and become passable for the remainder of that search path.
Implement the required fixes and explain the algorithm used at each stage, including how the search state must evolve as new mechanics are added.