diff options
Diffstat (limited to '')
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | doc/nissy.1 | 7 | ||||
| -rw-r--r-- | src/commands.c | 48 | ||||
| -rw-r--r-- | src/cubetypes.h | 1 | ||||
| -rw-r--r-- | src/pruning.c | 5 |
5 files changed, 61 insertions, 1 deletions
| @@ -1,4 +1,5 @@ | |||
| 1 | doc/*.html | 1 | doc/*.html |
| 2 | doc/*.pdf | 2 | doc/*.pdf |
| 3 | experiments | ||
| 3 | nissy | 4 | nissy |
| 4 | nissy-* | 5 | nissy-* |
diff --git a/doc/nissy.1 b/doc/nissy.1 index 138d6ae..c467a2b 100644 --- a/doc/nissy.1 +++ b/doc/nissy.1 | |||
| @@ -81,6 +81,13 @@ Invert the given scramble. | |||
| 81 | Display a text-only description of the cube obtained after applying | 81 | Display a text-only description of the cube obtained after applying |
| 82 | .Ar scramble . | 82 | .Ar scramble . |
| 83 | . | 83 | . |
| 84 | .It Nm ptable Op Ar table | ||
| 85 | Display information, such as the table distribution, on a pruning table. | ||
| 86 | If no | ||
| 87 | .Ar table | ||
| 88 | is given, the available pruning tables are listed. | ||
| 89 | This command is intended for advanced use only. | ||
| 90 | . | ||
| 84 | .It Nm quit | 91 | .It Nm quit |
| 85 | Quit nissy. | 92 | Quit nissy. |
| 86 | . | 93 | . |
diff --git a/src/commands.c b/src/commands.c index 78d7583..f01edfd 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -6,6 +6,7 @@ CommandArgs * gen_parse_args(int c, char **v); | |||
| 6 | CommandArgs * help_parse_args(int c, char **v); | 6 | CommandArgs * help_parse_args(int c, char **v); |
| 7 | CommandArgs * parse_only_scramble(int c, char **v); | 7 | CommandArgs * parse_only_scramble(int c, char **v); |
| 8 | CommandArgs * parse_no_arg(int c, char **v); | 8 | CommandArgs * parse_no_arg(int c, char **v); |
| 9 | CommandArgs * ptable_parse_args(int c, char **v); | ||
| 9 | CommandArgs * solve_parse_args(int c, char **v); | 10 | CommandArgs * solve_parse_args(int c, char **v); |
| 10 | CommandArgs * scramble_parse_args(int c, char **v); | 11 | CommandArgs * scramble_parse_args(int c, char **v); |
| 11 | 12 | ||
| @@ -20,6 +21,7 @@ static void steps_exec(CommandArgs *args); | |||
| 20 | static void commands_exec(CommandArgs *args); | 21 | static void commands_exec(CommandArgs *args); |
| 21 | static void freemem_exec(CommandArgs *args); | 22 | static void freemem_exec(CommandArgs *args); |
| 22 | static void print_exec(CommandArgs *args); | 23 | static void print_exec(CommandArgs *args); |
| 24 | static void ptable_exec(CommandArgs *args); | ||
| 23 | static void twophase_exec(CommandArgs *args); | 25 | static void twophase_exec(CommandArgs *args); |
| 24 | static void help_exec(CommandArgs *args); | 26 | static void help_exec(CommandArgs *args); |
| 25 | static void quit_exec(CommandArgs *args); | 27 | static void quit_exec(CommandArgs *args); |
| @@ -107,6 +109,15 @@ print_cmd = { | |||
| 107 | }; | 109 | }; |
| 108 | 110 | ||
| 109 | Command | 111 | Command |
| 112 | ptable_cmd = { | ||
| 113 | .name = "ptable", | ||
| 114 | .usage = "ptable [TABLE]", | ||
| 115 | .description = "Print information on pruning tables", | ||
| 116 | .parse_args = ptable_parse_args, | ||
| 117 | .exec = ptable_exec, | ||
| 118 | }; | ||
| 119 | |||
| 120 | Command | ||
| 110 | help_cmd = { | 121 | help_cmd = { |
| 111 | .name = "help", | 122 | .name = "help", |
| 112 | .usage = "help [COMMAND]", | 123 | .usage = "help [COMMAND]", |
| @@ -167,6 +178,7 @@ Command *commands[] = { | |||
| 167 | &help_cmd, | 178 | &help_cmd, |
| 168 | &invert_cmd, | 179 | &invert_cmd, |
| 169 | &print_cmd, | 180 | &print_cmd, |
| 181 | &ptable_cmd, | ||
| 170 | &quit_cmd, | 182 | &quit_cmd, |
| 171 | &solve_cmd, | 183 | &solve_cmd, |
| 172 | &scramble_cmd, | 184 | &scramble_cmd, |
| @@ -384,6 +396,24 @@ parse_no_arg(int c, char **v) | |||
| 384 | return a; | 396 | return a; |
| 385 | } | 397 | } |
| 386 | 398 | ||
| 399 | CommandArgs * | ||
| 400 | ptable_parse_args(int c, char **v) | ||
| 401 | { | ||
| 402 | int i; | ||
| 403 | CommandArgs *a = new_args(); | ||
| 404 | |||
| 405 | if (c == 1) { | ||
| 406 | for (i = 0; all_pd[i] != NULL; i++) | ||
| 407 | if (!strcmp(v[0], all_pd[i]->filename)) | ||
| 408 | a->pd = all_pd[i]; | ||
| 409 | if (a->pd == NULL) | ||
| 410 | fprintf(stderr, "%s: pruning table not found\n", v[0]); | ||
| 411 | } | ||
| 412 | |||
| 413 | a->success = c == 0 || (c == 1 && a->pd != NULL); | ||
| 414 | return a; | ||
| 415 | } | ||
| 416 | |||
| 387 | /* Exec functions implementation *********************************************/ | 417 | /* Exec functions implementation *********************************************/ |
| 388 | 418 | ||
| 389 | static void | 419 | static void |
| @@ -584,6 +614,23 @@ print_exec(CommandArgs *args) | |||
| 584 | } | 614 | } |
| 585 | 615 | ||
| 586 | static void | 616 | static void |
| 617 | ptable_exec(CommandArgs *args) | ||
| 618 | { | ||
| 619 | int i = 0; | ||
| 620 | if (args->pd == NULL) { | ||
| 621 | printf("Available pruning tables:\n"); | ||
| 622 | for (i = 0; all_pd[i] != NULL; i++) | ||
| 623 | printf("\t%s\n", all_pd[i]->filename); | ||
| 624 | printf("Use ptable [TABLE] to see the table distribution" | ||
| 625 | " and other information\n"); | ||
| 626 | } else { | ||
| 627 | genptable(args->pd, args->opts->nthreads); | ||
| 628 | print_ptable(args->pd); | ||
| 629 | } | ||
| 630 | } | ||
| 631 | |||
| 632 | |||
| 633 | static void | ||
| 587 | twophase_exec(CommandArgs *args) | 634 | twophase_exec(CommandArgs *args) |
| 588 | { | 635 | { |
| 589 | Cube c; | 636 | Cube c; |
| @@ -750,6 +797,7 @@ new_args(void) | |||
| 750 | /* step and command are static */ | 797 | /* step and command are static */ |
| 751 | args->step = steps[0]; /* default: first step in list */ | 798 | args->step = steps[0]; /* default: first step in list */ |
| 752 | args->command = NULL; | 799 | args->command = NULL; |
| 800 | args->pd = NULL; | ||
| 753 | 801 | ||
| 754 | return args; | 802 | return args; |
| 755 | } | 803 | } |
diff --git a/src/cubetypes.h b/src/cubetypes.h index ad9c627..66839ca 100644 --- a/src/cubetypes.h +++ b/src/cubetypes.h | |||
| @@ -162,6 +162,7 @@ commandargs | |||
| 162 | char scrtype[20]; | 162 | char scrtype[20]; |
| 163 | bool scrstdin; | 163 | bool scrstdin; |
| 164 | bool header; | 164 | bool header; |
| 165 | PruneData * pd; | ||
| 165 | }; | 166 | }; |
| 166 | 167 | ||
| 167 | struct | 168 | struct |
diff --git a/src/pruning.c b/src/pruning.c index aeeac21..fcb27e5 100644 --- a/src/pruning.c +++ b/src/pruning.c | |||
| @@ -405,7 +405,10 @@ print_ptable(PruneData *pd) | |||
| 405 | printf("Table %s\n", pd->filename); | 405 | printf("Table %s\n", pd->filename); |
| 406 | printf("Base value: %d\n", pd->base); | 406 | printf("Base value: %d\n", pd->base); |
| 407 | for (i = 0; i < 16; i++) | 407 | for (i = 0; i < 16; i++) |
| 408 | printf("%2" PRIu64 "\t%10" PRIu64 "\n", i, pd->count[i]); | 408 | if (pd->count[i] != 0) |
| 409 | printf("%2" PRIu64 "\t%10" PRIu64 "\n", | ||
| 410 | i, pd->count[i]); | ||
| 411 | printf("Total: %" PRIu64 "\n", pd->coord->max); | ||
| 409 | } | 412 | } |
| 410 | 413 | ||
| 411 | uint64_t | 414 | uint64_t |
