aboutsummaryrefslogtreecommitdiff
path: root/src/nissy.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/nissy.h120
1 files changed, 91 insertions, 29 deletions
diff --git a/src/nissy.h b/src/nissy.h
index 1fc1776..c78fb50 100644
--- a/src/nissy.h
+++ b/src/nissy.h
@@ -1,10 +1,17 @@
1/* 1/*
2If you include this file, you should also include the following: 2This is libnissy (temporarily also known as h48), a Rubik's cube library.
3 3
4inttypes, stdarg, stdbool, string 4If you include this file, you should also use the following includes:
5 5
6All the functions below return 0 in case of success and a positive 6#include <inttypes>
7number in case of error, unless otherwise specified. 7#include <stdarg>
8#include <stdbool>
9#include <string>
10
11All the functions below return 0 in case of success and a positive number
12in case of error, unless otherwise specified. Errors are checked in code
13order: for example if error code 1 is returned then it could that also
14an error with code 2 or higher occurred.
8 15
9Arguments of type char [static 22] denote a cube in B32 format. 16Arguments of type char [static 22] denote a cube in B32 format.
10Other available formats are H48 and SRC. See README.md for more info on 17Other available formats are H48 and SRC. See README.md for more info on
@@ -18,40 +25,85 @@ A transformation must be given in the format
18for example 'rotation UF' or 'mirrored BL'. 25for example 'rotation UF' or 'mirrored BL'.
19*/ 26*/
20 27
21/* Apply the secod argument as a permutation on the first argument */ 28/*
29Apply the secod argument as a permutation on the first argument.
30
31Return values:
32 0 Valid result
33 1 The given cube is invalid
34 2 The given permutation is invalid
35 9 The resulting cube is not solvable
36*/
22int64_t nissy_compose( 37int64_t nissy_compose(
23 const char cube[static 22], 38 const char cube[static 22],
24 const char permutation[static 22], 39 const char permutation[static 22],
25 char result[static 22] 40 char result[static 22]
26); 41);
27 42
28/* Compute the inverse of the given cube */ 43/*
44Compute the inverse of the given cube.
45
46Return values:
47 0 Valid result
48 1 The given cube is invalid
49 9 The resulting cube is not solvable
50*/
29int64_t nissy_inverse( 51int64_t nissy_inverse(
30 const char cube[static 22], 52 const char cube[static 22],
31 char result[static 22] 53 char result[static 22]
32); 54);
33 55
34/* Apply the given sequence of moves on the given cube */ 56/*
57Apply the given sequence of moves on the given cube.
58
59Return values:
60 0 Valid result
61 1 The given cube is invalid
62 8 The given moves are invalid
63 9 The resulting cube is not solvable
64*/
35int64_t nissy_applymoves( 65int64_t nissy_applymoves(
36 const char cube[static 22], 66 const char cube[static 22],
37 const char *moves, 67 const char *moves,
38 char result[static 22] 68 char result[static 22]
39); 69);
40 70
41/* Apply the single given transformation to the given cube */ 71/*
72Apply the single given transformation to the given cube.
73
74Return values:
75 0 Valid result
76 1 The given cube is invalid
77 8 The given transformation is invalid
78 9 The resulting cube is not solvable
79*/
42int64_t nissy_applytrans( 80int64_t nissy_applytrans(
43 const char cube[static 22], 81 const char cube[static 22],
44 const char *transformation, 82 const char *transformation,
45 char result[static 22] 83 char result[static 22]
46); 84);
47 85
48/* Return the cube obtained by applying the given moves to the solved cube */ 86/*
87Apply the given moves to the solved cube.
88
89Return values:
90 0 Valid result
91 1 The given moves are invalid
92*/
49int64_t nissy_frommoves( 93int64_t nissy_frommoves(
50 const char *moves, 94 const char *moves,
51 char result[static 22] 95 char result[static 22]
52); 96);
53 97
54/* Convert the given cube between the two given formats */ 98/*
99Convert the given cube between the two given formats.
100
101Return values:
102 0 Valid result
103 1 The given cube or format_in is invalid
104 2 The resulting cube or format_out is invalid
105 3 The resulting cube is inconsistent
106*/
55int64_t nissy_convert( 107int64_t nissy_convert(
56 const char *format_in, 108 const char *format_in,
57 const char *format_out, 109 const char *format_out,
@@ -70,40 +122,48 @@ int64_t nissy_getcube(
70); 122);
71 123
72/* 124/*
73Returns the size of the data generated by nissy_gendata, when called with 125Compute the size of the data generated by nissy_gendata, when called with
74the same parameters, or -1 in case of error. The returned value can be 126the same parameters, or -1 in case of error.
75slightly larger than the actual table size. 127
128Return values:
129 -1 Error
130 >=0 The size of the table, in bytes
76*/ 131*/
77int64_t nissy_datasize( 132int64_t nissy_datasize(
78 const char *solver 133 const char *solver
79); 134);
80 135
81/* Returns the number of bytes written, or -1 in case of error */ 136/*
137Compute the data for the given solver and store it in generated_data.
138
139Return values:
140 -1 Error
141 >=0 The size of the table, in bytes
142*/
82int64_t nissy_gendata( 143int64_t nissy_gendata(
83 const char *solver, 144 const char *solver,
84 void *generated_data 145 void *generated_data
85); 146);
86 147
87/* Temporarily added to test h48 intermediate tables */ 148/*
88int64_t nissy_derivedata( 149Print information on a data table via the provided callback writer.
89 const char *options,
90 const void *fulltable,
91 void *generated_data
92);
93
94/* Returns 0 on positive check, 1 on error */
95int64_t nissy_checkdata(
96 const char *solver,
97 const void *data
98);
99 150
100/* Print information on a data table via the provided callback writer */ 151Return values:
152 0 No error
153 1 The given data could not be read correctly
154*/
101int64_t nissy_datainfo( 155int64_t nissy_datainfo(
102 const void *table, 156 const void *table,
103 void (*write)(const char *, ...) 157 void (*write)(const char *, ...)
104); 158);
105 159
106/* Returns the number of solutions found, or -1 in case of error */ 160/*
161Solve the given cube using the given solver and options
162
163Return values:
164 -1 Error
165 >=0 The number of solutions found
166*/
107int64_t nissy_solve( 167int64_t nissy_solve(
108 const char cube[static 22], 168 const char cube[static 22],
109 const char *solver, 169 const char *solver,
@@ -116,5 +176,7 @@ int64_t nissy_solve(
116 char *solutions 176 char *solutions
117); 177);
118 178
119/* Set a global logger function used by this library. */ 179/*
180Set a global logger function used by this library.
181*/
120void nissy_setlogger(void (*logger_function)(const char *, ...)); 182void nissy_setlogger(void (*logger_function)(const char *, ...));

Generated with cgit - Back to sebastiano.tronto.net