From bd5691eee39a1ea18362a53b204585617280ef93 Mon Sep 17 00:00:00 2001
From: Michael Mutote <130656746+mr1Michael@users.noreply.github.com>
Date: Thu, 26 Oct 2023 21:58:04 +0200
Subject: [PATCH] 22202956 refactored

---
 Search_Algorithms/Search_Algorithms.py |  2 +-
 Search_Algorithms/solution testing.py  | 36 ++++++++++++++------------
 2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/Search_Algorithms/Search_Algorithms.py b/Search_Algorithms/Search_Algorithms.py
index dbeae12..57c8331 100644
--- a/Search_Algorithms/Search_Algorithms.py
+++ b/Search_Algorithms/Search_Algorithms.py
@@ -25,7 +25,7 @@ def DepthFirstSearch(state, successor, isgoal):
     toDo = deque()
     toDo.append([state])
     explored = {state}
-    while not toDo:
+    while toDo:
         path = toDo.pop()
         current = path[-1]
         if isgoal(current):
diff --git a/Search_Algorithms/solution testing.py b/Search_Algorithms/solution testing.py
index 669fa3d..63c1b2a 100644
--- a/Search_Algorithms/solution testing.py	
+++ b/Search_Algorithms/solution testing.py	
@@ -4,20 +4,22 @@ import is_goal
 
 
 # Maze Problem, note, the maze if fixed in the allowed state.
-print(breadth_first_search.BreadthFirstSearch((4, 0), Sucessors.maze_successor, is_goal.is_goal_maze))
+# print(Search_Algorithms.BreadthFirstSearch((4, 0), Sucessors.maze_successor, is_goal.is_goal_maze))
 
 # Sudoku
-grid = ((5, 3, 0, 0, 7, 0, 0, 0, 0),
-        (6, 0, 0, 1, 9, 5, 0, 0, 0),
-        (0, 9, 8, 0, 0, 0, 0, 6, 0),
-        (8, 0, 0, 0, 6, 0, 0, 0, 3),
-        (4, 0, 0, 8, 0, 3, 0, 0, 1),
-        (7, 0, 0, 0, 2, 0, 0, 0, 6),
-        (0, 6, 0, 0, 0, 0, 2, 8, 0),
-        (0, 0, 0, 4, 1, 9, 0, 0, 5),
+grid = ((1, 0, 0, 0, 0, 0, 0, 0, 0),
+        (0, 0, 0, 0, 0, 0, 0, 0, 0),
+        (0, 0, 0, 0, 0, 0, 0, 0, 0),
+        (0, 0, 0, 0, 0, 0, 0, 0, 0),
+        (0, 0, 0, 0, 0, 0, 0, 0, 0),
+        (0, 0, 0, 0, 0, 0, 0, 0, 0),
+        (0, 0, 0, 0, 0, 0, 0, 0, 0),
+        (0, 0, 0, 0, 0, 0, 0, 0, 0),
         (0, 0, 0, 0, 8, 0, 0, 0, 0))
 
-sln = (breadth_first_search.BreadthFirstSearch(grid, Sucessors.sudoku_successor, is_goal.is_goal_sudoku)[-1])
+# sln = (Search_Algorithms.BreadthFirstSearch(grid, Sucessors.sudoku_successor, is_goal.is_goal_sudoku)[-1])
+
+sln = (Search_Algorithms.DepthFirstSearch(grid, Sucessors.sudoku_successor, is_goal.is_goal_sudoku)[-1])
 
 for rows in sln:
     print(rows)
@@ -34,14 +36,16 @@ board = ((False, False, False, False, False, False, False, False, False),
          (False, False, False, False, False, False, False, False, False))
 
 
-sln = (breadth_first_search.BreadthFirstSearch(board, Sucessors.queens_successor, is_goal.is_goal_queens)[-1])
+# sln = (Search_Algorithms.BreadthFirstSearch(board, Sucessors.queens_successor, is_goal.is_goal_queens)[-1])
+
+sln = (Search_Algorithms.DepthFirstSearch(board, Sucessors.queens_successor, is_goal.is_goal_queens)[-1])
 
 output_tuple = tuple(tuple("Q" if value else "." for value in sln) for sln in sln)
 for rows in output_tuple:
     print(rows)
 
-
-puzzle = ()
-
-
-print(breadth_first_search.BreadthFirstSearch(puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])
+#
+# puzzle = ()
+#
+#
+# print(Search_Algorithms.BreadthFirstSearch(puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])
-- 
GitLab