Skip to content
Snippets Groups Projects
solution testing.py 2.5 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
import Heuristics
Michael Mutote's avatar
Michael Mutote committed


Michael Mutote's avatar
Michael Mutote committed
# Maze Problem, note, the maze is 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])

Michael Mutote's avatar
Michael Mutote committed
# sln = (Search_Algorithms.DepthFirstSearch(
#     grid, Sucessors.sudoku_successor, is_goal.is_goal_sudoku)[-1])
#
# 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])
Michael Mutote's avatar
Michael Mutote committed
#
# 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)
Michael Mutote's avatar
Michael Mutote committed

tnbeats's avatar
tnbeats committed

# Sliding Puzzle
initial_puzzle = (
    (7, 2, 4),
    (5, 0, 6),
    (8, 3, 1)
)
Michael Mutote's avatar
Michael Mutote committed
#
# 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")

Michael Mutote's avatar
Michael Mutote committed
#
# sln = (Search_Algorithms.DepthFirstSearch(initial_puzzle, Sucessors.puzzle_successor, is_goal.is_goal_puzzle)[-1])
#
# if sln:
#     for rows in sln:
#         print(rows)
# else:
#     print("No solution found")

print(Search_Algorithms.A_StarSearch((4, 0), Sucessors.maze_successor, is_goal.is_goal_maze, Heuristics.maze_opt))





tnbeats's avatar
tnbeats committed