diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-26 19:38:28 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-26 19:38:28 +0100 |
| commit | 975e3eafbae15b93a1a4f160dd781d359a6c717b (patch) | |
| tree | dc6b05fcb57a64014c260ce43baa222386e5140f /src/commands.c | |
| parent | b82df53eb461506984eb2b6a9b53e445b75e46af (diff) | |
| download | nissy-975e3eafbae15b93a1a4f160dd781d359a6c717b.tar.gz nissy-975e3eafbae15b93a1a4f160dd781d359a6c717b.zip | |
Added two-phase solver
Diffstat (limited to 'src/commands.c')
| -rw-r--r-- | src/commands.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/commands.c b/src/commands.c index 56ff944..02af19f 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -2,12 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | /* Arg parsing functions *****************************************************/ | 3 | /* Arg parsing functions *****************************************************/ |
| 4 | 4 | ||
| 5 | CommandArgs * solve_parse_args(int c, char **v); | ||
| 6 | CommandArgs * gen_parse_args(int c, char **v); | 5 | CommandArgs * gen_parse_args(int c, char **v); |
| 7 | CommandArgs * help_parse_args(int c, char **v); | 6 | CommandArgs * help_parse_args(int c, char **v); |
| 8 | CommandArgs * print_parse_args(int c, char **v); | 7 | CommandArgs * print_parse_args(int c, char **v); |
| 9 | CommandArgs * parse_only_scramble(int c, char **v); | 8 | CommandArgs * parse_only_scramble(int c, char **v); |
| 10 | CommandArgs * parse_no_arg(int c, char **v); | 9 | CommandArgs * parse_no_arg(int c, char **v); |
| 10 | CommandArgs * solve_parse_args(int c, char **v); | ||
| 11 | 11 | ||
| 12 | /* Exec functions ************************************************************/ | 12 | /* Exec functions ************************************************************/ |
| 13 | 13 | ||
| @@ -17,6 +17,7 @@ static void solve_exec(CommandArgs *args); | |||
| 17 | static void steps_exec(CommandArgs *args); | 17 | static void steps_exec(CommandArgs *args); |
| 18 | static void commands_exec(CommandArgs *args); | 18 | static void commands_exec(CommandArgs *args); |
| 19 | static void print_exec(CommandArgs *args); | 19 | static void print_exec(CommandArgs *args); |
| 20 | static void twophase_exec(CommandArgs *args); | ||
| 20 | static void help_exec(CommandArgs *args); | 21 | static void help_exec(CommandArgs *args); |
| 21 | static void quit_exec(CommandArgs *args); | 22 | static void quit_exec(CommandArgs *args); |
| 22 | static void unniss_exec(CommandArgs *args); | 23 | static void unniss_exec(CommandArgs *args); |
| @@ -93,6 +94,15 @@ help_cmd = { | |||
| 93 | }; | 94 | }; |
| 94 | 95 | ||
| 95 | Command | 96 | Command |
| 97 | twophase_cmd = { | ||
| 98 | .name = "twophase", | ||
| 99 | .usage = "twophase", | ||
| 100 | .description = "Find a solution quickly using a 2-phase method", | ||
| 101 | .parse_args = parse_only_scramble, | ||
| 102 | .exec = twophase_exec, | ||
| 103 | }; | ||
| 104 | |||
| 105 | Command | ||
| 96 | quit_cmd = { | 106 | quit_cmd = { |
| 97 | .name = "quit", | 107 | .name = "quit", |
| 98 | .usage = "quit", | 108 | .usage = "quit", |
| @@ -128,6 +138,7 @@ Command *commands[NCOMMANDS] = { | |||
| 128 | &quit_cmd, | 138 | &quit_cmd, |
| 129 | &solve_cmd, | 139 | &solve_cmd, |
| 130 | &steps_cmd, | 140 | &steps_cmd, |
| 141 | &twophase_cmd, | ||
| 131 | &unniss_cmd, | 142 | &unniss_cmd, |
| 132 | &version_cmd, | 143 | &version_cmd, |
| 133 | }; | 144 | }; |
| @@ -384,6 +395,22 @@ print_exec(CommandArgs *args) | |||
| 384 | } | 395 | } |
| 385 | 396 | ||
| 386 | static void | 397 | static void |
| 398 | twophase_exec(CommandArgs *args) | ||
| 399 | { | ||
| 400 | Cube c; | ||
| 401 | Alg *sol; | ||
| 402 | |||
| 403 | init_movesets(); | ||
| 404 | init_symcoord(); | ||
| 405 | |||
| 406 | c = apply_alg(args->scramble, (Cube){0}); | ||
| 407 | sol = solve_2phase(c, 1); | ||
| 408 | |||
| 409 | print_alg(sol, false); | ||
| 410 | free_alg(sol); | ||
| 411 | } | ||
| 412 | |||
| 413 | static void | ||
| 387 | help_exec(CommandArgs *args) | 414 | help_exec(CommandArgs *args) |
| 388 | { | 415 | { |
| 389 | if (args->command == NULL) { | 416 | if (args->command == NULL) { |
