Skip to content
Snippets Groups Projects
solution testing.py 1.92 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.
Michael Mutote's avatar
Michael Mutote committed
# print(Search_Algorithms.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 = ((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),
Michael Mutote's avatar
Michael Mutote committed
        (0, 0, 0, 0, 8, 0, 0, 0, 0))

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

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

Michael Mutote's avatar
Michael Mutote committed
#
# puzzle = ()
#
#
# print(Search_Algorithms.BreadthFirstSearch(puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])