diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-22 12:49:20 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-22 12:49:20 +0200 |
| commit | 259c7326f78d5495f5dc51c619932599a5279f68 (patch) | |
| tree | a78e2b9d9624014dac5405c5e26266bf27321101 /src/cube_array.c | |
| parent | 0032089b5c7dedf057c60fcee17cbdd2b0f8bb87 (diff) | |
| download | nissy-core-259c7326f78d5495f5dc51c619932599a5279f68.tar.gz nissy-core-259c7326f78d5495f5dc51c619932599a5279f68.zip | |
Progess with transformation implementation
Diffstat (limited to 'src/cube_array.c')
| -rw-r--r-- | src/cube_array.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/cube_array.c b/src/cube_array.c index 1d2da86..cbf59e4 100644 --- a/src/cube_array.c +++ b/src/cube_array.c | |||
| @@ -120,6 +120,57 @@ static char *movestr[] = { | |||
| 120 | [B3] = "B'", | 120 | [B3] = "B'", |
| 121 | }; | 121 | }; |
| 122 | 122 | ||
| 123 | static char *transstr[] = { | ||
| 124 | [UFr] = "rotation UF", | ||
| 125 | [UFm] = "mirrored UF", | ||
| 126 | [ULr] = "rotation UL", | ||
| 127 | [ULm] = "mirrored UL", | ||
| 128 | [UBr] = "rotation UB", | ||
| 129 | [UBm] = "mirrored UB", | ||
| 130 | [URr] = "rotation UR", | ||
| 131 | [URm] = "mirrored UR", | ||
| 132 | [DFr] = "rotation DF", | ||
| 133 | [DFm] = "mirrored DF", | ||
| 134 | [DLr] = "rotation DL", | ||
| 135 | [DLm] = "mirrored DL", | ||
| 136 | [DBr] = "rotation DB", | ||
| 137 | [DBm] = "mirrored DB", | ||
| 138 | [DRr] = "rotation DR", | ||
| 139 | [DRm] = "mirrored DR", | ||
| 140 | [RUr] = "rotation RU", | ||
| 141 | [RUm] = "mirrored RU", | ||
| 142 | [RFr] = "rotation RF", | ||
| 143 | [RFm] = "mirrored RF", | ||
| 144 | [RDr] = "rotation RD", | ||
| 145 | [RDm] = "mirrored RD", | ||
| 146 | [RBr] = "rotation RB", | ||
| 147 | [RBm] = "mirrored RB", | ||
| 148 | [LUr] = "rotation LU", | ||
| 149 | [LUm] = "mirrored LU", | ||
| 150 | [LFr] = "rotation LF", | ||
| 151 | [LFm] = "mirrored LF", | ||
| 152 | [LDr] = "rotation LD", | ||
| 153 | [LDm] = "mirrored LD", | ||
| 154 | [LBr] = "rotation LB", | ||
| 155 | [LBm] = "mirrored LB", | ||
| 156 | [FUr] = "rotation FU", | ||
| 157 | [FUm] = "mirrored FU", | ||
| 158 | [FRr] = "rotation FR", | ||
| 159 | [FRm] = "mirrored FR", | ||
| 160 | [FDr] = "rotation FD", | ||
| 161 | [FDm] = "mirrored FD", | ||
| 162 | [FLr] = "rotation FL", | ||
| 163 | [FLm] = "mirrored FL", | ||
| 164 | [BUr] = "rotation BU", | ||
| 165 | [BUm] = "mirrored BU", | ||
| 166 | [BRr] = "rotation BR", | ||
| 167 | [BRm] = "mirrored BR", | ||
| 168 | [BDr] = "rotation BD", | ||
| 169 | [BDm] = "mirrored BD", | ||
| 170 | [BLr] = "rotation BL", | ||
| 171 | [BLm] = "mirrored BL", | ||
| 172 | }; | ||
| 173 | |||
| 123 | cube_t solvedcube = { | 174 | cube_t solvedcube = { |
| 124 | .c = { | 175 | .c = { |
| 125 | [_c_ufr] = _c_ufr, | 176 | [_c_ufr] = _c_ufr, |
| @@ -452,6 +503,21 @@ readmoves_error: | |||
| 452 | return -1; | 503 | return -1; |
| 453 | } | 504 | } |
| 454 | 505 | ||
| 506 | trans_t | ||
| 507 | readtrans(char *buf) | ||
| 508 | { | ||
| 509 | uint8_t t; | ||
| 510 | |||
| 511 | for (t = 0; t < 48; t++) | ||
| 512 | if (!strncmp(buf, transstr[t], 11)) | ||
| 513 | return t; | ||
| 514 | |||
| 515 | #ifdef DEBUG | ||
| 516 | fprintf(stderr, "readtrans error\n"); | ||
| 517 | #endif | ||
| 518 | return errortrans; | ||
| 519 | } | ||
| 520 | |||
| 455 | void | 521 | void |
| 456 | writemoves(move_t *m, int n, char *buf) | 522 | writemoves(move_t *m, int n, char *buf) |
| 457 | { | 523 | { |
| @@ -469,6 +535,15 @@ writemoves(move_t *m, int n, char *buf) | |||
| 469 | *b = '\0'; | 535 | *b = '\0'; |
| 470 | } | 536 | } |
| 471 | 537 | ||
| 538 | void | ||
| 539 | writetrans(trans_t t, char *buf) | ||
| 540 | { | ||
| 541 | if (t >= 48) | ||
| 542 | memcpy(buf, "error trans", 11); | ||
| 543 | else | ||
| 544 | memcpy(buf, transstr[t], 11); | ||
| 545 | buf[11] = '\0'; | ||
| 546 | } | ||
| 472 | 547 | ||
| 473 | static int | 548 | static int |
| 474 | permsign(uint8_t *a, int n) | 549 | permsign(uint8_t *a, int n) |
