aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md4
-rw-r--r--doc/nissy.14
-rw-r--r--src/commands.c71
-rw-r--r--src/cube.c2
-rw-r--r--src/solve.c8
5 files changed, 61 insertions, 28 deletions
diff --git a/TODO.md b/TODO.md
index f3fb075..a21c903 100644
--- a/TODO.md
+++ b/TODO.md
@@ -56,10 +56,6 @@ including e.g. solutions that were not shown because -c)
56## Technical stuff 56## Technical stuff
57 57
58### Memory management 58### Memory management
59* Optimization: allow coordinates do define how moves and trans are applied on
60 them; if not then just move the cube normally.
61 This can speedup things, for example in computing coordinates (no need to apply
62 trans_to_rep) and of course in optimal solver.
63* free pruning table after solve is done? if I do this I need to deafault to a 59* free pruning table after solve is done? if I do this I need to deafault to a
64 small table for < 8 moves solutions or smth 60 small table for < 8 moves solutions or smth
65* improve multi-threading when solving multiple scrambles 61* improve multi-threading when solving multiple scrambles
diff --git a/doc/nissy.1 b/doc/nissy.1
index 25c6ef2..124df9b 100644
--- a/doc/nissy.1
+++ b/doc/nissy.1
@@ -92,6 +92,8 @@ can be specified to be one of the following:
92.Bl -tag -width Ds 92.Bl -tag -width Ds
93.It Ar corners 93.It Ar corners
94Scramble with solved edges (only cornes are scrambled). 94Scramble with solved edges (only cornes are scrambled).
95.It Ar dr
96Scramble with solved DR on U/D.
95.It Ar edges 97.It Ar edges
96Scramble with solved corners (only edges are scrambled). 98Scramble with solved corners (only edges are scrambled).
97.It Ar eo 99.It Ar eo
@@ -99,6 +101,8 @@ Scramble with solved EO on F/B axis.
99.It Ar fmc 101.It Ar fmc
100Scramble the full cube and the resulting scramble starts and ends with 102Scramble the full cube and the resulting scramble starts and ends with
101the moves R\(aq U\(aq F. 103the moves R\(aq U\(aq F.
104.It Ar htr
105Scramble with HTR solved.
102.El 106.El
103. 107.
104.It Nm solve Ar step Oo Ar options Oc Ar scramble 108.It Nm solve Ar step Oo Ar options Oc Ar scramble
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
172char *scrtypes[20] = { "eo", "corners", "edges", "fmc", NULL }; 172char *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")) {
diff --git a/src/cube.c b/src/cube.c
index 803fefd..0ed862f 100644
--- a/src/cube.c
+++ b/src/cube.c
@@ -413,6 +413,8 @@ is_admissible(Cube cube) {
413 perm_sign(a->cp, 8) + 413 perm_sign(a->cp, 8) +
414 perm_sign(a->cpos, 6); 414 perm_sign(a->cpos, 6);
415 415
416 free_cubearray(a, pf_all);
417
416 return perm && parity % 2 == 0; 418 return perm && parity % 2 == 0;
417} 419}
418 420
diff --git a/src/solve.c b/src/solve.c
index 587bbc8..d4c0f18 100644
--- a/src/solve.c
+++ b/src/solve.c
@@ -466,7 +466,13 @@ solve_2phase(Cube cube, int nthreads)
466 opts2.can_niss = false; 466 opts2.can_niss = false;
467 opts2.verbose = false; 467 opts2.verbose = false;
468 468
469 sols1 = solve(cube, &drany_HTM, &opts1); 469 /* We skip step1 if it is solved on any axis */
470 if (drany_HTM.is_done(cube)) {
471 sols1 = new_alglist();
472 append_alg(sols1, new_alg(""));
473 } else {
474 sols1 = solve(cube, &drany_HTM, &opts1);
475 }
470 bestalg = new_alg(""); 476 bestalg = new_alg("");
471 bestlen = 999; 477 bestlen = 999;
472 for (i = sols1->first; i != NULL; i = i->next) { 478 for (i = sols1->first; i != NULL; i = i->next) {

Generated with cgit - Back to sebastiano.tronto.net