diff options
Diffstat (limited to '')
| -rw-r--r-- | old/2021-11-10-beforeremovingchecker/coord.c | 629 |
1 files changed, 629 insertions, 0 deletions
diff --git a/old/2021-11-10-beforeremovingchecker/coord.c b/old/2021-11-10-beforeremovingchecker/coord.c new file mode 100644 index 0000000..343dfb3 --- /dev/null +++ b/old/2021-11-10-beforeremovingchecker/coord.c | |||
| @@ -0,0 +1,629 @@ | |||
| 1 | #include "coord.h" | ||
| 2 | |||
| 3 | static Cube antindex_eofb(uint64_t ind); | ||
| 4 | static Cube antindex_eofbepos(uint64_t ind); | ||
| 5 | static Cube antindex_epud(uint64_t ind); | ||
| 6 | static Cube antindex_coud(uint64_t ind); | ||
| 7 | static Cube antindex_corners(uint64_t ind); | ||
| 8 | static Cube antindex_cp(uint64_t ind); | ||
| 9 | static Cube antindex_cphtr(uint64_t); | ||
| 10 | static Cube antindex_cornershtr(uint64_t ind); | ||
| 11 | static Cube antindex_cornershtrfin(uint64_t ind); | ||
| 12 | static Cube antindex_drud(uint64_t ind); | ||
| 13 | static Cube antindex_drud_eofb(uint64_t ind); | ||
| 14 | static Cube antindex_htr_drud(uint64_t ind); | ||
| 15 | static Cube antindex_htrfin(uint64_t ind); | ||
| 16 | |||
| 17 | static uint64_t index_eofb(Cube cube); | ||
| 18 | static uint64_t index_eofbepos(Cube cube); | ||
| 19 | static uint64_t index_epud(Cube cube); | ||
| 20 | static uint64_t index_coud(Cube cube); | ||
| 21 | static uint64_t index_corners(Cube cube); | ||
| 22 | static uint64_t index_cp(Cube cube); | ||
| 23 | static uint64_t index_cphtr(Cube cube); | ||
| 24 | static uint64_t index_cornershtr(Cube cube); | ||
| 25 | static uint64_t index_cornershtrfin(Cube cube); | ||
| 26 | static uint64_t index_drud(Cube cube); | ||
| 27 | static uint64_t index_drud_eofb(Cube cube); | ||
| 28 | static uint64_t index_htr_drud(Cube cube); | ||
| 29 | static uint64_t index_htrfin(Cube cube); | ||
| 30 | |||
| 31 | static void init_cphtr_cosets(); | ||
| 32 | static void init_cphtr_left_cosets_bfs(int i, int c); | ||
| 33 | static void init_cphtr_right_cosets_color(int i, int c); | ||
| 34 | static void init_cornershtrfin(); | ||
| 35 | |||
| 36 | |||
| 37 | /* All sorts of useful costants and tables **********************************/ | ||
| 38 | |||
| 39 | static int cphtr_left_cosets[FACTORIAL8]; | ||
| 40 | static int cphtr_right_cosets[FACTORIAL8]; | ||
| 41 | static int cphtr_right_rep[BINOM8ON4*6]; | ||
| 42 | static int cornershtrfin_ind[FACTORIAL8]; | ||
| 43 | static int cornershtrfin_ant[24*24/6]; | ||
| 44 | |||
| 45 | /* Coordinates and their implementation **************************************/ | ||
| 46 | |||
| 47 | Coordinate | ||
| 48 | coord_eofb = { | ||
| 49 | .index = index_eofb, | ||
| 50 | .cube = antindex_eofb, | ||
| 51 | .check = check_eofb, | ||
| 52 | .max = POW2TO11, | ||
| 53 | .ntrans = 1, | ||
| 54 | }; | ||
| 55 | |||
| 56 | Coordinate | ||
| 57 | coord_eofbepos = { | ||
| 58 | .index = index_eofbepos, | ||
| 59 | .cube = antindex_eofbepos, | ||
| 60 | .check = check_eofbepos, | ||
| 61 | .max = POW2TO11 * BINOM12ON4, | ||
| 62 | .ntrans = 1, | ||
| 63 | }; | ||
| 64 | |||
| 65 | Coordinate | ||
| 66 | coord_coud = { | ||
| 67 | .index = index_coud, | ||
| 68 | .cube = antindex_coud, | ||
| 69 | .check = check_coud, | ||
| 70 | .max = POW3TO7, | ||
| 71 | .ntrans = 1, | ||
| 72 | }; | ||
| 73 | |||
| 74 | Coordinate | ||
| 75 | coord_corners = { | ||
| 76 | .index = index_corners, | ||
| 77 | .cube = antindex_corners, | ||
| 78 | .check = check_corners, | ||
| 79 | .max = POW3TO7 * FACTORIAL8, | ||
| 80 | .ntrans = 1, | ||
| 81 | }; | ||
| 82 | |||
| 83 | Coordinate | ||
| 84 | coord_cp = { | ||
| 85 | .index = index_cp, | ||
| 86 | .cube = antindex_cp, | ||
| 87 | .check = check_cp, | ||
| 88 | .max = FACTORIAL8, | ||
| 89 | .ntrans = 1, | ||
| 90 | }; | ||
| 91 | |||
| 92 | Coordinate | ||
| 93 | coord_cphtr = { | ||
| 94 | .index = index_cphtr, | ||
| 95 | .cube = antindex_cphtr, | ||
| 96 | .check = check_cphtr, | ||
| 97 | .max = BINOM8ON4 * 6, | ||
| 98 | .ntrans = 1, | ||
| 99 | }; | ||
| 100 | |||
| 101 | Coordinate | ||
| 102 | coord_cornershtr = { | ||
| 103 | .index = index_cornershtr, | ||
| 104 | .cube = antindex_cornershtr, | ||
| 105 | .check = check_cornershtr, | ||
| 106 | .max = POW3TO7 * BINOM8ON4 * 6, | ||
| 107 | .ntrans = 1, | ||
| 108 | }; | ||
| 109 | |||
| 110 | Coordinate | ||
| 111 | coord_cornershtrfin = { | ||
| 112 | .index = index_cornershtrfin, | ||
| 113 | .cube = antindex_cornershtrfin, | ||
| 114 | .check = check_cp, | ||
| 115 | .max = 24*24/6, | ||
| 116 | .ntrans = 1, | ||
| 117 | }; | ||
| 118 | |||
| 119 | Coordinate | ||
| 120 | coord_epud = { | ||
| 121 | .index = index_epud, | ||
| 122 | .cube = antindex_epud, | ||
| 123 | .check = check_epud, | ||
| 124 | .max = FACTORIAL8, | ||
| 125 | .ntrans = 1, | ||
| 126 | }; | ||
| 127 | |||
| 128 | Coordinate | ||
| 129 | coord_drud = { | ||
| 130 | .index = index_drud, | ||
| 131 | .cube = antindex_drud, | ||
| 132 | .check = check_drud, | ||
| 133 | .max = POW2TO11 * POW3TO7 * BINOM12ON4, | ||
| 134 | .ntrans = 1, | ||
| 135 | }; | ||
| 136 | |||
| 137 | Coordinate | ||
| 138 | coord_htr_drud = { | ||
| 139 | .index = index_htr_drud, | ||
| 140 | .cube = antindex_htr_drud, | ||
| 141 | .check = check_drud, | ||
| 142 | .max = BINOM8ON4 * 6 * BINOM8ON4, | ||
| 143 | .ntrans = 1, | ||
| 144 | }; | ||
| 145 | |||
| 146 | Coordinate | ||
| 147 | coord_htrfin = { | ||
| 148 | .index = index_htrfin, | ||
| 149 | .cube = antindex_htrfin, | ||
| 150 | .check = check_htr, | ||
| 151 | .max = 24 * 24 * 24 *24 * 24 / 6, /* should be /12 but it's ok */ | ||
| 152 | .ntrans = 1, | ||
| 153 | }; | ||
| 154 | |||
| 155 | Coordinate | ||
| 156 | coord_drud_eofb = { | ||
| 157 | .index = index_drud_eofb, | ||
| 158 | .cube = antindex_drud_eofb, | ||
| 159 | .check = check_drud, | ||
| 160 | .max = POW3TO7 * BINOM12ON4, | ||
| 161 | .ntrans = 1, | ||
| 162 | }; | ||
| 163 | |||
| 164 | /* Functions *****************************************************************/ | ||
| 165 | |||
| 166 | static Cube | ||
| 167 | antindex_eofb(uint64_t ind) | ||
| 168 | { | ||
| 169 | return (Cube){ .eofb = ind, .eorl = ind, .eoud = ind }; | ||
| 170 | } | ||
| 171 | |||
| 172 | static Cube | ||
| 173 | antindex_eofbepos(uint64_t ind) | ||
| 174 | { | ||
| 175 | Cube ret = {0}; | ||
| 176 | |||
| 177 | ret.eofb = ind % POW2TO11; | ||
| 178 | ret.epose = (ind / POW2TO11) * 24; | ||
| 179 | |||
| 180 | return ret; | ||
| 181 | } | ||
| 182 | |||
| 183 | static Cube | ||
| 184 | antindex_epud(uint64_t ind) | ||
| 185 | { | ||
| 186 | static bool initialized = false; | ||
| 187 | static Cube epud_aux[FACTORIAL8]; | ||
| 188 | int a[12]; | ||
| 189 | uint64_t ui; | ||
| 190 | CubeArray arr; | ||
| 191 | |||
| 192 | if (!initialized) { | ||
| 193 | a[FR] = FR; | ||
| 194 | a[FL] = FL; | ||
| 195 | a[BL] = BL; | ||
| 196 | a[BR] = BR; | ||
| 197 | for (ui = 0; ui < FACTORIAL8; ui++) { | ||
| 198 | index_to_perm(ui, 8, a); | ||
| 199 | arr.ep = a; | ||
| 200 | epud_aux[ui] = arrays_to_cube(&arr, pf_ep); | ||
| 201 | } | ||
| 202 | |||
| 203 | initialized = true; | ||
| 204 | } | ||
| 205 | |||
| 206 | return epud_aux[ind]; | ||
| 207 | } | ||
| 208 | |||
| 209 | static Cube | ||
| 210 | antindex_coud(uint64_t ind) | ||
| 211 | { | ||
| 212 | return (Cube){ .coud = ind, .corl = ind, .cofb = ind }; | ||
| 213 | } | ||
| 214 | |||
| 215 | static Cube | ||
| 216 | antindex_corners(uint64_t ind) | ||
| 217 | { | ||
| 218 | Cube c = {0}; | ||
| 219 | |||
| 220 | c.coud = ind / FACTORIAL8; | ||
| 221 | c.cp = ind % FACTORIAL8; | ||
| 222 | |||
| 223 | return c; | ||
| 224 | } | ||
| 225 | |||
| 226 | static Cube | ||
| 227 | antindex_cp(uint64_t ind) | ||
| 228 | { | ||
| 229 | Cube c = {0}; | ||
| 230 | |||
| 231 | c.cp = ind; | ||
| 232 | |||
| 233 | return c; | ||
| 234 | } | ||
| 235 | |||
| 236 | static Cube | ||
| 237 | antindex_cphtr(uint64_t ind) | ||
| 238 | { | ||
| 239 | return (Cube) { .cp = cphtr_right_rep[ind] }; | ||
| 240 | } | ||
| 241 | |||
| 242 | static Cube | ||
| 243 | antindex_cornershtr(uint64_t ind) | ||
| 244 | { | ||
| 245 | Cube c = antindex_cphtr(ind % (BINOM8ON4 * 6)); | ||
| 246 | |||
| 247 | c.coud = ind / (BINOM8ON4 * 6); | ||
| 248 | |||
| 249 | return c; | ||
| 250 | } | ||
| 251 | |||
| 252 | static Cube | ||
| 253 | antindex_cornershtrfin(uint64_t ind) | ||
| 254 | { | ||
| 255 | return (Cube){ .cp = cornershtrfin_ant[ind] }; | ||
| 256 | } | ||
| 257 | |||
| 258 | static Cube | ||
| 259 | antindex_drud(uint64_t ind) | ||
| 260 | { | ||
| 261 | uint64_t epos, eofb; | ||
| 262 | Cube c; | ||
| 263 | |||
| 264 | eofb = ind % POW2TO11; | ||
| 265 | epos = ind / (POW2TO11 * POW3TO7); | ||
| 266 | c = antindex_eofbepos(eofb + POW2TO11 * epos); | ||
| 267 | |||
| 268 | c.coud = (ind / POW2TO11) % POW3TO7; | ||
| 269 | |||
| 270 | return c; | ||
| 271 | } | ||
| 272 | |||
| 273 | static Cube | ||
| 274 | antindex_drud_eofb(uint64_t ind) | ||
| 275 | { | ||
| 276 | return antindex_drud(ind * POW2TO11); | ||
| 277 | } | ||
| 278 | |||
| 279 | static Cube | ||
| 280 | antindex_htr_drud(uint64_t ind) | ||
| 281 | { | ||
| 282 | Cube ret; | ||
| 283 | |||
| 284 | ret = antindex_cphtr(ind / BINOM8ON4); | ||
| 285 | ret.eposs = (ind % BINOM8ON4) * FACTORIAL4; | ||
| 286 | |||
| 287 | return ret; | ||
| 288 | } | ||
| 289 | |||
| 290 | static Cube | ||
| 291 | antindex_htrfin(uint64_t ind) | ||
| 292 | { | ||
| 293 | Cube ret; | ||
| 294 | |||
| 295 | ret = antindex_cornershtrfin(ind/(24*24*24)); | ||
| 296 | |||
| 297 | ret.eposm = ind % 24; | ||
| 298 | ind /= 24; | ||
| 299 | ret.eposs = ind % 24; | ||
| 300 | ind /= 24; | ||
| 301 | ret.epose = ind % 24; | ||
| 302 | |||
| 303 | return ret; | ||
| 304 | } | ||
| 305 | |||
| 306 | bool | ||
| 307 | check_centers(Cube cube) | ||
| 308 | { | ||
| 309 | return cube.cpos == 0; | ||
| 310 | } | ||
| 311 | |||
| 312 | bool | ||
| 313 | check_corners(Cube cube) | ||
| 314 | { | ||
| 315 | return cube.cp == 0 && cube.coud == 0; | ||
| 316 | } | ||
| 317 | |||
| 318 | bool | ||
| 319 | check_cp(Cube cube) | ||
| 320 | { | ||
| 321 | return cube.cp == 0; | ||
| 322 | } | ||
| 323 | |||
| 324 | bool | ||
| 325 | check_cphtr(Cube cube) | ||
| 326 | { | ||
| 327 | return index_cphtr(cube) == 0; | ||
| 328 | } | ||
| 329 | |||
| 330 | bool | ||
| 331 | check_cornershtr(Cube cube) | ||
| 332 | { | ||
| 333 | return cube.coud == 0 && index_cphtr(cube) == 0; | ||
| 334 | } | ||
| 335 | |||
| 336 | bool | ||
| 337 | check_coud(Cube cube) | ||
| 338 | { | ||
| 339 | return cube.coud == 0; | ||
| 340 | } | ||
| 341 | |||
| 342 | bool | ||
| 343 | check_drud(Cube cube) | ||
| 344 | { | ||
| 345 | return cube.eofb == 0 && cube.eorl == 0 && cube.coud == 0; | ||
| 346 | } | ||
| 347 | |||
| 348 | bool | ||
| 349 | check_htr(Cube cube) | ||
| 350 | { | ||
| 351 | return check_cornershtr(cube) && | ||
| 352 | cube.eofb == 0 && cube.eorl == 0 && cube.eoud == 0; | ||
| 353 | } | ||
| 354 | |||
| 355 | bool | ||
| 356 | check_drudfin_noE(Cube cube) | ||
| 357 | { | ||
| 358 | return cube.eposs == 0 && cube.eposm == 0 && cube.cp == 0; | ||
| 359 | } | ||
| 360 | |||
| 361 | bool | ||
| 362 | check_eofb(Cube cube) | ||
| 363 | { | ||
| 364 | return cube.eofb == 0; | ||
| 365 | } | ||
| 366 | |||
| 367 | bool | ||
| 368 | check_eofbepos(Cube cube) | ||
| 369 | { | ||
| 370 | return cube.eofb == 0 && cube.epose / 24 == 0; | ||
| 371 | } | ||
| 372 | |||
| 373 | bool | ||
| 374 | check_epose(Cube cube) | ||
| 375 | { | ||
| 376 | return cube.epose == 0; | ||
| 377 | } | ||
| 378 | |||
| 379 | bool | ||
| 380 | check_epud(Cube cube) | ||
| 381 | { | ||
| 382 | return cube.eposs == 0 && cube.eposm == 0; | ||
| 383 | } | ||
| 384 | |||
| 385 | bool | ||
| 386 | check_ep(Cube cube) | ||
| 387 | { | ||
| 388 | return cube.epose == 0 && cube.eposs == 0 && cube.eposm == 0; | ||
| 389 | } | ||
| 390 | |||
| 391 | bool | ||
| 392 | check_khuge(Cube cube) | ||
| 393 | { | ||
| 394 | return check_drud(cube) && cube.epose % 24 == 0; | ||
| 395 | } | ||
| 396 | |||
| 397 | bool | ||
| 398 | check_nothing(Cube cube) | ||
| 399 | { | ||
| 400 | return is_admissible(cube); /*TODO: maybe change?*/ | ||
| 401 | } | ||
| 402 | |||
| 403 | static uint64_t | ||
| 404 | index_eofb(Cube cube) | ||
| 405 | { | ||
| 406 | return cube.eofb; | ||
| 407 | } | ||
| 408 | |||
| 409 | static uint64_t | ||
| 410 | index_eofbepos(Cube cube) | ||
| 411 | { | ||
| 412 | return (cube.epose / FACTORIAL4) * POW2TO11 + cube.eofb; | ||
| 413 | } | ||
| 414 | |||
| 415 | static uint64_t | ||
| 416 | index_epud(Cube cube) | ||
| 417 | { | ||
| 418 | uint64_t ret; | ||
| 419 | CubeArray *arr = new_cubearray(cube, pf_ep); | ||
| 420 | |||
| 421 | ret = perm_to_index(arr->ep, 8); | ||
| 422 | free_cubearray(arr, pf_ep); | ||
| 423 | |||
| 424 | return ret; | ||
| 425 | } | ||
| 426 | |||
| 427 | static uint64_t | ||
| 428 | index_coud(Cube cube) | ||
| 429 | { | ||
| 430 | return cube.coud; | ||
| 431 | } | ||
| 432 | |||
| 433 | static uint64_t | ||
| 434 | index_corners(Cube cube) | ||
| 435 | { | ||
| 436 | return cube.coud * FACTORIAL8 + cube.cp; | ||
| 437 | } | ||
| 438 | |||
| 439 | static uint64_t | ||
| 440 | index_cp(Cube cube) | ||
| 441 | { | ||
| 442 | return cube.cp; | ||
| 443 | } | ||
| 444 | |||
| 445 | static uint64_t | ||
| 446 | index_cphtr(Cube cube) | ||
| 447 | { | ||
| 448 | return cphtr_right_cosets[cube.cp]; | ||
| 449 | } | ||
| 450 | |||
| 451 | static uint64_t | ||
| 452 | index_cornershtr(Cube cube) | ||
| 453 | { | ||
| 454 | return cube.coud * BINOM8ON4 * 6 + index_cphtr(cube); | ||
| 455 | } | ||
| 456 | |||
| 457 | static uint64_t | ||
| 458 | index_cornershtrfin(Cube cube) | ||
| 459 | { | ||
| 460 | return cornershtrfin_ind[cube.cp]; | ||
| 461 | } | ||
| 462 | |||
| 463 | static uint64_t | ||
| 464 | index_drud(Cube cube) | ||
| 465 | { | ||
| 466 | uint64_t a, b, c; | ||
| 467 | |||
| 468 | a = cube.eofb; | ||
| 469 | b = cube.coud; | ||
| 470 | c = cube.epose / FACTORIAL4; | ||
| 471 | |||
| 472 | b *= POW2TO11; | ||
| 473 | c *= POW2TO11 * POW3TO7; | ||
| 474 | |||
| 475 | return a + b + c; | ||
| 476 | } | ||
| 477 | |||
| 478 | static uint64_t | ||
| 479 | index_drud_eofb(Cube cube) | ||
| 480 | { | ||
| 481 | return index_drud(cube) / POW2TO11; | ||
| 482 | } | ||
| 483 | |||
| 484 | static uint64_t | ||
| 485 | index_htr_drud(Cube cube) | ||
| 486 | { | ||
| 487 | return index_cphtr(cube) * BINOM8ON4 + | ||
| 488 | (cube.eposs / FACTORIAL4) % BINOM8ON4; | ||
| 489 | } | ||
| 490 | |||
| 491 | static uint64_t | ||
| 492 | index_htrfin(Cube cube) | ||
| 493 | { | ||
| 494 | uint64_t epe, eps, epm, cp, ep; | ||
| 495 | |||
| 496 | epe = cube.epose % 24; | ||
| 497 | eps = cube.eposs % 24; | ||
| 498 | epm = cube.eposm % 24; | ||
| 499 | ep = (epe * 24 + eps) *24 + epm; | ||
| 500 | cp = index_cornershtrfin(cube); | ||
| 501 | |||
| 502 | return cp * 24 * 24 * 24 + ep; | ||
| 503 | } | ||
| 504 | |||
| 505 | /* Init functions implementation *********************************************/ | ||
| 506 | |||
| 507 | /* | ||
| 508 | * There is certainly a better way to do this, but for now I just use | ||
| 509 | * a "graph coloring" algorithm to compute the left cosets, and I compose | ||
| 510 | * with every possible cp to get the right cosets (it is possible that I am | ||
| 511 | * mixing up left and right). | ||
| 512 | * | ||
| 513 | * For doing it better "Mathematically", we need 3 things: | ||
| 514 | * - Checking that cp separates the orbits (UFR,UBL,DFL,DBR) and the other | ||
| 515 | * This is easy and it is done in the commented function cphtr_cp(). | ||
| 516 | * - Check that there is no ep/cp parity | ||
| 517 | * - Check that we are not in the "3c" case; this is the part I don't | ||
| 518 | * know how to do. | ||
| 519 | */ | ||
| 520 | static void | ||
| 521 | init_cphtr_cosets() | ||
| 522 | { | ||
| 523 | unsigned int i; | ||
| 524 | int c = 0, d = 0; | ||
| 525 | |||
| 526 | for (i = 0; i < FACTORIAL8; i++) { | ||
| 527 | cphtr_left_cosets[i] = -1; | ||
| 528 | cphtr_right_cosets[i] = -1; | ||
| 529 | } | ||
| 530 | |||
| 531 | /* First we compute left cosets with a bfs */ | ||
| 532 | for (i = 0; i < FACTORIAL8; i++) | ||
| 533 | if (cphtr_left_cosets[i] == -1) | ||
| 534 | init_cphtr_left_cosets_bfs(i, c++); | ||
| 535 | |||
| 536 | /* Then we compute right cosets using compose() */ | ||
| 537 | for (i = 0; i < FACTORIAL8; i++) | ||
| 538 | if (cphtr_right_cosets[i] == -1) | ||
| 539 | init_cphtr_right_cosets_color(i, d++); | ||
| 540 | } | ||
| 541 | |||
| 542 | static void | ||
| 543 | init_cphtr_left_cosets_bfs(int i, int c) | ||
| 544 | { | ||
| 545 | int j, jj, k, next[FACTORIAL8], next2[FACTORIAL8], n, n2; | ||
| 546 | Move moves[6] = {U2, D2, R2, L2, F2, B2}; | ||
| 547 | |||
| 548 | n = 1; | ||
| 549 | next[0] = i; | ||
| 550 | cphtr_left_cosets[i] = c; | ||
| 551 | |||
| 552 | while (n != 0) { | ||
| 553 | for (j = 0, n2 = 0; j < n; j++) { | ||
| 554 | for (k = 0; k < 6; k++) { | ||
| 555 | /*jj = cp_mtable[moves[k]][next[j]];*/ | ||
| 556 | /* TODO fix formatting */ | ||
| 557 | jj = apply_move(moves[k], (Cube){.cp=next[j]}).cp; | ||
| 558 | if (cphtr_left_cosets[jj] == -1) { | ||
| 559 | cphtr_left_cosets[jj] = c; | ||
| 560 | next2[n2++] = jj; | ||
| 561 | } | ||
| 562 | } | ||
| 563 | } | ||
| 564 | |||
| 565 | for (j = 0; j < n2; j++) | ||
| 566 | next[j] = next2[j]; | ||
| 567 | n = n2; | ||
| 568 | } | ||
| 569 | } | ||
| 570 | |||
| 571 | static void | ||
| 572 | init_cphtr_right_cosets_color(int i, int d) | ||
| 573 | { | ||
| 574 | int cp; | ||
| 575 | unsigned int j; | ||
| 576 | |||
| 577 | cphtr_right_rep[d] = i; | ||
| 578 | for (j = 0; j < FACTORIAL8; j++) { | ||
| 579 | if (cphtr_left_cosets[j] == 0) { | ||
| 580 | /* TODO: use antindexer, it's nicer */ | ||
| 581 | cp = compose((Cube){.cp = i}, (Cube){.cp = j}).cp; | ||
| 582 | cphtr_right_cosets[cp] = d; | ||
| 583 | } | ||
| 584 | } | ||
| 585 | } | ||
| 586 | |||
| 587 | static void | ||
| 588 | init_cornershtrfin() | ||
| 589 | { | ||
| 590 | unsigned int i, j; | ||
| 591 | int n, c; | ||
| 592 | Move m; | ||
| 593 | |||
| 594 | for (i = 0; i < FACTORIAL8; i++) | ||
| 595 | cornershtrfin_ind[i] = -1; | ||
| 596 | cornershtrfin_ind[0] = 0; | ||
| 597 | |||
| 598 | /* 10-pass, I think 5 is enough, but just in case */ | ||
| 599 | n = 1; | ||
| 600 | for (i = 0; i < 10; i++) { | ||
| 601 | for (j = 0; j < FACTORIAL8; j++) { | ||
| 602 | if (cornershtrfin_ind[j] == -1) | ||
| 603 | continue; | ||
| 604 | for (m = U; m < NMOVES; m++) { | ||
| 605 | if (moveset_htr(m)) { | ||
| 606 | c = apply_move(m, (Cube){.cp = j}).cp; | ||
| 607 | if (cornershtrfin_ind[c] == -1) { | ||
| 608 | cornershtrfin_ind[c] = n; | ||
| 609 | cornershtrfin_ant[n] = c; | ||
| 610 | n++; | ||
| 611 | } | ||
| 612 | } | ||
| 613 | } | ||
| 614 | } | ||
| 615 | } | ||
| 616 | } | ||
| 617 | |||
| 618 | void | ||
| 619 | init_coord() | ||
| 620 | { | ||
| 621 | static bool initialized = false; | ||
| 622 | if (initialized) | ||
| 623 | return; | ||
| 624 | initialized = true; | ||
| 625 | |||
| 626 | init_cphtr_cosets(); | ||
| 627 | init_cornershtrfin(); | ||
| 628 | } | ||
| 629 | |||
