nissy-nx

A Rubik's cube optimal solver
git clone https://git.tronto.net/nissy-nx
Download | Log | Files | Refs | README | LICENSE

commands.h (2017B)


      1 #ifndef COMMANDS_H
      2 #define COMMANDS_H
      3 
      4 #include <time.h>
      5 
      6 #include "solve.h"
      7 #include "solver_nxopt31.h"
      8 #include "threader_single.h"
      9 #include "threader_eager.h"
     10 
     11 void                    free_args(CommandArgs *args);
     12 CommandArgs *           new_args();
     13 
     14 /* Arg parsing functions *****************************************************/
     15 
     16 CommandArgs *           gen_parse_args(int c, char **v);
     17 CommandArgs *           help_parse_args(int c, char **v);
     18 CommandArgs *           parse_only_scramble(int c, char **v);
     19 CommandArgs *           parse_no_arg(int c, char **v);
     20 CommandArgs *           solve_parse_args(int c, char **v);
     21 
     22 /* Exec functions ************************************************************/
     23 
     24 void                    gen_exec(CommandArgs *args);
     25 void                    solve_exec(CommandArgs *args);
     26 void                    help_exec(CommandArgs *args);
     27 void                    quit_exec(CommandArgs *args);
     28 
     29 /* Commands ******************************************************************/
     30 
     31 #ifndef COMMANDS_C
     32 
     33 extern Command gen_cmd;
     34 extern Command help_cmd;
     35 extern Command quit_cmd;
     36 extern Command solve_cmd;
     37 
     38 extern Command *commands[];
     39 
     40 #else
     41 
     42 Command
     43 solve_cmd = {
     44 	.name        = "solve",
     45 	.usage       = "solve [OPTIONS] SCRAMBLE",
     46 	.description = "Solve the cube",
     47 	.parse_args  = solve_parse_args,
     48 	.exec        = solve_exec
     49 };
     50 
     51 Command
     52 gen_cmd = {
     53 	.name        = "gen",
     54 	.usage       = "gen [-t N]",
     55 	.description = "Generate all tables [using N threads]",
     56 	.parse_args  = gen_parse_args,
     57 	.exec        = gen_exec
     58 };
     59 
     60 Command
     61 help_cmd = {
     62 	.name        = "help",
     63 	.usage       = "help [COMMAND]",
     64 	.description = "Display nissy manual page or help on specific command",
     65 	.parse_args  = help_parse_args,
     66 	.exec        = help_exec,
     67 };
     68 
     69 Command
     70 quit_cmd = {
     71 	.name        = "quit",
     72 	.usage       = "quit",
     73 	.description = "Quit nissy",
     74 	.parse_args  = parse_no_arg,
     75 	.exec        = quit_exec,
     76 };
     77 
     78 Command *commands[] = {
     79 	&gen_cmd,
     80 	&help_cmd,
     81 	&quit_cmd,
     82 	&solve_cmd,
     83 	NULL
     84 };
     85 
     86 #endif
     87 
     88 #endif