refactor: DFS not DST
The searching algorithm is called Depth-First Search not DST.
This commit is contained in:
parent
8466500092
commit
611935050b
2 changed files with 5 additions and 5 deletions
2
main.py
2
main.py
|
@ -18,7 +18,7 @@ def main():
|
|||
|
||||
solver = Solver(game)
|
||||
|
||||
if solver.solve(solver.solve_with_randomised_dst_r):
|
||||
if solver.solve(solver.solve_with_randomised_dfs_r):
|
||||
print("Maze solved successfully :)")
|
||||
else:
|
||||
print("I'm unable to solve the maze :(")
|
||||
|
|
|
@ -44,7 +44,7 @@ class Solver:
|
|||
|
||||
return solve_method(start_position, end_position)
|
||||
|
||||
def solve_with_dst_r(
|
||||
def solve_with_dfs_r(
|
||||
self,
|
||||
current_position: MazePosition,
|
||||
end_position: MazePosition,
|
||||
|
@ -77,7 +77,7 @@ class Solver:
|
|||
continue
|
||||
|
||||
self._game.draw_path_between(current_position, adjacent_position)
|
||||
solved = self.solve_with_dst_r(adjacent_position, end_position)
|
||||
solved = self.solve_with_dfs_r(adjacent_position, end_position)
|
||||
if solved:
|
||||
return True
|
||||
self._game.draw_path_between(
|
||||
|
@ -85,7 +85,7 @@ class Solver:
|
|||
|
||||
return False
|
||||
|
||||
def solve_with_randomised_dst_r(
|
||||
def solve_with_randomised_dfs_r(
|
||||
self,
|
||||
current_position: MazePosition,
|
||||
end_position: MazePosition,
|
||||
|
@ -130,7 +130,7 @@ class Solver:
|
|||
chosen_direction,
|
||||
)
|
||||
self._game.draw_path_between(current_position, next_position)
|
||||
solved = self.solve_with_randomised_dst_r(
|
||||
solved = self.solve_with_randomised_dfs_r(
|
||||
next_position, end_position)
|
||||
if solved:
|
||||
return True
|
||||
|
|
Loading…
Reference in a new issue