aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-22 14:17:03 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-22 14:17:03 +0200
commitac652bb6fb45099008e862e3ced650299dc3ebb7 (patch)
tree12fb1c902c271fbeac41c4ee416cf1cd76b16fd7 /src
parent71e104d84b3538e15f27df79b151e6b49cbad1eb (diff)
parente391c4624055138f075c0e5772ccaf8ede094b5a (diff)
downloadnissy-core-ac652bb6fb45099008e862e3ced650299dc3ebb7.tar.gz
nissy-core-ac652bb6fb45099008e862e3ced650299dc3ebb7.zip
Merge branch 'master' into extend_moves
Diffstat (limited to '')
-rw-r--r--src/arch/avx2.h2
-rw-r--r--src/core/core.h1
-rw-r--r--src/core/cube.h178
-rw-r--r--src/nissy.c92
-rw-r--r--src/nissy.h102
-rw-r--r--utils/convert.c (renamed from src/core/io_formats.h)6
6 files changed, 241 insertions, 140 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index ad4ee0d..b1f8a59 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -134,7 +134,7 @@ inverse(cube_t c)
134 vp = _mm256_andnot_si256(ORIENT_AVX2, vi); 134 vp = _mm256_andnot_si256(ORIENT_AVX2, vi);
135 ret = _mm256_or_si256(vp, vo); 135 ret = _mm256_or_si256(vp, vo);
136 ret = _mm256_and_si256(ret, USED_AVX2); 136 ret = _mm256_and_si256(ret, USED_AVX2);
137 137
138 return invertco(ret); 138 return invertco(ret);
139} 139}
140 140
diff --git a/src/core/core.h b/src/core/core.h
index de1c198..fce1751 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -1,5 +1,4 @@
1#include "constant_cubes.h" 1#include "constant_cubes.h"
2#include "cube.h" 2#include "cube.h"
3#include "io_formats.h"
4#include "moves.h" 3#include "moves.h"
5#include "transform.h" 4#include "transform.h"
diff --git a/src/core/cube.h b/src/core/cube.h
index ce8a6b8..a045e55 100644
--- a/src/core/cube.h
+++ b/src/core/cube.h
@@ -174,3 +174,181 @@ getcube(int64_t ep, int64_t eo, int64_t cp, int64_t co)
174 174
175 return cubefromarray(carr, earr); 175 return cubefromarray(carr, earr);
176} 176}
177
178
179/******************************************************************************/
180
181STATIC cube_t readcube(const char *);
182STATIC int64_t writecube(cube_t, size_t n, char [n]);
183STATIC uint8_t readco(const char *);
184STATIC uint8_t readcp(const char *);
185STATIC uint8_t readeo(const char *);
186STATIC uint8_t readep(const char *);
187
188STATIC uint8_t b32toedge(char);
189STATIC uint8_t b32tocorner(char);
190STATIC char edgetob32(uint8_t);
191STATIC char cornertob32(uint8_t);
192
193STATIC uint8_t
194readco(const char *str)
195{
196 if (*str == '0')
197 return 0;
198 if (*str == '1')
199 return CTWIST_CW;
200 if (*str == '2')
201 return CTWIST_CCW;
202
203 LOG("Error reading CO\n");
204 return UINT8_ERROR;
205}
206
207STATIC uint8_t
208readcp(const char *str)
209{
210 uint8_t c;
211
212 for (c = 0; c < 8; c++)
213 if (!strncmp(str, cornerstr[c], 3) ||
214 !strncmp(str, cornerstralt[c], 3))
215 return c;
216
217 LOG("Error reading CP\n");
218 return UINT8_ERROR;
219}
220
221STATIC uint8_t
222readeo(const char *str)
223{
224 if (*str == '0')
225 return 0;
226 if (*str == '1')
227 return EFLIP;
228
229 LOG("Error reading EO\n");
230 return UINT8_ERROR;
231}
232
233STATIC uint8_t
234readep(const char *str)
235{
236 uint8_t e;
237
238 for (e = 0; e < 12; e++)
239 if (!strncmp(str, edgestr[e], 2))
240 return e;
241
242 LOG("Error reading EP\n");
243 return UINT8_ERROR;
244}
245
246STATIC cube_t
247readcube(const char *buf)
248{
249 int i;
250 uint8_t c[8], e[12];
251
252 for (i = 0; i < 8; i++) {
253 c[i] = b32tocorner(buf[i]);
254 if (c[i] == UINT8_ERROR) {
255 LOG("Error reading corner %d ", i);
256 if (buf[i] == 0) {
257 LOG("(string terminated early)\n");
258 } else {
259 LOG("(char '%c')\n", buf[i]);
260 }
261 return ZERO_CUBE;
262 }
263 }
264
265 if (buf[8] != '=') {
266 LOG("Error reading separator: a single '=' "
267 "must be used to separate edges and corners\n");
268 return ZERO_CUBE;
269 }
270
271 for (i = 0; i < 12; i++) {
272 e[i] = b32toedge(buf[i+9]);
273 if (e[i] == UINT8_ERROR) {
274 LOG("Error reading edge %d ", i);
275 if (buf[i+9] == 0) {
276 LOG("(string terminated early)\n");
277 } else {
278 LOG("(char '%c')\n", buf[i+9]);
279 }
280 return ZERO_CUBE;
281 }
282 }
283
284 return cubefromarray(c, e);
285}
286
287STATIC int64_t
288writecube(cube_t cube, size_t buf_size, char buf[buf_size])
289{
290 int i;
291 uint8_t corner[8], edge[12];
292
293 if (buf_size < NISSY_SIZE_CUBE) {
294 LOG("Cannot write cube: buffer size must be at least %u "
295 "bytes, but the provided one is %zu bytes.\n",
296 NISSY_SIZE_CUBE, buf_size);
297 return NISSY_ERROR_BUFFER_SIZE;
298 }
299
300 pieces(&cube, corner, edge);
301
302 for (i = 0; i < 8; i++)
303 buf[i] = cornertob32(corner[i]);
304
305 buf[8] = '=';
306
307 for (i = 0; i < 12; i++)
308 buf[i+9] = edgetob32(edge[i]);
309
310/* TODO */
311 buf[21] = '=';
312 buf[22] = 'A';
313 buf[23] = '\0';
314
315 return NISSY_OK;
316}
317
318STATIC uint8_t
319b32toedge(char c)
320{
321 if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f')))
322 return UINT8_ERROR;
323
324 return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26;
325}
326
327STATIC uint8_t
328b32tocorner(char c) {
329 uint8_t val;
330
331 if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'f')))
332 return UINT8_ERROR;
333
334 val = c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26;
335
336 return (val & 7) | ((val & 24) << 2);
337}
338
339STATIC char
340edgetob32(uint8_t edge)
341{
342 return edge < 26 ? 'A' + (char)edge : 'a' + (char)(edge - 26);
343}
344
345STATIC char
346cornertob32(uint8_t corner)
347{
348 uint8_t val;
349
350 val = (corner & 7) | ((corner & 96) >> 2);
351
352 return val < 26 ? 'A' + (char)val : 'a' + (char)(val - 26);
353}
354/******************************************************************************/
diff --git a/src/nissy.c b/src/nissy.c
index dfa1a90..8aa0334 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -17,7 +17,7 @@ long long parse_h48_solver(
17STATIC bool checkdata(const unsigned char *, const tableinfo_t [static 1]); 17STATIC bool checkdata(const unsigned char *, const tableinfo_t [static 1]);
18STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], 18STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN],
19 const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); 19 const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t);
20STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); 20STATIC long long write_result(cube_t, char [static NISSY_SIZE_CUBE]);
21STATIC size_t my_strnlen(const char *, size_t); 21STATIC size_t my_strnlen(const char *, size_t);
22STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); 22STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]);
23STATIC long long nissy_gendata_unsafe( 23STATIC long long nissy_gendata_unsafe(
@@ -117,9 +117,9 @@ distribution_equal(
117} 117}
118 118
119STATIC long long 119STATIC long long
120write_result(cube_t cube, char result[static NISSY_SIZE_B32]) 120write_result(cube_t cube, char result[static NISSY_SIZE_CUBE])
121{ 121{
122 writecube("B32", cube, NISSY_SIZE_B32, result); 122 writecube(cube, NISSY_SIZE_CUBE, result);
123 123
124 if (!issolvable(cube)) { 124 if (!issolvable(cube)) {
125 LOG("Warning: resulting cube is not solvable\n"); 125 LOG("Warning: resulting cube is not solvable\n");
@@ -143,15 +143,15 @@ my_strnlen(const char *str, size_t maxlen)
143 143
144long long 144long long
145nissy_compose( 145nissy_compose(
146 const char cube[static NISSY_SIZE_B32], 146 const char cube[static NISSY_SIZE_CUBE],
147 const char permutation[static NISSY_SIZE_B32], 147 const char permutation[static NISSY_SIZE_CUBE],
148 char result[static NISSY_SIZE_B32] 148 char result[static NISSY_SIZE_CUBE]
149) 149)
150{ 150{
151 cube_t c, p, res; 151 cube_t c, p, res;
152 long long err; 152 long long err;
153 153
154 c = readcube("B32", cube); 154 c = readcube(cube);
155 155
156 if (!isconsistent(c)) { 156 if (!isconsistent(c)) {
157 LOG("[compose] Error: the given cube is invalid\n"); 157 LOG("[compose] Error: the given cube is invalid\n");
@@ -159,7 +159,7 @@ nissy_compose(
159 goto nissy_compose_error; 159 goto nissy_compose_error;
160 } 160 }
161 161
162 p = readcube("B32", permutation); 162 p = readcube(permutation);
163 163
164 if (!isconsistent(p)) { 164 if (!isconsistent(p)) {
165 LOG("[compose] Error: given permutation is invalid\n"); 165 LOG("[compose] Error: given permutation is invalid\n");
@@ -178,20 +178,20 @@ nissy_compose(
178 return write_result(res, result); 178 return write_result(res, result);
179 179
180nissy_compose_error: 180nissy_compose_error:
181 writecube("B32", ZERO_CUBE, NISSY_SIZE_B32, result); 181 writecube(ZERO_CUBE, NISSY_SIZE_CUBE, result);
182 return err; 182 return err;
183} 183}
184 184
185long long 185long long
186nissy_inverse( 186nissy_inverse(
187 const char cube[static NISSY_SIZE_B32], 187 const char cube[static NISSY_SIZE_CUBE],
188 char result[static NISSY_SIZE_B32] 188 char result[static NISSY_SIZE_CUBE]
189) 189)
190{ 190{
191 cube_t c, res; 191 cube_t c, res;
192 long long err; 192 long long err;
193 193
194 c = readcube("B32", cube); 194 c = readcube(cube);
195 195
196 if (iserror(c)) { 196 if (iserror(c)) {
197 LOG("[inverse] Error: the given cube is invalid\n"); 197 LOG("[inverse] Error: the given cube is invalid\n");
@@ -210,15 +210,15 @@ nissy_inverse(
210 return write_result(res, result); 210 return write_result(res, result);
211 211
212nissy_inverse_error: 212nissy_inverse_error:
213 writecube("B32", ZERO_CUBE, NISSY_SIZE_B32, result); 213 writecube(ZERO_CUBE, NISSY_SIZE_CUBE, result);
214 return err; 214 return err;
215} 215}
216 216
217long long 217long long
218nissy_applymoves( 218nissy_applymoves(
219 const char cube[static NISSY_SIZE_B32], 219 const char cube[static NISSY_SIZE_CUBE],
220 const char *moves, 220 const char *moves,
221 char result[static NISSY_SIZE_B32] 221 char result[static NISSY_SIZE_CUBE]
222) 222)
223{ 223{
224 cube_t c, res; 224 cube_t c, res;
@@ -230,7 +230,7 @@ nissy_applymoves(
230 goto nissy_applymoves_error; 230 goto nissy_applymoves_error;
231 } 231 }
232 232
233 c = readcube("B32", cube); 233 c = readcube(cube);
234 234
235 if (!isconsistent(c)) { 235 if (!isconsistent(c)) {
236 LOG("[applymoves] Error: given cube is invalid\n"); 236 LOG("[applymoves] Error: given cube is invalid\n");
@@ -249,21 +249,21 @@ nissy_applymoves(
249 return write_result(res, result); 249 return write_result(res, result);
250 250
251nissy_applymoves_error: 251nissy_applymoves_error:
252 writecube("B32", ZERO_CUBE, NISSY_SIZE_B32, result); 252 writecube(ZERO_CUBE, NISSY_SIZE_CUBE, result);
253 return err; 253 return err;
254} 254}
255 255
256long long 256long long
257nissy_applytrans( 257nissy_applytrans(
258 const char cube[static NISSY_SIZE_B32], 258 const char cube[static NISSY_SIZE_CUBE],
259 const char transformation[static NISSY_SIZE_TRANSFORMATION], 259 const char transformation[static NISSY_SIZE_TRANSFORMATION],
260 char result[static NISSY_SIZE_B32] 260 char result[static NISSY_SIZE_CUBE]
261) 261)
262{ 262{
263 cube_t c, res; 263 cube_t c, res;
264 long long err; 264 long long err;
265 265
266 c = readcube("B32", cube); 266 c = readcube(cube);
267 267
268 if (!isconsistent(c)) { 268 if (!isconsistent(c)) {
269 LOG("[applytrans] Error: given cube is invalid\n"); 269 LOG("[applytrans] Error: given cube is invalid\n");
@@ -282,51 +282,7 @@ nissy_applytrans(
282 return write_result(res, result); 282 return write_result(res, result);
283 283
284nissy_applytrans_error: 284nissy_applytrans_error:
285 writecube("B32", ZERO_CUBE, NISSY_SIZE_B32, result); 285 writecube(ZERO_CUBE, NISSY_SIZE_CUBE, result);
286 return err;
287}
288
289long long
290nissy_convert(
291 const char *format_in,
292 const char *format_out,
293 const char *cube_string,
294 unsigned result_size,
295 char result[result_size]
296)
297{
298 cube_t c;
299 long long err;
300
301 if (format_in == NULL) {
302 LOG("[convert] Error: 'format_in' argument is NULL\n");
303 err = NISSY_ERROR_NULL_POINTER;
304 goto nissy_convert_error;
305 }
306
307 if (format_out == NULL) {
308 LOG("[convert] Error: 'format_out' argument is NULL\n");
309 err = NISSY_ERROR_NULL_POINTER;
310 goto nissy_convert_error;
311 }
312
313 if (cube_string == NULL) {
314 LOG("[convert] Error: 'cube_string' argument is NULL\n");
315 err = NISSY_ERROR_NULL_POINTER;
316 goto nissy_convert_error;
317 }
318
319 c = readcube(format_in, cube_string);
320
321 if (!isconsistent(c)) {
322 err = NISSY_ERROR_INVALID_CUBE;
323 goto nissy_convert_error;
324 }
325
326 return writecube(format_out, c, result_size, result);
327
328nissy_convert_error:
329 result[0] = '\0';
330 return err; 286 return err;
331} 287}
332 288
@@ -337,7 +293,7 @@ nissy_getcube(
337 long long cp, 293 long long cp,
338 long long co, 294 long long co,
339 const char *options, 295 const char *options,
340 char result[static NISSY_SIZE_B32] 296 char result[static NISSY_SIZE_CUBE]
341) 297)
342{ 298{
343 int i; 299 int i;
@@ -526,7 +482,7 @@ nissy_checkdata(
526 482
527long long 483long long
528nissy_solve( 484nissy_solve(
529 const char cube[static NISSY_SIZE_B32], 485 const char cube[static NISSY_SIZE_CUBE],
530 const char *solver, 486 const char *solver,
531 unsigned nissflag, 487 unsigned nissflag,
532 unsigned minmoves, 488 unsigned minmoves,
@@ -551,7 +507,7 @@ nissy_solve(
551 return NISSY_ERROR_NULL_POINTER; 507 return NISSY_ERROR_NULL_POINTER;
552 } 508 }
553 509
554 c = readcube_B32(cube); 510 c = readcube(cube);
555 511
556 if (!isconsistent(c)) { 512 if (!isconsistent(c)) {
557 LOG("[solve] Error: cube is invalid\n"); 513 LOG("[solve] Error: cube is invalid\n");
diff --git a/src/nissy.h b/src/nissy.h
index a5b3015..4b2d1eb 100644
--- a/src/nissy.h
+++ b/src/nissy.h
@@ -2,12 +2,11 @@
2This is libnissy (temporarily also known as h48), a Rubik's cube library. 2This is libnissy (temporarily also known as h48), a Rubik's cube library.
3 3
4All the functions return 0 or a positive integer in case of success and 4All the functions return 0 or a positive integer in case of success and
5a negative integer in case of error, unless otherwise specified. See at 5a negative integer in case of error, unless otherwise specified. See
6the bottom of this file for the list of error codes and their meaning. 6below for the list of error codes and their meaning.
7 7
8All cube arguments are in B32 formats, unless otherwise specified. 8Cubes are passed as strings in the cccccccc=eeeeeeeeeeee=r format,
9Other available formats are H48 and SRC. See README.md for more info on 9see the README.md file for more information.
10these formats.
11 10
12Accepted moves are U, D, R, L, F and B, optionally followed by a 2, 11Accepted moves are U, D, R, L, F and B, optionally followed by a 2,
13a ' or a 3. 12a ' or a 3.
@@ -21,9 +20,7 @@ for example 'rotation UF' or 'mirrored BL'.
21/* Constants *****************************************************************/ 20/* Constants *****************************************************************/
22 21
23/* Some constants for size for I/O buffers */ 22/* Some constants for size for I/O buffers */
24#define NISSY_SIZE_B32 22U 23#define NISSY_SIZE_CUBE 24U
25#define NISSY_SIZE_H48 88U
26#define NISSY_SIZE_CUBE_MAX NISSY_SIZE_H48
27#define NISSY_SIZE_TRANSFORMATION 12U 24#define NISSY_SIZE_TRANSFORMATION 12U
28#define NISSY_SIZE_SOLVE_STATS 10U 25#define NISSY_SIZE_SOLVE_STATS 10U
29#define NISSY_SIZE_DATAID 255U 26#define NISSY_SIZE_DATAID 255U
@@ -37,8 +34,8 @@ for example 'rotation UF' or 'mirrored BL'.
37#define NISSY_NISSFLAG_ALL \ 34#define NISSY_NISSFLAG_ALL \
38 (NISSY_NISSFLAG_NORMAL | NISSY_NISSFLAG_INVERSE | NISSY_NISSFLAG_MIXED) 35 (NISSY_NISSFLAG_NORMAL | NISSY_NISSFLAG_INVERSE | NISSY_NISSFLAG_MIXED)
39 36
40/* The solved cube in B32 format */ 37/* The solved cube */
41#define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL" 38#define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL=A"
42 39
43/* Error codes ***************************************************************/ 40/* Error codes ***************************************************************/
44 41
@@ -58,8 +55,7 @@ provided an unsolvable cube as input.
58 55
59/* 56/*
60The value NISSY_ERROR_INVALID_CUBE means that the provided cube is 57The value NISSY_ERROR_INVALID_CUBE means that the provided cube is
61invalid. It could be written in an unknown format, or in a format 58invalid. It could be written in an unknown format, or be ill-formed.
62different from what specified, or simply ill-formed.
63*/ 59*/
64#define NISSY_ERROR_INVALID_CUBE -10LL 60#define NISSY_ERROR_INVALID_CUBE -10LL
65 61
@@ -85,12 +81,6 @@ is invalid.
85#define NISSY_ERROR_INVALID_TRANS -30LL 81#define NISSY_ERROR_INVALID_TRANS -30LL
86 82
87/* 83/*
88The value NISSY_ERROR_INVALID_FORMAT means that the given format is
89not known.
90*/
91#define NISSY_ERROR_INVALID_FORMAT -40LL
92
93/*
94The value NISSY_ERROR_INVALID_SOLVER means that the given solver is 84The value NISSY_ERROR_INVALID_SOLVER means that the given solver is
95not known. 85not known.
96*/ 86*/
@@ -139,10 +129,10 @@ of this kind to sebastiano@tronto.net. Thanks!
139Apply the secod argument as a permutation on the first argument. 129Apply the secod argument as a permutation on the first argument.
140 130
141Parameters: 131Parameters:
142 cube - The first cube, in B32 format. 132 cube - The first cube.
143 permutation - The second cube, in B32 format. This cube is treated as a 133 permutation - The second cub. This cube is treated as a permutation and
144 permutation and "applied" to the first cube. 134 "applied" to the first cube.
145 result - The return parameter for the resulting cube, in B32 format. 135 result - The return parameter for the resulting cube.
146 136
147Return values: 137Return values:
148 NISSY_OK - The cubes were composed succesfully. 138 NISSY_OK - The cubes were composed succesfully.
@@ -155,17 +145,17 @@ Return values:
155*/ 145*/
156long long 146long long
157nissy_compose( 147nissy_compose(
158 const char cube[static NISSY_SIZE_B32], 148 const char cube[static NISSY_SIZE_CUBE],
159 const char permutation[static NISSY_SIZE_B32], 149 const char permutation[static NISSY_SIZE_CUBE],
160 char result[static NISSY_SIZE_B32] 150 char result[static NISSY_SIZE_CUBE]
161); 151);
162 152
163/* 153/*
164Compute the inverse of the given cube. 154Compute the inverse of the given cube.
165 155
166Parameters: 156Parameters:
167 cube - The cube to be inverted, in B32 format. 157 cube - The cube to be inverted.
168 result - The return parameter for the resulting cube, in B32 format. 158 result - The return parameter for the resulting cube.
169 159
170Return values: 160Return values:
171 NISSY_OK - The cube was inverted succesfully. 161 NISSY_OK - The cube was inverted succesfully.
@@ -177,17 +167,17 @@ Return values:
177*/ 167*/
178long long 168long long
179nissy_inverse( 169nissy_inverse(
180 const char cube[static NISSY_SIZE_B32], 170 const char cube[static NISSY_SIZE_CUBE],
181 char result[static NISSY_SIZE_B32] 171 char result[static NISSY_SIZE_CUBE]
182); 172);
183 173
184/* 174/*
185Apply the given sequence of moves on the given cube. 175Apply the given sequence of moves on the given cube.
186 176
187Parameters: 177Parameters:
188 cube - The cube to move, in B32 format. 178 cube - The cube to move.
189 moves - The moves to apply to the cube. Must be a NULL-terminated string. 179 moves - The moves to apply to the cube. Must be a NULL-terminated string.
190 result - The return parameter for the resulting cube, in B32 format. 180 result - The return parameter for the resulting cube.
191 181
192Return values: 182Return values:
193 NISSY_OK - The moves were applied succesfully. 183 NISSY_OK - The moves were applied succesfully.
@@ -200,18 +190,18 @@ Return values:
200*/ 190*/
201long long 191long long
202nissy_applymoves( 192nissy_applymoves(
203 const char cube[static NISSY_SIZE_B32], 193 const char cube[static NISSY_SIZE_CUBE],
204 const char *moves, 194 const char *moves,
205 char result[static NISSY_SIZE_B32] 195 char result[static NISSY_SIZE_CUBE]
206); 196);
207 197
208/* 198/*
209Apply the single given transformation to the given cube. 199Apply the single given transformation to the given cube.
210 200
211Parameters: 201Parameters:
212 cube - The cube to be transformed, in B32 format. 202 cube - The cube to be transformed.
213 transformation - The transformation in (rotation|mirrored) xy format. 203 transformation - The transformation in "(rotation|mirrored) __" format.
214 result - The return parameter for the resulting cube, in B32 format. 204 result - The return parameter for the resulting cube.
215 205
216Return values: 206Return values:
217 NISSY_OK - The transformation was performed succesfully. 207 NISSY_OK - The transformation was performed succesfully.
@@ -222,37 +212,9 @@ Return values:
222*/ 212*/
223long long 213long long
224nissy_applytrans( 214nissy_applytrans(
225 const char cube[static NISSY_SIZE_B32], 215 const char cube[static NISSY_SIZE_CUBE],
226 const char transformation[static NISSY_SIZE_TRANSFORMATION], 216 const char transformation[static NISSY_SIZE_TRANSFORMATION],
227 char result[static NISSY_SIZE_B32] 217 char result[static NISSY_SIZE_CUBE]
228);
229
230/*
231Convert the given cube between the two given formats.
232
233Parameters:
234 format_in - The input format.
235 format_out - The output format.
236 cube_string - The cube, in format_in format.
237 result_size - The allocated size of the result array.
238 result - Return parameter for the cube in format_out format.
239
240Return values:
241 NISSY_OK - The conversion was performed succesfully.
242 NISSY_ERROR_BUFFER_SIZE - The given buffer is too small for the result.
243 NISSY_ERROR_INVALID_CUBE - The given cube is invalid.
244 NISSY_ERROR_INVALID_FORMAT - At least one of the given formats is invalid.
245 NISSY_ERROR_UNKNOWN - An unknown error occurred.
246 NISSY_ERROR_NULL_POINTER - At least one of 'format_in', 'format_out' or
247 'cube_string' arguments is NULL.
248*/
249long long
250nissy_convert(
251 const char *format_in,
252 const char *format_out,
253 const char *cube_string,
254 unsigned result_size,
255 char result[result_size]
256); 218);
257 219
258/* 220/*
@@ -267,7 +229,7 @@ Parameters:
267 cp - The corner permutation, 0 <= cp <= 40320 (8!) 229 cp - The corner permutation, 0 <= cp <= 40320 (8!)
268 co - The corner orientation, 0 <= co <= 2187 (3^7) 230 co - The corner orientation, 0 <= co <= 2187 (3^7)
269 options - Other options. 231 options - Other options.
270 result - The return parameter for the resulting cube, in B32 format. 232 result - The return parameter for the resulting cube.
271 233
272Return values: 234Return values:
273 NISSY_OK - The cube was generated succesfully. 235 NISSY_OK - The cube was generated succesfully.
@@ -281,7 +243,7 @@ nissy_getcube(
281 long long cp, 243 long long cp,
282 long long co, 244 long long co,
283 const char *options, 245 const char *options,
284 char result[static NISSY_SIZE_B32] 246 char result[static NISSY_SIZE_CUBE]
285); 247);
286 248
287/* 249/*
@@ -354,7 +316,7 @@ nissy_checkdata(
354Solve the given cube using the given solver and options. 316Solve the given cube using the given solver and options.
355 317
356Parameters: 318Parameters:
357 cube - The cube to solver, in B32 format. 319 cube - The cube to solver.
358 solver - The name of the solver. 320 solver - The name of the solver.
359 nissflag - The flags for NISS (linear, inverse, mixed, or combinations). 321 nissflag - The flags for NISS (linear, inverse, mixed, or combinations).
360 minmoves - The minimum number of moves for a solution. 322 minmoves - The minimum number of moves for a solution.
@@ -386,7 +348,7 @@ Return values:
386*/ 348*/
387long long 349long long
388nissy_solve( 350nissy_solve(
389 const char cube[static NISSY_SIZE_B32], 351 const char cube[static NISSY_SIZE_CUBE],
390 const char *solver, 352 const char *solver,
391 unsigned nissflag, 353 unsigned nissflag,
392 unsigned minmoves, 354 unsigned minmoves,
diff --git a/src/core/io_formats.h b/utils/convert.c
index f5668d4..4f4bb8c 100644
--- a/src/core/io_formats.h
+++ b/utils/convert.c
@@ -1,3 +1,9 @@
1/*
2This file contains code related to cube format conversion that used to
3be in src/core. It is to be adapted into a standalone tool for cube
4format conversion.
5*/
6
1STATIC cube_t readcube(const char *, const char *); 7STATIC cube_t readcube(const char *, const char *);
2STATIC int64_t writecube(const char *, cube_t, size_t n, char [n]); 8STATIC int64_t writecube(const char *, cube_t, size_t n, char [n]);
3STATIC void log_available_formats(void); 9STATIC void log_available_formats(void);

Generated with cgit - Back to sebastiano.tronto.net