diff options
| -rw-r--r-- | TODO.txt | 1 | ||||
| -rw-r--r-- | src/cube.h | 12 | ||||
| -rw-r--r-- | src/cube_public.h | 12 | ||||
| -rw-r--r-- | src/solve_h48.h | 11 |
4 files changed, 33 insertions, 3 deletions
| @@ -3,7 +3,6 @@ Solver | |||
| 3 | 3 | ||
| 4 | More utilities for tables (in cube.h) | 4 | More utilities for tables (in cube.h) |
| 5 | - cleanup solve and gendata in cube.h and cube_public.h | 5 | - cleanup solve and gendata in cube.h and cube_public.h |
| 6 | - for tables, a "dryrun" function that only tells you the size needed | ||
| 7 | - check hash of generated data | 6 | - check hash of generated data |
| 8 | 7 | ||
| 9 | Goal: find out which k value is best | 8 | Goal: find out which k value is best |
| @@ -51,6 +51,16 @@ int nissy_convertcube( | |||
| 51 | char *result | 51 | char *result |
| 52 | ); | 52 | ); |
| 53 | 53 | ||
| 54 | /* | ||
| 55 | Returns the size of the data generated by nissy_gendata, when called with | ||
| 56 | the same parameters, or -1 in case of error. The returned value can be | ||
| 57 | slightly larger than the actual table size. | ||
| 58 | */ | ||
| 59 | int64_t nissy_datasize( | ||
| 60 | const char *solver, | ||
| 61 | const char *options | ||
| 62 | ); | ||
| 63 | |||
| 54 | /* Returns the number of bytes written, or -1 in case of error */ | 64 | /* Returns the number of bytes written, or -1 in case of error */ |
| 55 | int64_t nissy_gendata( | 65 | int64_t nissy_gendata( |
| 56 | const char *solver, | 66 | const char *solver, |
| @@ -59,7 +69,7 @@ int64_t nissy_gendata( | |||
| 59 | ); | 69 | ); |
| 60 | 70 | ||
| 61 | /* Returns the number of solutions found, or -1 in case of error */ | 71 | /* Returns the number of solutions found, or -1 in case of error */ |
| 62 | int nissy_solve( | 72 | int64_t nissy_solve( |
| 63 | const char cube[static 22], | 73 | const char cube[static 22], |
| 64 | const char *solver, | 74 | const char *solver, |
| 65 | const char *options, | 75 | const char *options, |
diff --git a/src/cube_public.h b/src/cube_public.h index 1b0cc14..01b6dac 100644 --- a/src/cube_public.h +++ b/src/cube_public.h | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | #include "cube.h" | ||
| 2 | |||
| 1 | int write_result(cube_t, char [static 22]); | 3 | int write_result(cube_t, char [static 22]); |
| 2 | 4 | ||
| 3 | int | 5 | int |
| @@ -127,6 +129,16 @@ nissy_writecube( | |||
| 127 | } | 129 | } |
| 128 | 130 | ||
| 129 | int64_t | 131 | int64_t |
| 132 | nissy_datasize( | ||
| 133 | const char *solver, | ||
| 134 | const char *options | ||
| 135 | ) | ||
| 136 | { | ||
| 137 | /* gendata() handles a NULL *data as a "dryrun" request */ | ||
| 138 | return nissy_gendata(solver, options, NULL); | ||
| 139 | } | ||
| 140 | |||
| 141 | int64_t | ||
| 130 | nissy_gendata( | 142 | nissy_gendata( |
| 131 | const char *solver, | 143 | const char *solver, |
| 132 | const char *options, | 144 | const char *options, |
diff --git a/src/solve_h48.h b/src/solve_h48.h index 8691d49..8be67b6 100644 --- a/src/solve_h48.h +++ b/src/solve_h48.h | |||
| @@ -129,6 +129,9 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) | |||
| 129 | uint8_t i, j, visited[COCSEP_VISITEDSIZE]; | 129 | uint8_t i, j, visited[COCSEP_VISITEDSIZE]; |
| 130 | dfsarg_cocsep_t arg; | 130 | dfsarg_cocsep_t arg; |
| 131 | 131 | ||
| 132 | if (buf == NULL) | ||
| 133 | goto gendata_cocsep_return_size; | ||
| 134 | |||
| 132 | buf32 = (uint32_t *)buf; | 135 | buf32 = (uint32_t *)buf; |
| 133 | info = buf32 + COCSEP_TABLESIZE; | 136 | info = buf32 + COCSEP_TABLESIZE; |
| 134 | memset(buf32, 0xFF, sizeof(uint32_t) * COCSEP_TABLESIZE); | 137 | memset(buf32, 0xFF, sizeof(uint32_t) * COCSEP_TABLESIZE); |
| @@ -165,6 +168,7 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) | |||
| 165 | for (j = 0; j < 10; j++) | 168 | for (j = 0; j < 10; j++) |
| 166 | DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+2]); | 169 | DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+2]); |
| 167 | 170 | ||
| 171 | gendata_cocsep_return_size: | ||
| 168 | return COCSEP_FULLSIZE; | 172 | return COCSEP_FULLSIZE; |
| 169 | } | 173 | } |
| 170 | 174 | ||
| @@ -234,8 +238,12 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth) | |||
| 234 | cube_t crep[COCSEP_CLASSES]; | 238 | cube_t crep[COCSEP_CLASSES]; |
| 235 | size_t cocsepsize, infosize; | 239 | size_t cocsepsize, infosize; |
| 236 | 240 | ||
| 237 | esep_max = (int64_t)ESEP_MAX(h); | 241 | infosize = 4 * maxdepth; |
| 238 | cocsepsize = gendata_cocsep(buf, selfsim, crep); | 242 | cocsepsize = gendata_cocsep(buf, selfsim, crep); |
| 243 | if (buf == NULL) | ||
| 244 | goto gendata_h48_return_size; | ||
| 245 | |||
| 246 | esep_max = (int64_t)ESEP_MAX(h); | ||
| 239 | cocsepdata = (uint32_t *)buf; | 247 | cocsepdata = (uint32_t *)buf; |
| 240 | buf32 = cocsepdata + cocsepsize / 4; | 248 | buf32 = cocsepdata + cocsepsize / 4; |
| 241 | info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t)); | 249 | info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t)); |
| @@ -272,6 +280,7 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth) | |||
| 272 | for (j = 0; j <= info[0]; j++) | 280 | for (j = 0; j <= info[0]; j++) |
| 273 | DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+1]); | 281 | DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+1]); |
| 274 | 282 | ||
| 283 | gendata_h48_return_size: | ||
| 275 | return cocsepsize + ESEP_TABLESIZE(h, k) + infosize; | 284 | return cocsepsize + ESEP_TABLESIZE(h, k) + infosize; |
| 276 | } | 285 | } |
| 277 | 286 | ||
