Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Artificial Intelligence Sliding Brick Puzzle Part II: Searching for Solutions ( 1 2 points ) In the previous part, we implemented key components of a
Artificial Intelligence
Sliding Brick Puzzle Part II: Searching for Solutions points
In the previous part, we implemented key components of a solver for the puzzle game Sliding Brick Puzzle. In this part, we continue with this implementation and significantly extend it to find puzzle solutions using various methods.
Please start with your code from part and extend it as directed below. As before, the code for this part should be written in Python to run on tux.csdrexel.edu, and we will use the same run.sh shell script for testing. Again, you may only use builtin standard libraries eg math, random, etc.; you may NOT use any external libraries or packages if you have any questions at all about what is allowable, please email the instructor
Important notes: Notice that the search space is a graph, so you will have to keep track of all the states visited so far, and make sure your algorithm does not get stuck in loops.
For all the search functions that you will implement in this assignment, the output should print the following:
the list of moves required to solve the state,
the final state of the puzzle,
the number of nodes that were explored,
the time that the function took to find the solution in seconds with two decimal
digits,
and the length of the solution found.
BreadthFirst Search BFSpts
Write a method that does a breadthfirst search from the given state from a file, returning the sequence of moves found that reaches the solution state. Add a bfs commandline command that allows a user to perform the BFS on a given file representing the state like before.
Here is an example pay attention to spaces and newlines: sh run.sh bfs SBPleveltxt
left
down
right
up
up
DepthFrist Search DFSpts
Similar to BFS write a method that does a depthlimited search from a given cube, returning the first sequence of moves found that reaches the solution state. Like the previous part, add a dfs commandline command that allows a user to perform the DFS on a given file representing the state:
sh run.sh dfs SBPleveltxt
left
left
right
down
left
left
up
right
right
down
left
up
Iterative Deepening Search IDSpts
Write a method that does an iterative deepening search from a given state, returning the first sequence of moves found that reaches the solution state. Add an "ids" commandline command that allows a user to perform this search:
sh run.sh ids SBPleveltxt
left
left
down
right
right
up
up
A Search pts
Lastly, write a method that does an A search from a given state, returning the first sequence of moves found that reaches the solution state. Add an "astar" commandline command that allows a user to perform this task. Note that as part of this process, you will need to choose and implement an admissible heuristic function h such that A can reasonably estimate the minimum cost from a given state to the goal state. As a heuristic, use the Manhattan distance between the master brick and the goal. Also, note that the A and BFS should have a similar length which is the length of an optimal solution for a state.
Here is an example:
sh run.sh bfs SBPleveltxt
left
down
right
up
up
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started