diff options
Diffstat (limited to '')
| -rw-r--r-- | src/cube.h | 28 |
1 files changed, 24 insertions, 4 deletions
| @@ -1,39 +1,57 @@ | |||
| 1 | /* include: inttypes, stdarg, stdbool, string */ | ||
| 2 | |||
| 3 | /* | 1 | /* |
| 2 | If you include this file, you should also include the following: | ||
| 3 | |||
| 4 | inttypes, stdarg, stdbool, string | ||
| 5 | |||
| 4 | All the functions below return 0 in case of success and a positive | 6 | All the functions below return 0 in case of success and a positive |
| 5 | number in case of error, unless otherwise specified. See (TODO: | 7 | number in case of error, unless otherwise specified. |
| 6 | documentation) for details. | 8 | |
| 9 | Arguments of type char [static 22] denote a cube in B32 format. | ||
| 10 | Other available formats are H48 and SRC. See README.md for more info on | ||
| 11 | these formats. | ||
| 12 | |||
| 13 | Accepted moves are U, D, R, L, F and B, optionally followed by a 2, | ||
| 14 | a ' or a 3. | ||
| 15 | |||
| 16 | A transformation must be given in the format | ||
| 17 | (rotation|mirrored) (2 letters) | ||
| 18 | for example 'rotation UF' or 'mirrored BL'. | ||
| 7 | */ | 19 | */ |
| 8 | 20 | ||
| 21 | /* Apply the secod argument as a permutation on the first argument */ | ||
| 9 | int64_t nissy_compose( | 22 | int64_t nissy_compose( |
| 10 | const char cube[static 22], | 23 | const char cube[static 22], |
| 11 | const char permutation[static 22], | 24 | const char permutation[static 22], |
| 12 | char result[static 22] | 25 | char result[static 22] |
| 13 | ); | 26 | ); |
| 14 | 27 | ||
| 28 | /* Compute the inverse of the given cube */ | ||
| 15 | int64_t nissy_inverse( | 29 | int64_t nissy_inverse( |
| 16 | const char cube[static 22], | 30 | const char cube[static 22], |
| 17 | char result[static 22] | 31 | char result[static 22] |
| 18 | ); | 32 | ); |
| 19 | 33 | ||
| 34 | /* Apply the given sequence of moves on the given cube */ | ||
| 20 | int64_t nissy_applymoves( | 35 | int64_t nissy_applymoves( |
| 21 | const char cube[static 22], | 36 | const char cube[static 22], |
| 22 | const char *moves, | 37 | const char *moves, |
| 23 | char result[static 22] | 38 | char result[static 22] |
| 24 | ); | 39 | ); |
| 25 | 40 | ||
| 41 | /* Apply the single given transformation to the given cube */ | ||
| 26 | int64_t nissy_applytrans( | 42 | int64_t nissy_applytrans( |
| 27 | const char cube[static 22], | 43 | const char cube[static 22], |
| 28 | const char *transformation, | 44 | const char *transformation, |
| 29 | char result[static 22] | 45 | char result[static 22] |
| 30 | ); | 46 | ); |
| 31 | 47 | ||
| 48 | /* Return the cube obtained by applying the given moves to the solved cube */ | ||
| 32 | int64_t nissy_frommoves( | 49 | int64_t nissy_frommoves( |
| 33 | const char *moves, | 50 | const char *moves, |
| 34 | char result[static 22] | 51 | char result[static 22] |
| 35 | ); | 52 | ); |
| 36 | 53 | ||
| 54 | /* Convert the given cube between the two given formats */ | ||
| 37 | int64_t nissy_convert( | 55 | int64_t nissy_convert( |
| 38 | const char *format_in, | 56 | const char *format_in, |
| 39 | const char *format_out, | 57 | const char *format_out, |
| @@ -41,6 +59,7 @@ int64_t nissy_convert( | |||
| 41 | char *result | 59 | char *result |
| 42 | ); | 60 | ); |
| 43 | 61 | ||
| 62 | /* Get the cube with the given ep, eo, cp and co values. */ | ||
| 44 | int64_t nissy_getcube( | 63 | int64_t nissy_getcube( |
| 45 | int64_t ep, | 64 | int64_t ep, |
| 46 | int64_t eo, | 65 | int64_t eo, |
| @@ -81,4 +100,5 @@ int64_t nissy_solve( | |||
| 81 | char *solutions | 100 | char *solutions |
| 82 | ); | 101 | ); |
| 83 | 102 | ||
| 103 | /* Set a global logger function used by this library. */ | ||
| 84 | void nissy_setlogger(void (*logger_function)(const char *, ...)); | 104 | void nissy_setlogger(void (*logger_function)(const char *, ...)); |
