diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-06-23 12:09:37 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-06-23 12:09:37 +0200 |
| commit | 05bdcfef13ef2bdd05df6af13a74ec3cd7fcd22f (patch) | |
| tree | 1d5512f3e31dd86414d386713a82336db5edf0f5 /src/solve_generic.h | |
| parent | 71c0188306377940ae172dceb58f2bd5f4fcdb4f (diff) | |
| download | nissy-core-05bdcfef13ef2bdd05df6af13a74ec3cd7fcd22f.tar.gz nissy-core-05bdcfef13ef2bdd05df6af13a74ec3cd7fcd22f.zip | |
Cleanup
Diffstat (limited to 'src/solve_generic.h')
| -rw-r--r-- | src/solve_generic.h | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/src/solve_generic.h b/src/solve_generic.h index 6a1dcf3..d1d1469 100644 --- a/src/solve_generic.h +++ b/src/solve_generic.h | |||
| @@ -16,47 +16,6 @@ _static int64_t solve_generic(cube_t, const char *, int8_t, int8_t, int64_t, | |||
| 16 | _static uint8_t estimate_simple(cube_t); | 16 | _static uint8_t estimate_simple(cube_t); |
| 17 | _static int64_t solve_simple(cube_t, int8_t, int8_t, int64_t, int8_t, char *); | 17 | _static int64_t solve_simple(cube_t, int8_t, int8_t, int64_t, int8_t, char *); |
| 18 | 18 | ||
| 19 | int64_t | ||
| 20 | solve( | ||
| 21 | cube_t cube, | ||
| 22 | const char *solver, | ||
| 23 | const char *options, | ||
| 24 | const char *nisstype, | ||
| 25 | int8_t minmoves, | ||
| 26 | int8_t maxmoves, | ||
| 27 | int64_t maxsols, | ||
| 28 | int8_t optimal, | ||
| 29 | const void *data, | ||
| 30 | char *solutions | ||
| 31 | ) | ||
| 32 | { | ||
| 33 | DBG_WARN(!strcmp(options, ""), | ||
| 34 | "solve: 'options' not implemented yet, ignoring\n"); | ||
| 35 | |||
| 36 | DBG_WARN(!strcmp(nisstype, ""), | ||
| 37 | "solve: NISS not implemented yet, ignoring 'nisstype'\n"); | ||
| 38 | |||
| 39 | DBG_WARN(data == NULL, | ||
| 40 | "solve: 'data' not implemented yet, ignoring\n"); | ||
| 41 | |||
| 42 | if (!strcmp(solver, "optimal") || !strcmp(solver, "simple")) { | ||
| 43 | return solve_simple( | ||
| 44 | cube, | ||
| 45 | minmoves, | ||
| 46 | maxmoves, | ||
| 47 | maxsols, | ||
| 48 | optimal, | ||
| 49 | solutions | ||
| 50 | ); | ||
| 51 | } else { | ||
| 52 | LOG("solve: unknown solver '%s'\n", solver); | ||
| 53 | return -1; | ||
| 54 | } | ||
| 55 | |||
| 56 | LOG("solve: error\n"); | ||
| 57 | return -1; | ||
| 58 | } | ||
| 59 | |||
| 60 | _static void | 19 | _static void |
| 61 | solve_generic_appendsolution(dfsarg_generic_t *arg) | 20 | solve_generic_appendsolution(dfsarg_generic_t *arg) |
| 62 | { | 21 | { |
| @@ -125,11 +84,6 @@ solve_generic( | |||
| 125 | dfsarg_generic_t arg; | 84 | dfsarg_generic_t arg; |
| 126 | int64_t ret, tmp, first; | 85 | int64_t ret, tmp, first; |
| 127 | 86 | ||
| 128 | if (!issolvable(cube)) { | ||
| 129 | LOG("solve: cube is not solvable\n"); | ||
| 130 | return -1; | ||
| 131 | } | ||
| 132 | |||
| 133 | if (issolved(cube)) { | 87 | if (issolved(cube)) { |
| 134 | LOG("solve: cube is already solved\n"); | 88 | LOG("solve: cube is already solved\n"); |
| 135 | sols[0] = '\n'; | 89 | sols[0] = '\n'; |
| @@ -137,34 +91,6 @@ solve_generic( | |||
| 137 | return 1; | 91 | return 1; |
| 138 | } | 92 | } |
| 139 | 93 | ||
| 140 | DBG_WARN(!strcmp(nisstype, ""), | ||
| 141 | "solve: NISS not implemented yet, 'nisstype' ignored\n"); | ||
| 142 | |||
| 143 | if (minmoves < 0) { | ||
| 144 | LOG("solve: 'minmoves' is negative, setting to 0\n"); | ||
| 145 | minmoves = 0; | ||
| 146 | } | ||
| 147 | |||
| 148 | if (maxmoves < 0) { | ||
| 149 | LOG("solve: invalid 'maxmoves', setting to 20\n"); | ||
| 150 | maxmoves = 20; | ||
| 151 | } | ||
| 152 | |||
| 153 | if (maxsols < 0) { | ||
| 154 | LOG("solve: 'maxsols' is negative\n"); | ||
| 155 | return -1; | ||
| 156 | } | ||
| 157 | |||
| 158 | if (maxsols == 0) { | ||
| 159 | LOG("solve: 'maxsols' is 0\n"); | ||
| 160 | return 0; | ||
| 161 | } | ||
| 162 | |||
| 163 | if (sols == NULL) { | ||
| 164 | LOG("solve: return parameter 'sols' is NULL\n"); | ||
| 165 | return -1; | ||
| 166 | } | ||
| 167 | |||
| 168 | if (estimate == NULL) { | 94 | if (estimate == NULL) { |
| 169 | LOG("solve: 'estimate' is NULL\n"); | 95 | LOG("solve: 'estimate' is NULL\n"); |
| 170 | return -1; | 96 | return -1; |
| @@ -230,27 +156,3 @@ solve_simple( | |||
| 230 | &estimate_simple | 156 | &estimate_simple |
| 231 | ); | 157 | ); |
| 232 | } | 158 | } |
| 233 | |||
| 234 | int64_t | ||
| 235 | gendata(const char *solver, const char *options, void *data) | ||
| 236 | { | ||
| 237 | int64_t ret; | ||
| 238 | uint8_t maxdepth, h, i, j; | ||
| 239 | |||
| 240 | if (!strcmp(solver, "H48")) { | ||
| 241 | /* | ||
| 242 | TODO: write a generic parser for options | ||
| 243 | for now it accepts "h;maxdepth" | ||
| 244 | */ | ||
| 245 | for (i = 0; options[i] != ';'; i++) ; | ||
| 246 | for (j = i; options[j]; j++) ; | ||
| 247 | h = atoi(options); | ||
| 248 | maxdepth = atoi(&options[i+1]); | ||
| 249 | ret = gendata_h48(data, h, maxdepth); | ||
| 250 | } else { | ||
| 251 | LOG("gendata: implemented only for H48 solver\n"); | ||
| 252 | ret = -1; | ||
| 253 | } | ||
| 254 | |||
| 255 | return ret; | ||
| 256 | } | ||
