nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

commit 7de88d1bcd420447023b8e74b0aa4f5e8ba1df6b
parent 48cd8b6b1779f34ba0507cb697492de83c4e9da8
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sun, 27 Feb 2022 16:53:22 +0100

Removed array-size constants for certain objects (steps, commands...)

Diffstat:
MTODO.md | 5++++-
Anissy | 0
Msrc/commands.c | 18+++++++++---------
Msrc/commands.h | 4+---
Msrc/pruning.c | 3++-
Msrc/pruning.h | 4+---
Msrc/shell.c | 4++--
Msrc/steps.c | 4+++-
Msrc/steps.h | 48++----------------------------------------------
9 files changed, 24 insertions(+), 66 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -56,6 +56,10 @@ including e.g. solutions that were not shown because -c) ## Technical stuff ### Memory management +* Optimization: allow coordinates do define how moves and trans are applied on + them; if not then just move the cube normally. + This can speedup things, for example in computing coordinates (no need to apply + trans_to_rep) and of course in optimal solver. * free pruning table after solve is done? if I do this I need to deafault to a small table for < 8 moves solutions or smth * improve multi-threading when solving multiple scrambles @@ -86,7 +90,6 @@ including e.g. solutions that were not shown because -c) ### Cleanup * Remove khuge from everywhere -* Arrays (commands, steps...): end with NULL and remove size constant * sort again functions alphabetically in their files * more stuff to load at start (or when suitable command is called) rather than when called directly, to avoid nasty problems with threading diff --git a/nissy b/nissy Binary files differ. diff --git a/src/commands.c b/src/commands.c @@ -150,7 +150,7 @@ version_cmd = { .exec = version_exec, }; -Command *commands[NCOMMANDS] = { +Command *commands[] = { &commands_cmd, &gen_cmd, &help_cmd, @@ -164,6 +164,7 @@ Command *commands[NCOMMANDS] = { &cleanup_cmd, &unniss_cmd, &version_cmd, + NULL }; /* Other constants ***********************************************************/ @@ -336,9 +337,8 @@ help_parse_args(int c, char **v) CommandArgs *a = new_args(); if (c == 1) { - for (i = 0; i < NCOMMANDS; i++) - if (commands[i] != NULL && - !strcmp(v[0], commands[i]->name)) + for (i = 0; commands[i] != NULL; i++) + if (!strcmp(v[0], commands[i]->name)) a->command = commands[i]; if (a->command == NULL) fprintf(stderr, "%s: command not found\n", v[0]); @@ -473,7 +473,7 @@ gen_exec(CommandArgs *args) init_symcoord(); fprintf(stderr, "Generating pruning tables...\n"); - for (i = 0; i < NPTABLES && allpd[i] != NULL; i++) + for (i = 0; allpd[i] != NULL; i++) genptable(allpd[i], args->opts->nthreads); fprintf(stderr, "Done!\n"); @@ -495,7 +495,7 @@ steps_exec(CommandArgs *args) { int i; - for (i = 0; i < NSTEPS && steps[i] != NULL; i++) + for (i = 0; steps[i] != NULL; i++) printf("%-15s %s\n", steps[i]->shortname, steps[i]->name); } @@ -504,7 +504,7 @@ commands_exec(CommandArgs *args) { int i; - for (i = 0; i < NCOMMANDS && commands[i] != NULL; i++) + for (i = 0; commands[i] != NULL; i++) printf("%s\n", commands[i]->usage); } @@ -642,8 +642,8 @@ read_step(CommandArgs *args, char *str) { int i; - for (i = 0; i < NSTEPS; i++) { - if (steps[i] != NULL && !strcmp(steps[i]->shortname, str)) { + for (i = 0; steps[i] != NULL; i++) { + if (!strcmp(steps[i]->shortname, str)) { args->step = steps[i]; return true; } diff --git a/src/commands.h b/src/commands.h @@ -6,11 +6,9 @@ #include "solve.h" #include "steps.h" -#define NCOMMANDS 20 - void free_args(CommandArgs *args); CommandArgs * new_args(); -extern Command * commands[NCOMMANDS]; +extern Command * commands[]; #endif diff --git a/src/pruning.c b/src/pruning.c @@ -98,7 +98,7 @@ pd_nxopt31_HTM = { .fbmod = BINOM8ON4, }; -PruneData * allpd[NPTABLES] = { +PruneData * allpd[] = { &pd_eofb_HTM, &pd_coud_HTM, &pd_cornershtr_HTM, @@ -110,6 +110,7 @@ PruneData * allpd[NPTABLES] = { &pd_htrfin_htr, /* &pd_khuge_HTM,*/ &pd_nxopt31_HTM, + NULL }; /* Functions *****************************************************************/ diff --git a/src/pruning.h b/src/pruning.h @@ -3,8 +3,6 @@ #include "symcoord.h" -#define NPTABLES 20 - extern PruneData pd_eofb_HTM; extern PruneData pd_coud_HTM; extern PruneData pd_corners_HTM; @@ -17,7 +15,7 @@ extern PruneData pd_htrfin_htr; extern PruneData pd_khuge_HTM; extern PruneData pd_nxopt31_HTM; -extern PruneData * allpd[NPTABLES]; +extern PruneData * allpd[]; void genptable(PruneData *pd, int nthreads); void print_ptable(PruneData *pd); diff --git a/src/shell.c b/src/shell.c @@ -37,8 +37,8 @@ exec_args(int c, char **v) CommandArgs *args; Alg *scramble; - for (i = 0; i < NCOMMANDS; i++) - if (commands[i] != NULL && !strcmp(v[0], commands[i]->name)) + for (i = 0; commands[i] != NULL; i++) + if (!strcmp(v[0], commands[i]->name)) cmd = commands[i]; if (cmd == NULL) { diff --git a/src/steps.c b/src/steps.c @@ -929,7 +929,7 @@ htrfin_htr = { .ntables = 1, }; -Step *steps[NSTEPS] = { +Step *steps[] = { &optimal_HTM, /* first is default */ &optimal_light_HTM, @@ -985,6 +985,8 @@ Step *steps[NSTEPS] = { &cornershtr_URF, &corners_HTM, &corners_URF, + + NULL }; /* Checkers, estimators and validators ***************************************/ diff --git a/src/steps.h b/src/steps.h @@ -3,55 +3,11 @@ #include "pruning.h" -#define NSTEPS 50 +extern Step * steps[]; -extern Step * steps[NSTEPS]; - -extern Step optimal_HTM; -extern Step optimal_light_HTM; -extern Step eofin_eo; -extern Step eofbfin_eofb; -extern Step eorlfin_eorl; -extern Step eoudfin_eoud; -extern Step eoany_HTM; -extern Step eofb_HTM; -extern Step eorl_HTM; -extern Step eoud_HTM; -extern Step coany_HTM; -extern Step coud_HTM; -extern Step corl_HTM; -extern Step cofb_HTM; -extern Step coany_URF; -extern Step coud_URF; -extern Step corl_URF; -extern Step cofb_URF; +/* Two steps used directly by two-phase solver */ extern Step drany_HTM; -extern Step drud_HTM; -extern Step drrl_HTM; -extern Step drfb_HTM; -extern Step dr_eo; -extern Step dr_eofb; -extern Step dr_eorl; -extern Step dr_eoud; -extern Step drud_eofb; -extern Step drrl_eofb; -extern Step drud_eorl; -extern Step drfb_eorl; -extern Step drfb_eoud; -extern Step drrl_eoud; extern Step dranyfin_DR; -extern Step drudfin_drud; -extern Step drrlfin_drrl; -extern Step drfbfin_drfb; -extern Step htr_any; -extern Step htr_drud; -extern Step htr_drrl; -extern Step htr_drfb; -extern Step htrfin_htr; -extern Step cornershtr_HTM; -extern Step cornershtr_URF; -extern Step corners_HTM; -extern Step corners_URF; void copy_estimatedata(EstimateData *s, EstimateData *d); void invert_estimatedata(EstimateData *ed);