diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-29 10:08:04 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-29 10:08:04 +0200 |
| commit | 8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84 (patch) | |
| tree | 8c0182f9bf94aaa8afe5126988e07af82c4409fd /src/nissy.h | |
| parent | cdf46d85efe7fa54e8c302a255214341c567b4af (diff) | |
| download | nissy-core-8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84.tar.gz nissy-core-8d3fc9f5f9c0593fcae9c451efe6c89c64dcbe84.zip | |
Added stop / pause / resume solve to API
Diffstat (limited to 'src/nissy.h')
| -rw-r--r-- | src/nissy.h | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/src/nissy.h b/src/nissy.h index 5800490..2fa4a75 100644 --- a/src/nissy.h +++ b/src/nissy.h | |||
| @@ -37,6 +37,11 @@ for example 'rotation UF' or 'mirrored BL'. | |||
| 37 | #define NISSY_NISSFLAG_ALL \ | 37 | #define NISSY_NISSFLAG_ALL \ |
| 38 | (NISSY_NISSFLAG_NORMAL | NISSY_NISSFLAG_INVERSE | NISSY_NISSFLAG_MIXED) | 38 | (NISSY_NISSFLAG_NORMAL | NISSY_NISSFLAG_INVERSE | NISSY_NISSFLAG_MIXED) |
| 39 | 39 | ||
| 40 | /* Status for stopping / pausing / resuming a solver */ | ||
| 41 | #define NISSY_STATUS_RUN 0 | ||
| 42 | #define NISSY_STATUS_STOP 1 | ||
| 43 | #define NISSY_STATUS_PAUSE 2 | ||
| 44 | |||
| 40 | /* The solved cube */ | 45 | /* The solved cube */ |
| 41 | #define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL=A" | 46 | #define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL=A" |
| 42 | 47 | ||
| @@ -296,24 +301,32 @@ nissy_checkdata( | |||
| 296 | Solve the given cube using the given solver and options. | 301 | Solve the given cube using the given solver and options. |
| 297 | 302 | ||
| 298 | Parameters: | 303 | Parameters: |
| 299 | cube - The cube to solver. | 304 | cube - The cube to solver. |
| 300 | solver - The name of the solver. | 305 | solver - The name of the solver. |
| 301 | nissflag - The flags for NISS (linear, inverse, mixed, or combinations). | 306 | nissflag - The flags for NISS (linear, inverse, mixed, or |
| 302 | minmoves - The minimum number of moves for a solution. | 307 | combinations; see the constants at the top of this file). |
| 303 | maxmoves - The maximum number of moves for a solution. | 308 | minmoves - The minimum number of moves for a solution. |
| 304 | maxsols - The maximum number of solutions. | 309 | maxmoves - The maximum number of moves for a solution. |
| 305 | optimal - The maximum number of moves above the optimal solution length. | 310 | maxsols - The maximum number of solutions. |
| 306 | threads - The number of threads to use. Must be less than or equalt to | 311 | optimal - The maximum number of moves above the optimal solution. |
| 307 | the value of the compile-time constant THREADS. If set to 0, | 312 | threads - The number of threads to use. Must be less than or equal |
| 308 | the default value THREADS will be used. | 313 | to the value of the compile-time constant THREADS. If set |
| 309 | data_size - The size of the data buffer. | 314 | to 0, the default value THREADS will be used. |
| 310 | data - The data for the solver. Can be computed with gendata. | 315 | data_size - The size of the data buffer. |
| 311 | This buffer must have 8-byte alignment. | 316 | data - The data for the solver. Can be computed with gendata. |
| 312 | sols_size - The size of the solutions buffer. | 317 | This buffer must have 8-byte alignment. |
| 313 | sols - The return parameter for the solutions. The solutions are | 318 | sols_size - The size of the solutions buffer. |
| 314 | separated by a '\n' (newline) and a '\0' (NULL character) | 319 | sols - The return parameter for the solutions. The solutions are |
| 315 | terminates the list. | 320 | separated by a '\n' (newline) and a '\0' (NULL character) |
| 316 | stats - An array to store some statistics about the solve. | 321 | terminates the list. |
| 322 | stats - An array to store some statistics about the solve. | ||
| 323 | poll_status - A callback function that should return the current | ||
| 324 | requested status for the solver (e.g. run, stop, pause, | ||
| 325 | resume; see the constants at the top of this file). The | ||
| 326 | way this status is polled and honored is solver-specific. | ||
| 327 | If this parameter is NULL, the status will always assumed | ||
| 328 | to be "run". | ||
| 329 | poll_status_data - Auxiliary data for the poll_status callback function. | ||
| 317 | 330 | ||
| 318 | Return values: | 331 | Return values: |
| 319 | NISSY_OK - Cube solved succesfully. | 332 | NISSY_OK - Cube solved succesfully. |
| @@ -340,7 +353,9 @@ nissy_solve( | |||
| 340 | const unsigned char data[data_size], | 353 | const unsigned char data[data_size], |
| 341 | unsigned sols_size, | 354 | unsigned sols_size, |
| 342 | char sols[sols_size], | 355 | char sols[sols_size], |
| 343 | long long stats[static NISSY_SIZE_SOLVE_STATS] | 356 | long long stats[static NISSY_SIZE_SOLVE_STATS], |
| 357 | int (*poll_status)(void *), | ||
| 358 | void *poll_status_data | ||
| 344 | ); | 359 | ); |
| 345 | 360 | ||
| 346 | /* | 361 | /* |
