diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-31 19:17:42 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-31 19:17:42 +0100 |
| commit | d65ce8e86b517ef3f7d48cf5ded1101444e05b2b (patch) | |
| tree | 6ac473a067fa06dbd64691adf2ddaafd8adc6e06 /README.md | |
| parent | bc2e6b8a8d5a6eccd2c2ac433e8a307ee356f14e (diff) | |
| download | nissy-core-d65ce8e86b517ef3f7d48cf5ded1101444e05b2b.tar.gz nissy-core-d65ce8e86b517ef3f7d48cf5ded1101444e05b2b.zip | |
Reorganized documentation
Diffstat (limited to '')
| -rw-r--r-- | README.md | 107 |
1 files changed, 103 insertions, 4 deletions
| @@ -1,6 +1,8 @@ | |||
| 1 | # Prototype for a new optimal solver | 1 | # Prototype for a new optimal solver |
| 2 | 2 | ||
| 3 | Work in progress. | 3 | Work in progress. There is some documentation at the bottom of this page, |
| 4 | but do not believe it. Everything is in a state of flux and can change | ||
| 5 | without notice. | ||
| 4 | 6 | ||
| 5 | ## Running tests | 7 | ## Running tests |
| 6 | 8 | ||
| @@ -38,9 +40,8 @@ $ make test | |||
| 38 | 40 | ||
| 39 | ### Documentation and interface | 41 | ### Documentation and interface |
| 40 | 42 | ||
| 41 | * remove the constant #define's from cube.h (write a comment instead) | 43 | * inline some documentation as comments in cube.h or cube.c |
| 42 | * reconsider content of cube.h, remove some stuff | 44 | * README.md (maybe convert to txt?) becomes the reference documentation |
| 43 | * remove doc folder, inline documentation as comments in cube.h or cube.c | ||
| 44 | 45 | ||
| 45 | ### AVX2 | 46 | ### AVX2 |
| 46 | 47 | ||
| @@ -64,3 +65,101 @@ $ make test | |||
| 64 | [_mm256_shuffle_epi8](https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-10/mm256-shuffle-epi8.html)) | 65 | [_mm256_shuffle_epi8](https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-10/mm256-shuffle-epi8.html)) |
| 65 | * Inspect compiled assembly | 66 | * Inspect compiled assembly |
| 66 | * Use valgrind tool cachegrind and other profiling tools | 67 | * Use valgrind tool cachegrind and other profiling tools |
| 68 | |||
| 69 | |||
| 70 | ## Internal representation of the cube | ||
| 71 | |||
| 72 | The plan (TODO) is to have multiple implementations: some that | ||
| 73 | take advantage of advanced CPU instructions (SIMD) and a fallback | ||
| 74 | "array" representation that works on any architecture. | ||
| 75 | |||
| 76 | ### Array representation (fallback) | ||
| 77 | |||
| 78 | In this implementation of the cube.h interface, the cube is represented | ||
| 79 | by two arrays of 8-bit unsigned integers, one for centers and one for | ||
| 80 | corners. The 4 leas-significant digits of each bit determine the piece, | ||
| 81 | the other 4 are used for orientation or kept to 0. | ||
| 82 | |||
| 83 | Edges: | ||
| 84 | xxxopppp (x = unused, o = orientation, p = piece) | ||
| 85 | |||
| 86 | Corners: | ||
| 87 | xooxpppp (x = unused, o = orientation, p = piece) | ||
| 88 | |||
| 89 | The two bits for CO are shifted to make it possible to perform mod 3 | ||
| 90 | operations (sum, inverse) using only addition and bitwise operators. | ||
| 91 | See below for details. | ||
| 92 | |||
| 93 | The third bit is needed because x+y+1 can exceed 4. | ||
| 94 | |||
| 95 | ### AVX2 | ||
| 96 | |||
| 97 | Work in progress | ||
| 98 | |||
| 99 | |||
| 100 | ## Textual representation of the cube | ||
| 101 | |||
| 102 | The functions readcube() and writecube() use different formats to read | ||
| 103 | and write a cube to text. Not all formats are supported for both input | ||
| 104 | and output. | ||
| 105 | |||
| 106 | ### H48 - standard format for h48 (read, write) | ||
| 107 | |||
| 108 | Each edge is represented by two letters denoting the sides it belongs to | ||
| 109 | and one number denoting its orientation (0 oriented, 1 mis-oriented). | ||
| 110 | Similarly, each corner is represented by three letters and a number | ||
| 111 | (0 oriented, 1 twisted clockwise, 2 twisted counter-clockwise). | ||
| 112 | Edge orientation is relative to the F / B axis, corner orientation is | ||
| 113 | relative to the U / D axis. | ||
| 114 | |||
| 115 | The pieces are ordered such that the solved cube looks like this: | ||
| 116 | |||
| 117 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 | ||
| 118 | UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 119 | |||
| 120 | Whitespace (including newlines) between pieces is ignored when reading | ||
| 121 | the cube, and a single whitespace character is added between pieces | ||
| 122 | when writing. | ||
| 123 | |||
| 124 | The cube after the moves R'U'F looks like this: | ||
| 125 | |||
| 126 | FL1 BR0 DB0 UR1 UF0 UB0 DL0 FR0 UL1 DF1 BL0 DR0 | ||
| 127 | UBL1 DBR1 UFR2 DFR2 DFL2 UBL2 UFL2 DBL0 | ||
| 128 | |||
| 129 | ### SRC - representation of the object in C code for cube_array (write) | ||
| 130 | |||
| 131 | The exact format depends on the internal cube representation (TODO: actually | ||
| 132 | this is false, because I need all formats for code generation; also adapating | ||
| 133 | tests is hard). It is guaranteed that, if OUT is the output in this format, | ||
| 134 | the line | ||
| 135 | |||
| 136 | cube_t cube = OUT; | ||
| 137 | |||
| 138 | is interpreted correctly by h48. | ||
| 139 | |||
| 140 | |||
| 141 | ## Transformations | ||
| 142 | |||
| 143 | Transformations can be either simple rotations or a rotation composed | ||
| 144 | with a mirroring. | ||
| 145 | |||
| 146 | Simple rotations are denoted by two letters corresponding to the faces | ||
| 147 | to be moved to the U and F positions, respectively. For example FD is | ||
| 148 | the rotation that brings the F face on top and the D face on front. | ||
| 149 | |||
| 150 | A composed rotation + mirror is obtained by applying the corresponding | ||
| 151 | rotation to the solved cube mirrored along the M plane. | ||
| 152 | |||
| 153 | For example, to apply the transformation RBm (mirrored RB) to a cube C: | ||
| 154 | 1a. Apply a mirror along the M plane to the solved cube | ||
| 155 | 1b. Rotate the mirrored cube with z' y2 | ||
| 156 | 3. Apply the cube C to the transformed solved cube | ||
| 157 | 4. Apply the transformations of step 1a and 1b in reverse | ||
| 158 | |||
| 159 | The orientation of pieces after a rotation ignores the new position | ||
| 160 | of centers. A rotated cube can technically be inconsistent, because | ||
| 161 | the parity of the edge permutation has to be adjusted considering the | ||
| 162 | parity of the centers, which we ignore. | ||
| 163 | |||
| 164 | The utility script mirror.sh transforms a solved, rotated cube to its | ||
| 165 | mirrored and rotated version. | ||
