Skip to content
Snippets Groups Projects
solution testing.py 1.71 KiB
Newer Older
Michael Mutote's avatar
Michael Mutote committed
import Search_Algorithms
Michael Mutote's avatar
Michael Mutote committed
import Sucessors
import is_goal


Michael Mutote's avatar
Michael Mutote committed
# 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))
Michael Mutote's avatar
Michael Mutote committed

Michael Mutote's avatar
Michael Mutote committed
# Sudoku
Michael Mutote's avatar
Michael Mutote committed
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),
        (0, 0, 0, 0, 8, 0, 0, 0, 0))

Michael Mutote's avatar
Michael Mutote committed
sln = (breadth_first_search.BreadthFirstSearch(grid, Sucessors.sudoku_successor, is_goal.is_goal_sudoku)[-1])
Michael Mutote's avatar
Michael Mutote committed

Michael Mutote's avatar
Michael Mutote committed
for rows in sln:
    print(rows)
Michael Mutote's avatar
Michael Mutote committed

# N Queens
board = ((False, False, False, False, False, False, False, False, False),
         (False, False, False, False, False, False, False, False, False),
         (False, False, False, False, False, False, False, False, False),
         (False, False, False, False, False, False, False, False, False),
         (False, False, False, False, False, False, False, False, False),
         (False, False, False, False, False, False, False, False, False),
         (False, False, False, False, False, False, False, False, False),
         (False, False, False, False, False, False, False, False, False),
         (False, False, False, False, False, False, False, False, False))


Michael Mutote's avatar
Michael Mutote committed
sln = (breadth_first_search.BreadthFirstSearch(board, Sucessors.queens_successor, is_goal.is_goal_queens)[-1])

Michael Mutote's avatar
Michael Mutote committed
output_tuple = tuple(tuple("Q" if value else "." for value in sln) for sln in sln)
Michael Mutote's avatar
Michael Mutote committed
for rows in output_tuple:
    print(rows)
Michael Mutote's avatar
Michael Mutote committed


puzzle = ()


print(breadth_first_search.BreadthFirstSearch(puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])