FirstProgrammingAssignment
FirstProgrammingAssignment
Artificial Intelligence
Instructions:
For this assignment we will use that convention that a single move on a Rubik's Cube can be defined as
a quarter turn (90') of any face either clockwise or anticlockwise. Therefore there are twelve possible
moves in each state of the cube.
In this part you are required to find and implement an efficient representation of the cube state and
implement the basic functions of applying a move in a given state to generate the next state. It might be
a good idea to package the state and the functions in a class.
Department of Computer Science FAST-NUCES Lahore Campus
Artificial Intelligence
Implement a function to scramble the state using a sequence of moves that are specified in a text file.
The text file will contain an initial state of the cube on a single line followed by the moves to be applied
on this state with each successive line containing a single move consisting of a faceID and moveID pair.
The faceID will have six distinct values {F: Front, T: Top, B: Bottom, L: Left, R: Right, A: bAck} and
moveID can have two values {C: Clockwise, A: Anti-clockwise}. Implement a function that generates a
new state NS from the initial state IS by successively applying the moves to the initial state. Finally
write the new state and the initial state in a new file on two separate lines.
Write a function that scrambles a given cube state based on a sequence of moves specified in a text file.
The text file will contain the initial cube state on a single line followed by a series of moves. Each move
consists of a faceID and a moveID pair, where faceID represents one of six faces ({F: Front, T: Top, B:
Bottom, L: Left, R: Right, A: Back}) and moveID indicates the rotation direction ({C: Clockwise, A: Anti-
clockwise}). The function should iteratively apply these moves to transform the initial state into a new
state. Finally, both the resulting final and the initial states should be written to a new file creating the
problem for state-space-search algorithms.
Compare the performance of three search strategies including BFS, DFS/Iterative deepening and A*
search to determine a sequence of moves that will transform the initial state into the final state using
minimum number of moves (i.e. 90' turns of faces)
Your code for this part will use the problem generated in part b (the text file containing the two states)
to search for a solution that will transform the first state into the second.
The comparison of the three search strategies must include i) the number of states expanded and ii) the
size of the queue at every instance in time while solving the problem. For the A* search strategy you
must research a good heuristic function that can guide the search effectively. You must solve multiple
problems of varying complexity to make the comparison.
Department of Computer Science FAST-NUCES Lahore Campus
Artificial Intelligence
Submission.
1. A folder/directory containing your code Use your University ID to name the folder
[10 Points]
2. A detailed report documenting your implementation and results obtained
[40 Points]