-
Notifications
You must be signed in to change notification settings - Fork 0
Home
A cube 3x3x3 consists of 27 nodes. However, the very center of cube, as well as centers of sides are static (don't move) and stay in the right positions. according to the subject of this project
Thus, only 20 nodes must be taken into consideration. Each node is represented as XYZ coordinate. Since size is 3x3x3, allowed values for coordinates are 0-2. Coordinates are counted from bottom left front corner (XYZ=000000) to upper right top corner (XYZ=101010). Each coordinate requires 2 bits, each node requires 3x2=6 bits, entire cube requires 20x6=120bits
The state is a unique number and is used to avoid duplicates (kinda hashsum, but without information loss)
|
| LOWER BELT | MIDDLE BELT | UPPER BELT |
|19 18 17 16 15 14 13 12 |11 10 9 8 |7 6 5 4 3 2 1 0 |
| X Y Z X Y Z X Y Z X Y Z X Y Z X Y Z X Y Z X Y Z| X Y Z X Y Z X Y Z X Y Z| X Y Z X Y Z X Y Z X Y Z X Y Z X Y Z X Y Z X Y Z|
00000000|000000 010000 100000 100001 100010 010010 000010 000001|000100 100100 100110 000110|001000 011000 101000 101001 101010 011010 001010 001001|
Initial state_ and how it changes after a rotation is applied.
00000000|000000 010000 100000 100001 100010 010010 000010 000001|000100 100100 100110 000110|001000 010000 101000 101001 101010 011010 001010 001001| START - correct initial (and final) state
|19 18 17 16 15 14 13 12 |11 10 9 8 |7 6 5 4 3 2 1 0 |
______ ______ ______ ______ ______ ______ ______ ______ - affected nodes
00000000|100000 100100 101000 100001 100010 010010 000010 000001|010000 010000 100110 000110|000000 000100 001000 101001 101010 011010 001010 001001|1 FRONT ROTATION
|17 10 5 16 15 14 13 12 |18 6 9 8 |19 11 7 4 3 2 1 0 | CHECKED
______ ______ ______ ______ ______ ______ ______ ______ - affected nodes
00000000|000000 010000 100010 100110 101010 010010 000010 000001|000100 100001 101001 000110|001000 010000 100000 100100 101000 011010 001010 001001|1 RIGHT ROTATION
|19 18 15 9 3 14 13 12 |11 16 4 8 |7 6 17 10 5 2 1 0 | CHECKED
______ ______ ______ ______ ______ ______ ______ ______ - affected nodes
00000000|000000 010000 100000 100001 100010 010010 000010 000001|000100 100100 100110 000110|101000 101001 101010 011010 001010 001001 001000 010000|1 UPPER ROTATION
|19 18 17 16 15 14 13 12 |11 10 9 8 |5 4 3 2 1 0 7 6 | CHECKED
______ ______ ______ ______ ______ ______ ______ ______ - affected nodes
00000000|000000 010000 100000 100001 000010 000110 001010 000001 000100 100100 010010 011010 001000 010000 101000 101001 100010 100110 101010 001001|1 BACK ROTATION
|19 18 17 16 13 8 1 12 |11 10 14 2 |7 6 5 4 15 9 3 0 | CHECKED
______ ______ ______ ______ ______ ______ ______ ______ - affected nodes
00000000|001000 010000 100000 100001 100010 010010 000000 000100|001001 100100 100110 000001|001010 010000 101000 101001 101010 011010 000010 000110|1 LEFT ROTATION
|7 18 17 16 15 14 19 11 |0 10 9 12 |1 6 5 4 3 2 13 8 | CHECKED
______ ______ ______ ______ ______ ______ ______ ______ - affected nodes
00000000|100000 100001 100010 010010 000010 000001 000000 010000|000100 100100 100110 000110|001000 010000 101000 101001 101010 011010 001010 001001|1 DOWN ROTATION
|17 16 15 14 13 12 19 18 |11 10 9 8 |7 6 5 4 3 2 1 0 | CHECKED
Node numbers:
| upper face | | |
| 01 02 03 | | |
| 00 04 | | |
| 07 06 05 | | |
-----------|------------|------------|------------|
left face | front face | right face | back face |
01 00 07 | 07 06 05 | 05 04 03 | 03 02 01 |
08 11 | 11 10 | 10 09 | 09 08 |
13 12 19 | 19 18 17 | 17 16 15 | 15 14 13 |
-----------|------------|------------|------------|
| down face | | |
| 19 18 17 | | |
| 12 16 | | |
| 13 14 15 | | |
Is a manhattan distance between current state and solution state. For each node of the cube in current state calculate differences in coordinates: Xcurrent - Xsolution + Ycurrent - Ysolution + Zcurrent - Zsolution. Maximal weight is 120, minimal weight is 0 (solution).
Counter, how many steps did it take to get from the initial state to current state It is added to the weight if selected search type is A*