Skip to content
Snippets Groups Projects
Commit bd5691ee authored by Michael Mutote's avatar Michael Mutote
Browse files

22202956

refactored
parent e1a7a4a5
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
......@@ -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])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment