Overview This is one large miniproject. You will implement an interactive version of the Rubik's cube puzzle which is described below. The working program will allow you to solve a scrambled Rubik's...

1 answer below »
How do I create an interactive Rubik's cube simulator?


Overview This is one large miniproject. You will implement an interactive version of the Rubik's cube puzzle which is described below. The working program will allow you to solve a scrambled Rubik's cube using the computer. The program will also contain a number of pre-defined cube "algorithms" to make solving cubes easier and will also allow you to define your own algorithms on the fly. Even if you've never been able to solve Rubik's cube before, you might be able to do so with the help of your program. The program will have these limitations: 1. It will not automatically solve the cube for you. Human input is required. 2. It will not feature fancy 3-d graphics. The cube is represented in a 2-d manner which is not particularly easy to understand, but you will get used to it quickly. 3. The program can only be used to solve 3x3x3 cubes (the original Rubik's cube) and 2x2x2 cubes (so-called "Pocket cubes"). Larger cubes (e.g. 4x4x4) and different cube variants (e.g. the Skewb, the Square-1, the Axis cube, the Megaminx, and literally hundreds of others) cannot be solved using this program. None of the functions or methods you need to write require more than about 30 lines of code (not counting comments, blank lines and docstrings), and most are much shorter than that. What's important is not how many lines of code you write, but that you understand the problems you are solving. The entire amount of code is less than 250 lines. Miniproject: The Rubik's cube puzzle In this section you'll write methods which (along with the supplied code) will allow you to interactively play the Rubik's cube puzzle using the computer. As mentioned previously, we will be providing you with template files which will contain some of the code for the program. You will need to fill in the rest of the code at the lines which now read: pass # TODO (removing these lines, naturally). Your code should be written in a professional manner, with good coding style etc. The template code provides docstrings for all mehtods described. You are allowed to add more methods if you find that useful. https://en.wikipedia.org/wiki/Rubik%27s_Cube Testing your code We are supplying you with these test scripts: • rubiks_rep_tests.py • rubiks_cube_tests.py • rubiks_control_tests.py These test scripts test the code that you will write in rubiks_rep.py, rubiks_cube.py and rubiks_control.py respectively.. Make sure all the test scripts and the Python files being tested are in the same directory, then run each test as follows (in order of Part A to Part C): $ python3 rubiks_rep_tests.py $ python3 rubiks_cube_tests.py $ python3 rubiks_control_tests.py Each file has a list of test functions to run at the end (in the if __name__ == '__main__': block). Feel free to comment out lines from these lists if you only want to run some of the tests. You may also find the python3 - i program_name.py interactive run mode useful, which was covered in lectures and Lab 6. If your code passes all the tests, there is a very good chance that it works correctly. However, to be sure you should actually try to solve some Rubik's cube scrambles using your program (and also, it's fun!). To do this, type the following command: $ python3 rubiks_control.py The next two sections will describe the Rubik's cube puzzle and show you what solving a Rubik's cube using the program looks like. Note that the program will run entirely in the terminal. The program will print out the state of the puzzle and ask you to enter a move by typing into the terminal. The legal moves when entering moves interactively are described below. Description of the puzzle Some of you may be familiar with the Rubik's cube puzzle. In case you aren't, please read the Wikipedia page and if possible look at a couple of YouTube videos showing how to solve the cube. This page is a good starting point; we recommend you watch the video too (the beginner's https://en.wikipedia.org/wiki/Rubik%27s_Cube https://ruwix.com/the-rubiks-cube/how-to-solve-the-rubiks-cube-beginners-method/ solving method described in the video is not exactly the same as the one we use below, but it is very similar). You will note that this spec has a lot of details/examples, which should also be sufficient to work through without having experience solving Rubik's cube puzzles. We will start by describing the classic Rubik's cube puzzle, the 3x3x3 cube. This puzzle was invented by the Hungarian architect Erno Rubik in the 1970s and became extremely popular in the 1980s (it remains popular to this day). The puzzle appears from the outside to be a cube subdivided into a number of smaller cubes. Each face of the entire cube is divided into a 3x3 grid of 9 smaller cubes. Any face of the cube can be rotated independently of the rest of the cube; when this is done, the 9 smaller cubes that make up the face all move simultaneously. When the puzzle is solved, each of the faces of the cube will have a single color (the colors of the faces are normally red, green, blue, yellow, orange, and white). As faces are rotated, the colors mix up. The puzzle is started by making a large number of random cube face rotations to "scramble" the cube. A scrambled cube will have a quasi-random collection of colors on each face. The goal of the puzzle is to rotate faces in such a way as to return it to the solved configuration. Since there are roughly 43 quintillion (4.3x1019) possible configurations of the cube, this is not trivial. The smaller cubes making up a face of the cube are referred to as "cubies". There are three categories of cubies: 1. Center cubies. These are at the center of each face. They can rotate but cannot move relative to other center cubies. They are very useful in that they show you what the eventual color of the entire face will ultimately be when the cube is solved. Note: 2x2x2 cubes do not have center cubies, so you have to determine the correct face color by other means. In a 3x3x3 cube, there are six center cubies (one per face). 2. Edge cubies. These cubies are horizontally or vertically adjacent to the center cubies, and are located between two center cubies. There are 12 edge cubies in a 3x3x3 cube. In a 2x2x2 cube, there are no edge cubies. 3. Corner cubies. These cubies are diagonally adjacent to the center cubies and horizontally and vertically adjacent to edge cubies. There are 8 edge cubies in both the 3x3x3 and 2x2x2 cubes. In 2x2x2 cubes, all the cubies are corner cubies. Note that any rotation of a face of the cube will alter not just that face but also all adjacent faces because non-center cubies are shared between faces. Edge cubies are part of two faces and corner cubies are part of three faces. Because of the large number of configurations of the cube, trying to solve it by making random moves (or even intelligent moves) is futile. A systematic strategy is required. There are many such strategies. The one we will use here is usually called the "beginner's method" because it is simple and doesn't require much memorization. Many more complex strategies exist, with curious names such as CFOP, Roux, ZZ and others. There is an entire subculture of "speedcubing" where people compete to see who can solve cubes fastest; the world's fastest solvers can solve most cubes in well under 10 seconds! To do this, you need specially designed "speedcubes" that are correctly lubricated to turn well and have magnets to enable precise rapid turns; you also need to memorize "finger tricks" to move the cube with maximum efficiency. It's a fun hobby and can get quite addictive. There are also larger cubes, going up to 17x17x17 at least, for those looking for a bigger challenge, and also many cube variants. Central to solving the Rubik's cube is to use so-called "algorithms" which rearrange a small number of cubes while leaving other cubes unchanged. As you know, "algorithm" is a computer science term, but here it just means a particular sequence of moves which achieves a desired result, often analogous to a recipe. At the beginning of a solve, very simple algorithms are all that are needed, and these are so obvious that cubers describe these steps as "intuitive" (which means "you don't have to memorize them"); later algorithms become more and more complicated, and you need to memorize the algorithms you use. In our case, the program will allow you to define algorithms and recall them as you need them, so you won't have to memorize anything except the names of the algorithms! It will also come with many useful algorithms predefined. Your program will also be able to help you solve a 2x2x2 cube; these cubes are generally much simpler than 3x3x3 cubes, having only corner cubes. However, some configurations can come up in 2x2x2 cubes that have no counterpart in 3x3x3 cubes, so different algorithms are sometimes required. Before we go on, we want to emphasize that you do not need to know how to solve Rubik's cube to complete this project! You also won't have to learn how to solve Rubik's cube in order to create or run your program. The program simply enables you to put whatever knowledge of Rubik's cube you may have to work in solving a cube. It also will contain a sufficient number of predefined algorithms so that solving a cube with the program will be much easier than without it if you have no cube knowledge. We hope that the program might even teach some of you how to solve the cube :) Cube notation Since your program will allow you to interactively solve Rubik's cube, you will need to know the "language" of cube moves in order to know how to tell your program what moves to make. Fortunately, this language is quite simple. First, you have to know these abbreviations for the faces of the cube. We assume that you are looking at a cube whose bottom face is parallel to the floor. The names of the faces are: • U is the "Up" face i
Answered Same DayDec 11, 2021

Answer To: Overview This is one large miniproject. You will implement an interactive version of the Rubik's...

Sandeep Kumar answered on Dec 12 2021
121 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here