https://paste.pythondiscord.com/OOAA
this code got me stuck in infinite loop, in explore function to be exact, it supposed to find the path to the goal and return it but it append the path despite it being visited?
"""
if goal is None:
goal = (self.width - 1, self.height - 1) # Default goal: Top-right corner
path = ""
visited = set() # Set to track visited positions to avoid infinite loops
while (speedster.get_x(runner), speedster.get_y(runner)) != goal:
position = (speedster.get_x(runner), speedster.get_y(runner))
if position in visited:
> raise RuntimeError("Stuck in an infinite loop! Check maze configuration or movement logic.")
E RuntimeError: Stuck in an infinite loop! Check maze configuration or movement logic.
maze.py:146: RuntimeError
===================================================================== short test summary info =====================================================================
FAILED test_maze.py::test_explore - RuntimeError: Stuck in an infinite loop! Check maze configuration or movement logic.
=================================================================== 1 failed, 7 passed in 0.88s ===================================================================
PS D:\Education\University\High-Level\supposed>