nissy.h (2922B)
1 /* 2 If you include this file, you should also include the following: 3 4 inttypes, stdarg, stdbool, string 5 6 All the functions below return 0 in case of success and a positive 7 number in case of error, unless otherwise specified. 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'. 19 */ 20 21 /* Apply the secod argument as a permutation on the first argument */ 22 int64_t nissy_compose( 23 const char cube[static 22], 24 const char permutation[static 22], 25 char result[static 22] 26 ); 27 28 /* Compute the inverse of the given cube */ 29 int64_t nissy_inverse( 30 const char cube[static 22], 31 char result[static 22] 32 ); 33 34 /* Apply the given sequence of moves on the given cube */ 35 int64_t nissy_applymoves( 36 const char cube[static 22], 37 const char *moves, 38 char result[static 22] 39 ); 40 41 /* Apply the single given transformation to the given cube */ 42 int64_t nissy_applytrans( 43 const char cube[static 22], 44 const char *transformation, 45 char result[static 22] 46 ); 47 48 /* Return the cube obtained by applying the given moves to the solved cube */ 49 int64_t nissy_frommoves( 50 const char *moves, 51 char result[static 22] 52 ); 53 54 /* Convert the given cube between the two given formats */ 55 int64_t nissy_convert( 56 const char *format_in, 57 const char *format_out, 58 const char *cube_string, 59 char *result 60 ); 61 62 /* Get the cube with the given ep, eo, cp and co values. */ 63 int64_t nissy_getcube( 64 int64_t ep, 65 int64_t eo, 66 int64_t cp, 67 int64_t co, 68 const char *options, 69 char result[static 22] 70 ); 71 72 /* 73 Returns the size of the data generated by nissy_gendata, when called with 74 the same parameters, or -1 in case of error. The returned value can be 75 slightly larger than the actual table size. 76 */ 77 int64_t nissy_datasize( 78 const char *solver, 79 const char *options /* TODO: remove options, use only solver name */ 80 ); 81 82 /* Returns the number of bytes written, or -1 in case of error */ 83 int64_t nissy_gendata( 84 const char *solver, 85 const char *options, /* TODO: remove options, use only solver name */ 86 void *generated_data 87 ); 88 89 /* Print information on a data table via the provided callback writer */ 90 int64_t nissy_datainfo( 91 const void *table, 92 void (*write)(const char *, ...) 93 ); 94 95 /* Returns the number of solutions found, or -1 in case of error */ 96 int64_t nissy_solve( 97 const char cube[static 22], 98 const char *solver, 99 const char *options, /* TODO: remove options, use only solver name */ 100 const char *nisstype, /* TODO: remove, use flags */ 101 int8_t minmoves, 102 int8_t maxmoves, 103 int64_t maxsolutions, 104 int8_t optimal, 105 const void *data, 106 char *solutions 107 ); 108 109 /* Set a global logger function used by this library. */ 110 void nissy_setlogger(void (*logger_function)(const char *, ...));