diff options
Diffstat (limited to 'src/commands.c')
| -rw-r--r-- | src/commands.c | 71 |
1 files changed, 48 insertions, 23 deletions
diff --git a/src/commands.c b/src/commands.c index 03eded0..6bfc7b7 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -169,7 +169,7 @@ Command *commands[] = { | |||
| 169 | 169 | ||
| 170 | /* Other constants ***********************************************************/ | 170 | /* Other constants ***********************************************************/ |
| 171 | 171 | ||
| 172 | char *scrtypes[20] = { "eo", "corners", "edges", "fmc", NULL }; | 172 | char *scrtypes[20] = { "eo", "corners", "edges", "fmc", "dr", "htr", NULL }; |
| 173 | 173 | ||
| 174 | /* Arg parsing functions implementation **************************************/ | 174 | /* Arg parsing functions implementation **************************************/ |
| 175 | 175 | ||
| @@ -401,6 +401,7 @@ scramble_exec(CommandArgs *args) | |||
| 401 | Cube cube; | 401 | Cube cube; |
| 402 | Alg *scr, *ruf, *aux; | 402 | Alg *scr, *ruf, *aux; |
| 403 | int i, j, eo, ep, co, cp, a[12]; | 403 | int i, j, eo, ep, co, cp, a[12]; |
| 404 | uint64_t ui, uj; | ||
| 404 | 405 | ||
| 405 | init_all_movesets(); | 406 | init_all_movesets(); |
| 406 | init_symcoord(); | 407 | init_symcoord(); |
| @@ -408,32 +409,56 @@ scramble_exec(CommandArgs *args) | |||
| 408 | srand(time(NULL)); | 409 | srand(time(NULL)); |
| 409 | 410 | ||
| 410 | for (i = 0; i < args->n; i++) { | 411 | for (i = 0; i < args->n; i++) { |
| 411 | eo = rand() % POW2TO11; | ||
| 412 | ep = rand() % FACTORIAL12; | ||
| 413 | co = rand() % POW3TO7; | ||
| 414 | cp = rand() % FACTORIAL8; | ||
| 415 | 412 | ||
| 416 | if (!strcmp(args->scrtype, "eo")) { | 413 | if (!strcmp(args->scrtype, "dr")) { |
| 417 | eo = 0; | 414 | /* Warning: cube is inconsistent because of side CO * |
| 418 | } else if (!strcmp(args->scrtype, "corners")) { | 415 | * and EO on U/D. But solve_2phase only solves drfin * |
| 419 | eo = 0; | 416 | * in this case, so it should be ok. * |
| 420 | ep = 0; | 417 | * TODO: check this properly * |
| 421 | index_to_perm(cp, 8, a); | 418 | * Moreover we again need to fix parity after * |
| 422 | if (perm_sign(a, 8) == 1) { | 419 | * generating epose manually */ |
| 423 | swap(&a[0], &a[1]); | 420 | do { |
| 424 | cp = perm_to_index(a, 8); | 421 | ui = rand() % coord_drudfin_noE_sym16.max; |
| 425 | } | 422 | uj = rand() % FACTORIAL4; |
| 426 | } else if (!strcmp(args->scrtype, "edges")) { | 423 | cube = coord_drudfin_noE_sym16.cube(ui); |
| 427 | co = 0; | 424 | cube.epose += uj; |
| 428 | cp = 0; | 425 | } while (!is_admissible(cube)); |
| 429 | index_to_perm(ep, 12, a); | 426 | } else if (!strcmp(args->scrtype, "htr")) { |
| 430 | if (perm_sign(a, 12) == 1) { | 427 | /* antindex_htrfin() returns a consistent * |
| 431 | swap(&a[0], &a[1]); | 428 | * cube, except possibly for parity */ |
| 432 | ep = perm_to_index(a, 12); | 429 | do { |
| 430 | ui = rand() % coord_htrfin.max; | ||
| 431 | cube = coord_htrfin.cube(ui); | ||
| 432 | } while (!is_admissible(cube)); | ||
| 433 | } else { | ||
| 434 | eo = rand() % POW2TO11; | ||
| 435 | ep = rand() % FACTORIAL12; | ||
| 436 | co = rand() % POW3TO7; | ||
| 437 | cp = rand() % FACTORIAL8; | ||
| 438 | |||
| 439 | if (!strcmp(args->scrtype, "eo")) { | ||
| 440 | eo = 0; | ||
| 441 | } else if (!strcmp(args->scrtype, "corners")) { | ||
| 442 | eo = 0; | ||
| 443 | ep = 0; | ||
| 444 | index_to_perm(cp, 8, a); | ||
| 445 | if (perm_sign(a, 8) == 1) { | ||
| 446 | swap(&a[0], &a[1]); | ||
| 447 | cp = perm_to_index(a, 8); | ||
| 448 | } | ||
| 449 | } else if (!strcmp(args->scrtype, "edges")) { | ||
| 450 | co = 0; | ||
| 451 | cp = 0; | ||
| 452 | index_to_perm(ep, 12, a); | ||
| 453 | if (perm_sign(a, 12) == 1) { | ||
| 454 | swap(&a[0], &a[1]); | ||
| 455 | ep = perm_to_index(a, 12); | ||
| 456 | } | ||
| 433 | } | 457 | } |
| 458 | cube = fourval_to_cube(eo, ep, co, cp); | ||
| 434 | } | 459 | } |
| 435 | 460 | ||
| 436 | cube = fourval_to_cube(eo, ep, co, cp); | 461 | /* TODO: can be optimized for htr and dr using htrfin, drfin */ |
| 437 | scr = solve_2phase(cube, 1); | 462 | scr = solve_2phase(cube, 1); |
| 438 | 463 | ||
| 439 | if (!strcmp(args->scrtype, "fmc")) { | 464 | if (!strcmp(args->scrtype, "fmc")) { |
