diff options
Diffstat (limited to 'old/maybe-useful-steps.c')
| -rw-r--r-- | old/maybe-useful-steps.c | 1111 |
1 files changed, 1111 insertions, 0 deletions
diff --git a/old/maybe-useful-steps.c b/old/maybe-useful-steps.c new file mode 100644 index 0000000..2a20dd9 --- /dev/null +++ b/old/maybe-useful-steps.c | |||
| @@ -0,0 +1,1111 @@ | |||
| 1 | #include "steps.h" | ||
| 2 | |||
| 3 | #define UPDATECHECKSTOP(a, b, c) if ((a=(MAX((a),(b))))>(c)) return (a); | ||
| 4 | |||
| 5 | static int estimate_stepalt(StepAlt *a, uint64_t *ind); | ||
| 6 | |||
| 7 | /* Checkers and validators ***************************************************/ | ||
| 8 | |||
| 9 | /* TODO: these should be with Cube *cube (and all need to change) */ | ||
| 10 | /* Maybe move them to cube.c */ | ||
| 11 | static bool check_centers(Cube cube); | ||
| 12 | static bool check_coud_HTM(Cube cube); | ||
| 13 | static bool check_coud_URF(Cube cube); | ||
| 14 | static bool check_corners_HTM(Cube cube); | ||
| 15 | static bool check_corners_URF(Cube cube); | ||
| 16 | static bool check_cornershtr(Cube cube); | ||
| 17 | static bool check_eofb(Cube cube); | ||
| 18 | static bool check_drud(Cube cube); | ||
| 19 | static bool check_htr(Cube cube); | ||
| 20 | |||
| 21 | static bool always_valid(Alg *alg); | ||
| 22 | static bool validate_singlecw_ending(Alg *alg); | ||
| 23 | |||
| 24 | /* Messages for when cube is not ready ***************************************/ | ||
| 25 | |||
| 26 | static char check_centers_msg[100] = "cube must be oriented (centers solved)"; | ||
| 27 | static char check_eo_msg[100] = "EO must be solved on given axis"; | ||
| 28 | static char check_dr_msg[100] = "DR must be solved on given axis"; | ||
| 29 | static char check_htr_msg[100] = "HTR must be solved"; | ||
| 30 | static char check_drany_msg[100] = "DR must be solved on at least one axis"; | ||
| 31 | |||
| 32 | /* Steps *********************************************************************/ | ||
| 33 | |||
| 34 | /* Optimal solvers *******************/ | ||
| 35 | |||
| 36 | Step | ||
| 37 | optimal_HTM = { | ||
| 38 | .shortname = "optimal", | ||
| 39 | .name = "Optimal solve (in HTM)", | ||
| 40 | |||
| 41 | .final = true, | ||
| 42 | .is_done = is_solved, | ||
| 43 | .estimate = estimate_nxopt31_HTM, | ||
| 44 | .ready = check_centers, | ||
| 45 | .ready_msg = check_centers_msg, | ||
| 46 | .is_valid = always_valid, | ||
| 47 | .moveset = &moveset_HTM, | ||
| 48 | |||
| 49 | .pre_trans = uf, | ||
| 50 | |||
| 51 | .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, | ||
| 52 | .ntables = 2, | ||
| 53 | }; | ||
| 54 | |||
| 55 | Step | ||
| 56 | optimal_light_HTM = { | ||
| 57 | .shortname = "light", | ||
| 58 | .name = "Optimal solve (in HTM), small table (500Mb RAM total)", | ||
| 59 | |||
| 60 | .final = true, | ||
| 61 | .is_done = is_solved, | ||
| 62 | .estimate = estimate_light_HTM, | ||
| 63 | .ready = check_centers, | ||
| 64 | .ready_msg = check_centers_msg, | ||
| 65 | .is_valid = always_valid, | ||
| 66 | .moveset = &moveset_HTM, | ||
| 67 | |||
| 68 | .pre_trans = uf, | ||
| 69 | |||
| 70 | .tables = {&pd_drud_sym16_HTM, &pd_corners_HTM}, | ||
| 71 | .ntables = 2, | ||
| 72 | }; | ||
| 73 | |||
| 74 | /* Optimal after EO ******************/ | ||
| 75 | |||
| 76 | Step | ||
| 77 | eofin_eo = { | ||
| 78 | .shortname = "eofin", | ||
| 79 | .name = "Optimal solve after EO without breaking EO (detected)", | ||
| 80 | |||
| 81 | .final = true, | ||
| 82 | .is_done = is_solved, | ||
| 83 | .estimate = estimate_nxopt31_HTM, | ||
| 84 | .ready = check_eofb, | ||
| 85 | .ready_msg = check_eo_msg, | ||
| 86 | .is_valid = always_valid, | ||
| 87 | .moveset = &moveset_eofb, | ||
| 88 | |||
| 89 | .detect = detect_pretrans_eofb, | ||
| 90 | |||
| 91 | .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, | ||
| 92 | .ntables = 2, | ||
| 93 | }; | ||
| 94 | |||
| 95 | Step | ||
| 96 | eofbfin_eofb = { | ||
| 97 | .shortname = "eofbfin", | ||
| 98 | .name = "Optimal after EO on F/B without breaking EO", | ||
| 99 | |||
| 100 | .final = true, | ||
| 101 | .is_done = is_solved, | ||
| 102 | .estimate = estimate_nxopt31_HTM, | ||
| 103 | .ready = check_eofb, | ||
| 104 | .ready_msg = check_eo_msg, | ||
| 105 | .is_valid = always_valid, | ||
| 106 | .moveset = &moveset_eofb, | ||
| 107 | |||
| 108 | .pre_trans = uf, | ||
| 109 | |||
| 110 | .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, | ||
| 111 | .ntables = 2, | ||
| 112 | }; | ||
| 113 | |||
| 114 | Step | ||
| 115 | eorlfin_eorl = { | ||
| 116 | .shortname = "eorlfin", | ||
| 117 | .name = "Optimal after EO on R/L without breaking EO", | ||
| 118 | |||
| 119 | .final = true, | ||
| 120 | .is_done = is_solved, | ||
| 121 | .estimate = estimate_nxopt31_HTM, | ||
| 122 | .ready = check_eofb, | ||
| 123 | .ready_msg = check_eo_msg, | ||
| 124 | .is_valid = always_valid, | ||
| 125 | .moveset = &moveset_eofb, | ||
| 126 | |||
| 127 | .pre_trans = ur, | ||
| 128 | |||
| 129 | .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, | ||
| 130 | .ntables = 2, | ||
| 131 | }; | ||
| 132 | |||
| 133 | Step | ||
| 134 | eoudfin_eoud = { | ||
| 135 | .shortname = "eoudfin", | ||
| 136 | .name = "Optimal after EO on U/D without breaking EO", | ||
| 137 | |||
| 138 | .final = true, | ||
| 139 | .is_done = is_solved, | ||
| 140 | .estimate = estimate_nxopt31_HTM, | ||
| 141 | .ready = check_eofb, | ||
| 142 | .ready_msg = check_eo_msg, | ||
| 143 | .is_valid = always_valid, | ||
| 144 | .moveset = &moveset_eofb, | ||
| 145 | |||
| 146 | .pre_trans = fd, | ||
| 147 | |||
| 148 | .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, | ||
| 149 | .ntables = 2, | ||
| 150 | }; | ||
| 151 | |||
| 152 | /* EO steps **************************/ | ||
| 153 | Step | ||
| 154 | eoany_HTM = { | ||
| 155 | .shortname = "eo", | ||
| 156 | .name = "EO on any axis", | ||
| 157 | |||
| 158 | .final = false, | ||
| 159 | .is_done = check_eofb, | ||
| 160 | .estimate = estimate_eofb_HTM, | ||
| 161 | .ready = check_centers, | ||
| 162 | .ready_msg = check_centers_msg, | ||
| 163 | .is_valid = validate_singlecw_ending, | ||
| 164 | .moveset = &moveset_HTM, | ||
| 165 | |||
| 166 | .detect = detect_pretrans_void_3axis, | ||
| 167 | |||
| 168 | .tables = {&pd_eofb_HTM}, | ||
| 169 | .ntables = 1, | ||
| 170 | }; | ||
| 171 | |||
| 172 | Step | ||
| 173 | eofb_HTM = { | ||
| 174 | .shortname = "eofb", | ||
| 175 | .name = "EO on F/B", | ||
| 176 | |||
| 177 | .final = false, | ||
| 178 | .is_done = check_eofb, | ||
| 179 | .estimate = estimate_eofb_HTM, | ||
| 180 | .ready = check_centers, | ||
| 181 | .ready_msg = check_centers_msg, | ||
| 182 | .is_valid = validate_singlecw_ending, | ||
| 183 | .moveset = &moveset_HTM, | ||
| 184 | |||
| 185 | .pre_trans = uf, | ||
| 186 | |||
| 187 | .tables = {&pd_eofb_HTM}, | ||
| 188 | .ntables = 1, | ||
| 189 | }; | ||
| 190 | |||
| 191 | Step | ||
| 192 | eorl_HTM = { | ||
| 193 | .shortname = "eorl", | ||
| 194 | .name = "EO on R/L", | ||
| 195 | |||
| 196 | .final = false, | ||
| 197 | .is_done = check_eofb, | ||
| 198 | .estimate = estimate_eofb_HTM, | ||
| 199 | .ready = check_centers, | ||
| 200 | .ready_msg = check_centers_msg, | ||
| 201 | .is_valid = validate_singlecw_ending, | ||
| 202 | .moveset = &moveset_HTM, | ||
| 203 | |||
| 204 | .pre_trans = ur, | ||
| 205 | |||
| 206 | .tables = {&pd_eofb_HTM}, | ||
| 207 | .ntables = 1, | ||
| 208 | }; | ||
| 209 | |||
| 210 | Step | ||
| 211 | eoud_HTM = { | ||
| 212 | .shortname = "eoud", | ||
| 213 | .name = "EO on U/D", | ||
| 214 | |||
| 215 | .final = false, | ||
| 216 | .is_done = check_eofb, | ||
| 217 | .estimate = estimate_eofb_HTM, | ||
| 218 | .ready = check_centers, | ||
| 219 | .ready_msg = check_centers_msg, | ||
| 220 | .is_valid = validate_singlecw_ending, | ||
| 221 | .moveset = &moveset_HTM, | ||
| 222 | |||
| 223 | .pre_trans = fd, | ||
| 224 | |||
| 225 | .tables = {&pd_eofb_HTM}, | ||
| 226 | .ntables = 1, | ||
| 227 | }; | ||
| 228 | |||
| 229 | /* CO steps **************************/ | ||
| 230 | Step | ||
| 231 | coany_HTM = { | ||
| 232 | .shortname = "co", | ||
| 233 | .name = "CO on any axis", | ||
| 234 | |||
| 235 | .final = false, | ||
| 236 | .is_done = check_coud_HTM, | ||
| 237 | .estimate = estimate_coud_HTM, | ||
| 238 | .ready = NULL, | ||
| 239 | .is_valid = validate_singlecw_ending, | ||
| 240 | .moveset = &moveset_HTM, | ||
| 241 | |||
| 242 | .detect = detect_pretrans_void_3axis, | ||
| 243 | |||
| 244 | .tables = {&pd_coud_HTM}, | ||
| 245 | .ntables = 1, | ||
| 246 | }; | ||
| 247 | |||
| 248 | Step | ||
| 249 | coud_HTM = { | ||
| 250 | .shortname = "coud", | ||
| 251 | .name = "CO on U/D", | ||
| 252 | |||
| 253 | .final = false, | ||
| 254 | .is_done = check_coud_HTM, | ||
| 255 | .estimate = estimate_coud_HTM, | ||
| 256 | .ready = NULL, | ||
| 257 | .is_valid = validate_singlecw_ending, | ||
| 258 | .moveset = &moveset_HTM, | ||
| 259 | |||
| 260 | .pre_trans = uf, | ||
| 261 | |||
| 262 | .tables = {&pd_coud_HTM}, | ||
| 263 | .ntables = 1, | ||
| 264 | }; | ||
| 265 | |||
| 266 | Step | ||
| 267 | corl_HTM = { | ||
| 268 | .shortname = "corl", | ||
| 269 | .name = "CO on R/L", | ||
| 270 | |||
| 271 | .final = false, | ||
| 272 | .is_done = check_coud_HTM, | ||
| 273 | .estimate = estimate_coud_HTM, | ||
| 274 | .ready = NULL, | ||
| 275 | .is_valid = validate_singlecw_ending, | ||
| 276 | .moveset = &moveset_HTM, | ||
| 277 | |||
| 278 | .pre_trans = rf, | ||
| 279 | |||
| 280 | .tables = {&pd_coud_HTM}, | ||
| 281 | .ntables = 1, | ||
| 282 | }; | ||
| 283 | |||
| 284 | Step | ||
| 285 | cofb_HTM = { | ||
| 286 | .shortname = "cofb", | ||
| 287 | .name = "CO on F/B", | ||
| 288 | |||
| 289 | .final = false, | ||
| 290 | .is_done = check_coud_HTM, | ||
| 291 | .estimate = estimate_coud_HTM, | ||
| 292 | .ready = NULL, | ||
| 293 | .is_valid = validate_singlecw_ending, | ||
| 294 | .moveset = &moveset_HTM, | ||
| 295 | |||
| 296 | .pre_trans = fd, | ||
| 297 | |||
| 298 | .tables = {&pd_coud_HTM}, | ||
| 299 | .ntables = 1, | ||
| 300 | }; | ||
| 301 | |||
| 302 | Step | ||
| 303 | coany_URF = { | ||
| 304 | .shortname = "co-URF", | ||
| 305 | .name = "CO any axis (URF moveset)", | ||
| 306 | |||
| 307 | .final = false, | ||
| 308 | .is_done = check_coud_URF, | ||
| 309 | .estimate = estimate_coud_URF, | ||
| 310 | .ready = NULL, | ||
| 311 | .is_valid = validate_singlecw_ending, | ||
| 312 | .moveset = &moveset_URF, | ||
| 313 | |||
| 314 | .detect = detect_pretrans_void_3axis, | ||
| 315 | |||
| 316 | .tables = {&pd_coud_HTM}, | ||
| 317 | .ntables = 1, | ||
| 318 | }; | ||
| 319 | |||
| 320 | Step | ||
| 321 | coud_URF = { | ||
| 322 | .shortname = "coud-URF", | ||
| 323 | .name = "CO on U/D (URF moveset)", | ||
| 324 | |||
| 325 | .final = false, | ||
| 326 | .is_done = check_coud_URF, | ||
| 327 | .estimate = estimate_coud_URF, | ||
| 328 | .ready = NULL, | ||
| 329 | .is_valid = validate_singlecw_ending, | ||
| 330 | .moveset = &moveset_URF, | ||
| 331 | |||
| 332 | .pre_trans = uf, | ||
| 333 | |||
| 334 | .tables = {&pd_coud_HTM}, | ||
| 335 | .ntables = 1, | ||
| 336 | }; | ||
| 337 | |||
| 338 | Step | ||
| 339 | corl_URF = { | ||
| 340 | .shortname = "corl-URF", | ||
| 341 | .name = "CO on R/L (URF moveset)", | ||
| 342 | |||
| 343 | .final = false, | ||
| 344 | .is_done = check_coud_URF, | ||
| 345 | .estimate = estimate_coud_URF, | ||
| 346 | .ready = NULL, | ||
| 347 | .is_valid = validate_singlecw_ending, | ||
| 348 | .moveset = &moveset_URF, | ||
| 349 | |||
| 350 | .pre_trans = rf, | ||
| 351 | |||
| 352 | .tables = {&pd_coud_HTM}, | ||
| 353 | .ntables = 1, | ||
| 354 | }; | ||
| 355 | |||
| 356 | Step | ||
| 357 | cofb_URF = { | ||
| 358 | .shortname = "cofb-URF", | ||
| 359 | .name = "CO on F/B (URF moveset)", | ||
| 360 | |||
| 361 | .final = false, | ||
| 362 | .is_done = check_coud_URF, | ||
| 363 | .estimate = estimate_coud_URF, | ||
| 364 | .ready = NULL, | ||
| 365 | .is_valid = validate_singlecw_ending, | ||
| 366 | .moveset = &moveset_URF, | ||
| 367 | |||
| 368 | .pre_trans = fd, | ||
| 369 | |||
| 370 | .tables = {&pd_coud_HTM}, | ||
| 371 | .ntables = 1, | ||
| 372 | }; | ||
| 373 | |||
| 374 | /* Misc corner steps *****************/ | ||
| 375 | Step | ||
| 376 | cornershtr_HTM = { | ||
| 377 | .shortname = "chtr", | ||
| 378 | .name = "Solve corners to HTR state", | ||
| 379 | |||
| 380 | .final = false, | ||
| 381 | .is_done = check_cornershtr, | ||
| 382 | .estimate = estimate_cornershtr_HTM, | ||
| 383 | .ready = NULL, | ||
| 384 | .is_valid = validate_singlecw_ending, | ||
| 385 | .moveset = &moveset_HTM, | ||
| 386 | |||
| 387 | .pre_trans = uf, | ||
| 388 | |||
| 389 | .tables = {&pd_cornershtr_HTM}, | ||
| 390 | .ntables = 1, | ||
| 391 | }; | ||
| 392 | |||
| 393 | Step | ||
| 394 | cornershtr_URF = { | ||
| 395 | .shortname = "chtr-URF", | ||
| 396 | .name = "Solve corners to HTR state (URF moveset)", | ||
| 397 | |||
| 398 | .final = false, | ||
| 399 | .is_done = check_cornershtr, | ||
| 400 | .estimate = estimate_cornershtr_URF, | ||
| 401 | .ready = NULL, | ||
| 402 | .is_valid = validate_singlecw_ending, | ||
| 403 | .moveset = &moveset_URF, | ||
| 404 | |||
| 405 | .pre_trans = uf, | ||
| 406 | |||
| 407 | .tables = {&pd_cornershtr_HTM}, | ||
| 408 | .ntables = 1, | ||
| 409 | }; | ||
| 410 | |||
| 411 | Step | ||
| 412 | corners_HTM = { | ||
| 413 | .shortname = "corners", | ||
| 414 | .name = "Solve corners", | ||
| 415 | |||
| 416 | .final = true, | ||
| 417 | .is_done = check_corners_HTM, | ||
| 418 | .estimate = estimate_corners_HTM, | ||
| 419 | .ready = NULL, | ||
| 420 | .is_valid = always_valid, | ||
| 421 | .moveset = &moveset_HTM, | ||
| 422 | |||
| 423 | .pre_trans = uf, | ||
| 424 | |||
| 425 | .tables = {&pd_corners_HTM}, | ||
| 426 | .ntables = 1, | ||
| 427 | }; | ||
| 428 | |||
| 429 | Step | ||
| 430 | corners_URF = { | ||
| 431 | .shortname = "corners-URF", | ||
| 432 | .name = "Solve corners (URF moveset)", | ||
| 433 | |||
| 434 | .final = true, /* TODO: check if this works with reorient */ | ||
| 435 | .is_done = check_corners_URF, | ||
| 436 | .estimate = estimate_corners_URF, | ||
| 437 | .ready = NULL, | ||
| 438 | .is_valid = always_valid, | ||
| 439 | .moveset = &moveset_URF, | ||
| 440 | |||
| 441 | .pre_trans = uf, | ||
| 442 | |||
| 443 | .tables = {&pd_corners_HTM}, | ||
| 444 | .ntables = 1, | ||
| 445 | }; | ||
| 446 | |||
| 447 | /* DR steps **************************/ | ||
| 448 | Step | ||
| 449 | drany_HTM = { | ||
| 450 | .shortname = "dr", | ||
| 451 | .name = "DR on any axis", | ||
| 452 | |||
| 453 | .final = false, | ||
| 454 | .is_done = check_drud, | ||
| 455 | .estimate = estimate_drud_HTM, | ||
| 456 | .ready = check_centers, | ||
| 457 | .ready_msg = check_centers_msg, | ||
| 458 | .is_valid = validate_singlecw_ending, | ||
| 459 | .moveset = &moveset_HTM, | ||
| 460 | |||
| 461 | .detect = detect_pretrans_void_3axis, | ||
| 462 | |||
| 463 | .tables = {&pd_drud_sym16_HTM}, | ||
| 464 | .ntables = 1, | ||
| 465 | }; | ||
| 466 | |||
| 467 | Step | ||
| 468 | drud_HTM = { | ||
| 469 | .shortname = "drud", | ||
| 470 | .name = "DR on U/D", | ||
| 471 | |||
| 472 | .final = false, | ||
| 473 | .is_done = check_drud, | ||
| 474 | .estimate = estimate_drud_HTM, | ||
| 475 | .ready = check_centers, | ||
| 476 | .ready_msg = check_centers_msg, | ||
| 477 | .is_valid = validate_singlecw_ending, | ||
| 478 | .moveset = &moveset_HTM, | ||
| 479 | |||
| 480 | .pre_trans = uf, | ||
| 481 | |||
| 482 | .tables = {&pd_drud_sym16_HTM}, | ||
| 483 | .ntables = 1, | ||
| 484 | }; | ||
| 485 | |||
| 486 | Step | ||
| 487 | drrl_HTM = { | ||
| 488 | .shortname = "drrl", | ||
| 489 | .name = "DR on R/L", | ||
| 490 | |||
| 491 | .final = false, | ||
| 492 | .is_done = check_drud, | ||
| 493 | .estimate = estimate_drud_HTM, | ||
| 494 | .ready = check_centers, | ||
| 495 | .ready_msg = check_centers_msg, | ||
| 496 | .is_valid = validate_singlecw_ending, | ||
| 497 | .moveset = &moveset_HTM, | ||
| 498 | |||
| 499 | .pre_trans = rf, | ||
| 500 | |||
| 501 | .tables = {&pd_drud_sym16_HTM}, | ||
| 502 | .ntables = 1, | ||
| 503 | }; | ||
| 504 | |||
| 505 | Step | ||
| 506 | drfb_HTM = { | ||
| 507 | .shortname = "drfb", | ||
| 508 | .name = "DR on F/B", | ||
| 509 | |||
| 510 | .final = false, | ||
| 511 | .is_done = check_drud, | ||
| 512 | .estimate = estimate_drud_HTM, | ||
| 513 | .ready = check_centers, | ||
| 514 | .ready_msg = check_centers_msg, | ||
| 515 | .is_valid = validate_singlecw_ending, | ||
| 516 | .moveset = &moveset_HTM, | ||
| 517 | |||
| 518 | .pre_trans = fd, | ||
| 519 | |||
| 520 | .tables = {&pd_drud_sym16_HTM}, | ||
| 521 | .ntables = 1, | ||
| 522 | }; | ||
| 523 | |||
| 524 | /* DR from EO */ | ||
| 525 | Step | ||
| 526 | dr_eo = { | ||
| 527 | .shortname = "dr-eo", | ||
| 528 | .name = "DR without breaking EO (automatically detected)", | ||
| 529 | |||
| 530 | .final = false, | ||
| 531 | .is_done = check_drud, | ||
| 532 | .estimate = estimate_dr_eofb, | ||
| 533 | .ready = check_eofb, | ||
| 534 | .ready_msg = check_eo_msg, | ||
| 535 | .is_valid = validate_singlecw_ending, | ||
| 536 | .moveset = &moveset_eofb, | ||
| 537 | |||
| 538 | .detect = detect_pretrans_eofb, | ||
| 539 | |||
| 540 | .tables = {&pd_drud_eofb}, | ||
| 541 | .ntables = 1, | ||
| 542 | }; | ||
| 543 | |||
| 544 | Step | ||
| 545 | dr_eofb = { | ||
| 546 | .shortname = "dr-eofb", | ||
| 547 | .name = "DR on U/D or R/L without breaking EO on F/B", | ||
| 548 | |||
| 549 | .final = false, | ||
| 550 | .is_done = check_drud, | ||
| 551 | .estimate = estimate_dr_eofb, | ||
| 552 | .ready = check_eofb, | ||
| 553 | .ready_msg = check_eo_msg, | ||
| 554 | .is_valid = validate_singlecw_ending, | ||
| 555 | .moveset = &moveset_eofb, | ||
| 556 | |||
| 557 | .pre_trans = uf, | ||
| 558 | |||
| 559 | .tables = {&pd_drud_eofb}, | ||
| 560 | .ntables = 1, | ||
| 561 | }; | ||
| 562 | |||
| 563 | Step | ||
| 564 | dr_eorl = { | ||
| 565 | .shortname = "dr-eorl", | ||
| 566 | .name = "DR on U/D or F/B without breaking EO on R/L", | ||
| 567 | |||
| 568 | .final = false, | ||
| 569 | .is_done = check_drud, | ||
| 570 | .estimate = estimate_dr_eofb, | ||
| 571 | .ready = check_eofb, | ||
| 572 | .ready_msg = check_eo_msg, | ||
| 573 | .is_valid = validate_singlecw_ending, | ||
| 574 | .moveset = &moveset_eofb, | ||
| 575 | |||
| 576 | .pre_trans = ur, | ||
| 577 | |||
| 578 | .tables = {&pd_drud_eofb}, | ||
| 579 | .ntables = 1, | ||
| 580 | }; | ||
| 581 | |||
| 582 | Step | ||
| 583 | dr_eoud = { | ||
| 584 | .shortname = "dr-eoud", | ||
| 585 | .name = "DR on R/L or F/B without breaking EO on U/D", | ||
| 586 | |||
| 587 | .final = false, | ||
| 588 | .is_done = check_drud, | ||
| 589 | .estimate = estimate_dr_eofb, | ||
| 590 | .ready = check_eofb, | ||
| 591 | .ready_msg = check_eo_msg, | ||
| 592 | .is_valid = validate_singlecw_ending, | ||
| 593 | .moveset = &moveset_eofb, | ||
| 594 | |||
| 595 | .pre_trans = fd, | ||
| 596 | |||
| 597 | .tables = {&pd_drud_eofb}, | ||
| 598 | .ntables = 1, | ||
| 599 | }; | ||
| 600 | |||
| 601 | Step | ||
| 602 | drud_eofb = { | ||
| 603 | .shortname = "drud-eofb", | ||
| 604 | .name = "DR on U/D without breaking EO on F/B", | ||
| 605 | |||
| 606 | .final = false, | ||
| 607 | .is_done = check_drud, | ||
| 608 | .estimate = estimate_drud_eofb, | ||
| 609 | .ready = check_eofb, | ||
| 610 | .ready_msg = check_eo_msg, | ||
| 611 | .is_valid = validate_singlecw_ending, | ||
| 612 | .moveset = &moveset_eofb, | ||
| 613 | |||
| 614 | .pre_trans = uf, | ||
| 615 | |||
| 616 | .tables = {&pd_drud_eofb}, | ||
| 617 | .ntables = 1, | ||
| 618 | }; | ||
| 619 | |||
| 620 | Step | ||
| 621 | drrl_eofb = { | ||
| 622 | .shortname = "drrl-eofb", | ||
| 623 | .name = "DR on R/L without breaking EO on F/B", | ||
| 624 | |||
| 625 | .final = false, | ||
| 626 | .is_done = check_drud, | ||
| 627 | .estimate = estimate_drud_eofb, | ||
| 628 | .ready = check_eofb, | ||
| 629 | .ready_msg = check_eo_msg, | ||
| 630 | .is_valid = validate_singlecw_ending, | ||
| 631 | .moveset = &moveset_eofb, | ||
| 632 | |||
| 633 | .pre_trans = rf, | ||
| 634 | |||
| 635 | .tables = {&pd_drud_eofb}, | ||
| 636 | .ntables = 1, | ||
| 637 | }; | ||
| 638 | |||
| 639 | Step | ||
| 640 | drud_eorl = { | ||
| 641 | .shortname = "drud-eorl", | ||
| 642 | .name = "DR on U/D without breaking EO on R/L", | ||
| 643 | |||
| 644 | .final = false, | ||
| 645 | .is_done = check_drud, | ||
| 646 | .estimate = estimate_drud_eofb, | ||
| 647 | .ready = check_eofb, | ||
| 648 | .ready_msg = check_eo_msg, | ||
| 649 | .is_valid = validate_singlecw_ending, | ||
| 650 | .moveset = &moveset_eofb, | ||
| 651 | |||
| 652 | .pre_trans = ur, | ||
| 653 | |||
| 654 | .tables = {&pd_drud_eofb}, | ||
| 655 | .ntables = 1, | ||
| 656 | }; | ||
| 657 | |||
| 658 | Step | ||
| 659 | drfb_eorl = { | ||
| 660 | .shortname = "drfb-eorl", | ||
| 661 | .name = "DR on F/B without breaking EO on R/L", | ||
| 662 | |||
| 663 | .final = false, | ||
| 664 | .is_done = check_drud, | ||
| 665 | .estimate = estimate_drud_eofb, | ||
| 666 | .ready = check_eofb, | ||
| 667 | .ready_msg = check_eo_msg, | ||
| 668 | .is_valid = validate_singlecw_ending, | ||
| 669 | .moveset = &moveset_eofb, | ||
| 670 | |||
| 671 | .pre_trans = fr, | ||
| 672 | |||
| 673 | .tables = {&pd_drud_eofb}, | ||
| 674 | .ntables = 1, | ||
| 675 | }; | ||
| 676 | |||
| 677 | Step | ||
| 678 | drfb_eoud = { | ||
| 679 | .shortname = "drfb-eoud", | ||
| 680 | .name = "DR on F/B without breaking EO on U/D", | ||
| 681 | |||
| 682 | .final = false, | ||
| 683 | .is_done = check_drud, | ||
| 684 | .estimate = estimate_drud_eofb, | ||
| 685 | .ready = check_eofb, | ||
| 686 | .ready_msg = check_eo_msg, | ||
| 687 | .is_valid = validate_singlecw_ending, | ||
| 688 | .moveset = &moveset_eofb, | ||
| 689 | |||
| 690 | .pre_trans = fd, | ||
| 691 | |||
| 692 | .tables = {&pd_drud_eofb}, | ||
| 693 | .ntables = 1, | ||
| 694 | }; | ||
| 695 | |||
| 696 | Step | ||
| 697 | drrl_eoud = { | ||
| 698 | .shortname = "drrl-eoud", | ||
| 699 | .name = "DR on R/L without breaking EO on U/D", | ||
| 700 | |||
| 701 | .final = false, | ||
| 702 | .is_done = check_drud, | ||
| 703 | .estimate = estimate_drud_eofb, | ||
| 704 | .ready = check_eofb, | ||
| 705 | .ready_msg = check_eo_msg, | ||
| 706 | .is_valid = validate_singlecw_ending, | ||
| 707 | .moveset = &moveset_eofb, | ||
| 708 | |||
| 709 | .pre_trans = rd, | ||
| 710 | |||
| 711 | .tables = {&pd_drud_eofb}, | ||
| 712 | .ntables = 1, | ||
| 713 | }; | ||
| 714 | |||
| 715 | /* DR finish steps */ | ||
| 716 | Step | ||
| 717 | dranyfin_DR = { | ||
| 718 | .shortname = "drfin", | ||
| 719 | .name = "DR finish on any axis without breaking DR", | ||
| 720 | |||
| 721 | .final = true, | ||
| 722 | .is_done = is_solved, | ||
| 723 | .estimate = estimate_drudfin_drud, | ||
| 724 | .ready = check_drud, | ||
| 725 | .ready_msg = check_drany_msg, | ||
| 726 | .is_valid = always_valid, | ||
| 727 | .moveset = &moveset_drud, | ||
| 728 | |||
| 729 | .detect = detect_pretrans_drud, | ||
| 730 | |||
| 731 | .tables = {&pd_drudfin_noE_sym16_drud}, | ||
| 732 | .ntables = 1, | ||
| 733 | }; | ||
| 734 | |||
| 735 | Step | ||
| 736 | drudfin_drud = { | ||
| 737 | .shortname = "drudfin", | ||
| 738 | .name = "DR finish on U/D without breaking DR", | ||
| 739 | |||
| 740 | .final = true, | ||
| 741 | .is_done = is_solved, | ||
| 742 | .estimate = estimate_drudfin_drud, | ||
| 743 | .ready = check_drud, | ||
| 744 | .ready_msg = check_dr_msg, | ||
| 745 | .is_valid = always_valid, | ||
| 746 | .moveset = &moveset_drud, | ||
| 747 | |||
| 748 | .pre_trans = uf, | ||
| 749 | |||
| 750 | .tables = {&pd_drudfin_noE_sym16_drud}, | ||
| 751 | .ntables = 1, | ||
| 752 | }; | ||
| 753 | |||
| 754 | Step | ||
| 755 | drrlfin_drrl = { | ||
| 756 | .shortname = "drrlfin", | ||
| 757 | .name = "DR finish on R/L without breaking DR", | ||
| 758 | |||
| 759 | .final = true, | ||
| 760 | .is_done = is_solved, | ||
| 761 | .estimate = estimate_drudfin_drud, | ||
| 762 | .ready = check_drud, | ||
| 763 | .ready_msg = check_dr_msg, | ||
| 764 | .is_valid = always_valid, | ||
| 765 | .moveset = &moveset_drud, | ||
| 766 | |||
| 767 | .pre_trans = rf, | ||
| 768 | |||
| 769 | .tables = {&pd_drudfin_noE_sym16_drud}, | ||
| 770 | .ntables = 1, | ||
| 771 | }; | ||
| 772 | |||
| 773 | Step | ||
| 774 | drfbfin_drfb = { | ||
| 775 | .shortname = "drfbfin", | ||
| 776 | .name = "DR finish on F/B without breaking DR", | ||
| 777 | |||
| 778 | .final = true, | ||
| 779 | .is_done = is_solved, | ||
| 780 | .estimate = estimate_drudfin_drud, | ||
| 781 | .ready = check_drud, | ||
| 782 | .ready_msg = check_dr_msg, | ||
| 783 | .is_valid = always_valid, | ||
| 784 | .moveset = &moveset_drud, | ||
| 785 | |||
| 786 | .pre_trans = fd, | ||
| 787 | |||
| 788 | .tables = {&pd_drudfin_noE_sym16_drud}, | ||
| 789 | .ntables = 1, | ||
| 790 | }; | ||
| 791 | |||
| 792 | /* HTR from DR */ | ||
| 793 | Step | ||
| 794 | htr_any = { | ||
| 795 | .shortname = "htr", | ||
| 796 | .name = "HTR from DR", | ||
| 797 | |||
| 798 | .final = false, | ||
| 799 | .is_done = check_htr, | ||
| 800 | .estimate = estimate_htr_drud, | ||
| 801 | .ready = check_drud, | ||
| 802 | .ready_msg = check_drany_msg, | ||
| 803 | .is_valid = validate_singlecw_ending, | ||
| 804 | .moveset = &moveset_drud, | ||
| 805 | |||
| 806 | .detect = detect_pretrans_drud, | ||
| 807 | |||
| 808 | .tables = {&pd_htr_drud}, | ||
| 809 | .ntables = 1, | ||
| 810 | }; | ||
| 811 | |||
| 812 | Step | ||
| 813 | htr_drud = { | ||
| 814 | .shortname = "htr-drud", | ||
| 815 | .name = "HTR from DR on U/D", | ||
| 816 | |||
| 817 | .final = false, | ||
| 818 | .is_done = check_htr, | ||
| 819 | .estimate = estimate_htr_drud, | ||
| 820 | .ready = check_drud, | ||
| 821 | .ready_msg = check_dr_msg, | ||
| 822 | .is_valid = validate_singlecw_ending, | ||
| 823 | .moveset = &moveset_drud, | ||
| 824 | |||
| 825 | .pre_trans = uf, | ||
| 826 | |||
| 827 | .tables = {&pd_htr_drud}, | ||
| 828 | .ntables = 1, | ||
| 829 | }; | ||
| 830 | |||
| 831 | Step | ||
| 832 | htr_drrl = { | ||
| 833 | .shortname = "htr-drrl", | ||
| 834 | .name = "HTR from DR on R/L", | ||
| 835 | |||
| 836 | .final = false, | ||
| 837 | .is_done = check_htr, | ||
| 838 | .estimate = estimate_htr_drud, | ||
| 839 | .ready = check_drud, | ||
| 840 | .ready_msg = check_dr_msg, | ||
| 841 | .is_valid = validate_singlecw_ending, | ||
| 842 | .moveset = &moveset_drud, | ||
| 843 | |||
| 844 | .pre_trans = rf, | ||
| 845 | |||
| 846 | .tables = {&pd_htr_drud}, | ||
| 847 | .ntables = 1, | ||
| 848 | }; | ||
| 849 | |||
| 850 | Step | ||
| 851 | htr_drfb = { | ||
| 852 | .shortname = "htr-drfb", | ||
| 853 | .name = "HTR from DR on F/B", | ||
| 854 | |||
| 855 | .final = false, | ||
| 856 | .is_done = check_htr, | ||
| 857 | .estimate = estimate_htr_drud, | ||
| 858 | .ready = check_drud, | ||
| 859 | .ready_msg = check_dr_msg, | ||
| 860 | .is_valid = validate_singlecw_ending, | ||
| 861 | .moveset = &moveset_drud, | ||
| 862 | |||
| 863 | .pre_trans = fd, | ||
| 864 | |||
| 865 | .tables = {&pd_htr_drud}, | ||
| 866 | .ntables = 1, | ||
| 867 | }; | ||
| 868 | |||
| 869 | /* HTR finish */ | ||
| 870 | Step | ||
| 871 | htrfin_htr = { | ||
| 872 | .shortname = "htrfin", | ||
| 873 | .name = "HTR finish without breaking HTR", | ||
| 874 | |||
| 875 | .final = true, | ||
| 876 | .is_done = is_solved, | ||
| 877 | .estimate = estimate_htrfin_htr, | ||
| 878 | .ready = check_htr, | ||
| 879 | .ready_msg = check_htr_msg, | ||
| 880 | .is_valid = always_valid, | ||
| 881 | .moveset = &moveset_htr, | ||
| 882 | |||
| 883 | .pre_trans = uf, | ||
| 884 | |||
| 885 | .tables = {&pd_htrfin_htr}, | ||
| 886 | .ntables = 1, | ||
| 887 | }; | ||
| 888 | |||
| 889 | Step *steps[] = { | ||
| 890 | &optimal_HTM, /* first is default */ | ||
| 891 | &optimal_light_HTM, | ||
| 892 | |||
| 893 | &eofin_eo, | ||
| 894 | &eofbfin_eofb, | ||
| 895 | &eorlfin_eorl, | ||
| 896 | &eoudfin_eoud, | ||
| 897 | |||
| 898 | &eoany_HTM, | ||
| 899 | &eofb_HTM, | ||
| 900 | &eorl_HTM, | ||
| 901 | &eoud_HTM, | ||
| 902 | |||
| 903 | &coany_HTM, | ||
| 904 | &coud_HTM, | ||
| 905 | &corl_HTM, | ||
| 906 | &cofb_HTM, | ||
| 907 | |||
| 908 | &coany_URF, | ||
| 909 | &coud_URF, | ||
| 910 | &corl_URF, | ||
| 911 | &cofb_URF, | ||
| 912 | |||
| 913 | &drany_HTM, | ||
| 914 | &drud_HTM, | ||
| 915 | &drrl_HTM, | ||
| 916 | &drfb_HTM, | ||
| 917 | |||
| 918 | &dr_eo, | ||
| 919 | &dr_eofb, | ||
| 920 | &dr_eorl, | ||
| 921 | &dr_eoud, | ||
| 922 | &drud_eofb, | ||
| 923 | &drrl_eofb, | ||
| 924 | &drud_eorl, | ||
| 925 | &drfb_eorl, | ||
| 926 | &drfb_eoud, | ||
| 927 | &drrl_eoud, | ||
| 928 | |||
| 929 | &dranyfin_DR, | ||
| 930 | &drudfin_drud, | ||
| 931 | &drrlfin_drrl, | ||
| 932 | &drfbfin_drfb, | ||
| 933 | |||
| 934 | &htr_any, | ||
| 935 | &htr_drud, | ||
| 936 | &htr_drrl, | ||
| 937 | &htr_drfb, | ||
| 938 | |||
| 939 | &htrfin_htr, | ||
| 940 | |||
| 941 | &cornershtr_HTM, | ||
| 942 | &cornershtr_URF, | ||
| 943 | &corners_HTM, | ||
| 944 | &corners_URF, | ||
| 945 | |||
| 946 | NULL | ||
| 947 | }; | ||
| 948 | |||
| 949 | /* Checkers and validators ***************************************************/ | ||
| 950 | |||
| 951 | static bool | ||
| 952 | check_centers(Cube cube) | ||
| 953 | { | ||
| 954 | return cube.cpos == 0; | ||
| 955 | } | ||
| 956 | |||
| 957 | static bool | ||
| 958 | check_coud_HTM(Cube cube) | ||
| 959 | { | ||
| 960 | return cube.coud == 0; | ||
| 961 | } | ||
| 962 | |||
| 963 | static bool | ||
| 964 | check_coud_URF(Cube cube) | ||
| 965 | { | ||
| 966 | Cube c2, c3; | ||
| 967 | |||
| 968 | c2 = apply_move(z, cube); | ||
| 969 | c3 = apply_move(x, cube); | ||
| 970 | |||
| 971 | return cube.coud == 0 || c2.coud == 0 || c3.coud == 0; | ||
| 972 | } | ||
| 973 | |||
| 974 | static bool | ||
| 975 | check_corners_URF(Cube cube) | ||
| 976 | { | ||
| 977 | Cube c; | ||
| 978 | Trans i; | ||
| 979 | |||
| 980 | for (i = 0; i < NROTATIONS; i++) { | ||
| 981 | c = apply_alg(rotation_alg(i), cube); | ||
| 982 | if (c.cp && c.coud) | ||
| 983 | return true; | ||
| 984 | } | ||
| 985 | |||
| 986 | return false; | ||
| 987 | } | ||
| 988 | |||
| 989 | static bool | ||
| 990 | check_corners_HTM(Cube cube) | ||
| 991 | { | ||
| 992 | return cube.cp == 0 && cube.coud == 0; | ||
| 993 | } | ||
| 994 | |||
| 995 | static bool | ||
| 996 | check_cornershtr(Cube cube) | ||
| 997 | { | ||
| 998 | return coord_cornershtr.index(cube) == 0; | ||
| 999 | } | ||
| 1000 | |||
| 1001 | static bool | ||
| 1002 | check_eofb(Cube cube) | ||
| 1003 | { | ||
| 1004 | return cube.eofb == 0; | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | static bool | ||
| 1008 | check_drud(Cube cube) | ||
| 1009 | { | ||
| 1010 | return cube.eofb == 0 && cube.eorl == 0 && cube.coud == 0; | ||
| 1011 | } | ||
| 1012 | |||
| 1013 | static bool | ||
| 1014 | check_htr(Cube cube) | ||
| 1015 | { | ||
| 1016 | return check_drud(cube) && coord_htr_drud.index(cube) == 0; | ||
| 1017 | } | ||
| 1018 | |||
| 1019 | static bool | ||
| 1020 | always_valid(Alg *alg) | ||
| 1021 | { | ||
| 1022 | return true; | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | static bool | ||
| 1026 | validate_singlecw_ending(Alg *alg) | ||
| 1027 | { | ||
| 1028 | int i; | ||
| 1029 | bool nor, inv; | ||
| 1030 | Move l2 = NULLMOVE, l1 = NULLMOVE, l2i = NULLMOVE, l1i = NULLMOVE; | ||
| 1031 | |||
| 1032 | for (i = 0; i < alg->len; i++) { | ||
| 1033 | if (alg->inv[i]) { | ||
| 1034 | l2i = l1i; | ||
| 1035 | l1i = alg->move[i]; | ||
| 1036 | } else { | ||
| 1037 | l2 = l1; | ||
| 1038 | l1 = alg->move[i]; | ||
| 1039 | } | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | nor = l1 ==base_move(l1) && (!commute(l1, l2) ||l2 ==base_move(l2)); | ||
| 1043 | inv = l1i==base_move(l1i) && (!commute(l1i,l2i)||l2i==base_move(l2i)); | ||
| 1044 | |||
| 1045 | return nor && inv; | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | /* Public functions **********************************************************/ | ||
| 1049 | |||
| 1050 | void | ||
| 1051 | compute_ind(StepAlt *a, Cube *cube, uint64_t *ind) | ||
| 1052 | { | ||
| 1053 | |||
| 1054 | } | ||
| 1055 | |||
| 1056 | int | ||
| 1057 | estimate_stepalt(StepAlt *a, uint64_t *ind) | ||
| 1058 | { | ||
| 1059 | int i, ret, est[a->n_coord]; | ||
| 1060 | |||
| 1061 | for (i = 0; i < a->n_coord; i++) { | ||
| 1062 | est[i] = ptableval(a->pd[i], ind[i]); | ||
| 1063 | if (est[i] == 0 && a->compact_pd[i]) | ||
| 1064 | est[i] = ptableval(a->fallback_pd, ind[i] / a->fbmod); | ||
| 1065 | } | ||
| 1066 | |||
| 1067 | for (i = 0; i < a->n_dbtrick; i++) | ||
| 1068 | if (est[a->dbtrick[i][0]] == est[a->dbtrick[i][1]] && | ||
| 1069 | est[a->dbtrick[i][0]] == est[a->dbtrick[i][2]]) | ||
| 1070 | est[a->dbtrick[i][0]] += 1; | ||
| 1071 | |||
| 1072 | for (i = 0, ret = -1; i < a->n_coord; i++) | ||
| 1073 | ret = max(ret, est[i]); | ||
| 1074 | |||
| 1075 | return ret; | ||
| 1076 | } | ||
| 1077 | |||
| 1078 | void | ||
| 1079 | prepare_step(Step *step, SolveOptions *opts) | ||
| 1080 | { | ||
| 1081 | int i, j; | ||
| 1082 | PDGenData pdg; | ||
| 1083 | StepAlt *a; | ||
| 1084 | |||
| 1085 | init_moveset(step->moveset); | ||
| 1086 | pdg.moveset = step->moveset; | ||
| 1087 | |||
| 1088 | for (i = 0; step->alt[i] != NULL; i++) { | ||
| 1089 | a = step->alt[i]; | ||
| 1090 | for (j = 0; j < a->n_coord; j++) { | ||
| 1091 | gen_coord(a->coord[j]); | ||
| 1092 | |||
| 1093 | pdg.coord = a->coord[j]; | ||
| 1094 | pdg.compact = a->compact[j]; | ||
| 1095 | pdg.pd = NULL; | ||
| 1096 | |||
| 1097 | a->pd[j] = genptable(&pdg, opts->nthreads); | ||
| 1098 | |||
| 1099 | if (a->compact_pd[j]) { | ||
| 1100 | gen_coord(a->fallback_coord[j]); | ||
| 1101 | |||
| 1102 | pdg.coord = a->fallback_coord[j]; | ||
| 1103 | pdg.compact = false; | ||
| 1104 | pdg.pd = NULL; | ||
| 1105 | |||
| 1106 | a->fallback_pd[j] = | ||
| 1107 | step->genptable(&pdg, opts->nthreads); | ||
| 1108 | } | ||
| 1109 | } | ||
| 1110 | } | ||
| 1111 | } | ||
