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

update

parent f5140860
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@ def DepthFirstSearch(state, successor, isgoal):
if next_state not in explored:
explored.add(next_state)
path2 = path + [next_state]
print(path2)
toDo.append(path2)
return "Error Path not found"
......@@ -19,11 +19,11 @@ grid = ((1, 0, 0, 0, 0, 0, 0, 0, 0),
# 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)
# sln = (Search_Algorithms.DepthFirstSearch(
# grid, Sucessors.sudoku_successor, is_goal.is_goal_sudoku)[-1])
#
# for rows in sln:
# print(rows)
# N Queens
board = ((False, False, False, False, False, False, False, False, False),
......@@ -38,14 +38,14 @@ board = ((False, False, False, False, False, False, False, False, False),
# 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)
#
# 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)
# Sliding Puzzle
......@@ -55,8 +55,17 @@ initial_puzzle = (
(5, 0, 6),
(8, 3, 1)
)
#
# sln = (Search_Algorithms.BreadthFirstSearch(initial_puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])
#
# if sln:
# for rows in sln:
# print(rows)
# else:
# print("No solution found")
sln = (Search_Algorithms.BreadthFirstSearch(initial_puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])
sln = (Search_Algorithms.DepthFirstSearch(initial_puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])
if sln:
for rows in sln:
......
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