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