diff options
| -rwxr-xr-x | build | 3 | ||||
| -rw-r--r-- | cpp/nissy.cpp | 14 | ||||
| -rw-r--r-- | cpp/nissy.h | 10 | ||||
| -rw-r--r-- | python/nissy_module.c | 37 | ||||
| -rw-r--r-- | shell/shell.c | 44 | ||||
| -rw-r--r-- | src/core/core_types.h | 9 | ||||
| -rw-r--r-- | src/core/moves.h | 69 | ||||
| -rw-r--r-- | src/nissy.c | 12 | ||||
| -rw-r--r-- | src/nissy.h | 22 | ||||
| -rw-r--r-- | test/033_inverse_move/inverse_move_tests.c | 4 | ||||
| -rw-r--r-- | test/062_transform_move/transform_move_tests.c | 4 | ||||
| -rw-r--r-- | test/140_appendsolution/appendsolution_tests.c | 4 |
12 files changed, 222 insertions, 10 deletions
| @@ -282,7 +282,8 @@ build_cpp() { | |||
| 282 | fi | 282 | fi |
| 283 | 283 | ||
| 284 | build_nissy || exit 1 | 284 | build_nissy || exit 1 |
| 285 | run $CXX $(odflags) -std=c++20 -o runcpp cpp/nissy.cpp nissy.o $@ | 285 | run $CXX $(odflags) -std=c++20 -o runcpp cpp/nissy.cpp nissy.o $@ \ |
| 286 | || exit 1 | ||
| 286 | run ./runcpp | 287 | run ./runcpp |
| 287 | } | 288 | } |
| 288 | 289 | ||
diff --git a/cpp/nissy.cpp b/cpp/nissy.cpp index 2c290a6..90fcf20 100644 --- a/cpp/nissy.cpp +++ b/cpp/nissy.cpp | |||
| @@ -24,6 +24,7 @@ extern "C" { | |||
| 24 | const unsigned char *, unsigned, char *, long long *, | 24 | const unsigned char *, unsigned, char *, long long *, |
| 25 | int (*)(void *), void *); | 25 | int (*)(void *), void *); |
| 26 | long long nissy_countmoves(const char *); | 26 | long long nissy_countmoves(const char *); |
| 27 | long long nissy_comparemoves(const char *, const char *); | ||
| 27 | long long nissy_setlogger(void (*)(const char *, void *), void *); | 28 | long long nissy_setlogger(void (*)(const char *, void *), void *); |
| 28 | } | 29 | } |
| 29 | 30 | ||
| @@ -53,6 +54,9 @@ namespace nissy { | |||
| 53 | const status status::STOP{1}; | 54 | const status status::STOP{1}; |
| 54 | const status status::PAUSE{2}; | 55 | const status status::PAUSE{2}; |
| 55 | 56 | ||
| 57 | const compare_result compare_result::EQUAL{0}; | ||
| 58 | const compare_result compare_result::DIFFERENT{99}; | ||
| 59 | |||
| 56 | namespace size { | 60 | namespace size { |
| 57 | constexpr size_t CUBE = 24; | 61 | constexpr size_t CUBE = 24; |
| 58 | constexpr size_t TRANSFORMATION = 12; | 62 | constexpr size_t TRANSFORMATION = 12; |
| @@ -210,6 +214,16 @@ namespace nissy { | |||
| 210 | return error{err}; | 214 | return error{err}; |
| 211 | } | 215 | } |
| 212 | 216 | ||
| 217 | std::variant<error, compare_result> | ||
| 218 | compare_moves(const std::string& m1, const std::string& m2) | ||
| 219 | { | ||
| 220 | auto cmp = nissy_comparemoves(m1.c_str(), m2.c_str()); | ||
| 221 | if (cmp < 0) | ||
| 222 | return error{cmp}; | ||
| 223 | else | ||
| 224 | return compare_result{cmp}; | ||
| 225 | } | ||
| 226 | |||
| 213 | void set_logger(void (*log)(const char *, void *), void *data) | 227 | void set_logger(void (*log)(const char *, void *), void *data) |
| 214 | { | 228 | { |
| 215 | nissy_setlogger(log, data); | 229 | nissy_setlogger(log, data); |
diff --git a/cpp/nissy.h b/cpp/nissy.h index 817307c..199af10 100644 --- a/cpp/nissy.h +++ b/cpp/nissy.h | |||
| @@ -55,6 +55,14 @@ namespace nissy { | |||
| 55 | static const status PAUSE; | 55 | static const status PAUSE; |
| 56 | }; | 56 | }; |
| 57 | 57 | ||
| 58 | class compare_result { | ||
| 59 | public: | ||
| 60 | long long value; | ||
| 61 | |||
| 62 | static const compare_result EQUAL; | ||
| 63 | static const compare_result DIFFERENT; | ||
| 64 | }; | ||
| 65 | |||
| 58 | class cube { | 66 | class cube { |
| 59 | public: | 67 | public: |
| 60 | cube(); | 68 | cube(); |
| @@ -103,6 +111,8 @@ namespace nissy { | |||
| 103 | }; | 111 | }; |
| 104 | 112 | ||
| 105 | error count_moves(const std::string&); | 113 | error count_moves(const std::string&); |
| 114 | std::variant<error, compare_result> compare_moves( | ||
| 115 | const std::string&, const std::string&); | ||
| 106 | void set_logger(void (*)(const char *, void *), void *); | 116 | void set_logger(void (*)(const char *, void *), void *); |
| 107 | } | 117 | } |
| 108 | 118 | ||
diff --git a/python/nissy_module.c b/python/nissy_module.c index 3e5ea08..a86b23f 100644 --- a/python/nissy_module.c +++ b/python/nissy_module.c | |||
| @@ -345,6 +345,42 @@ countmoves(PyObject *self, PyObject *args) | |||
| 345 | return long_result(count); | 345 | return long_result(count); |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | PyDoc_STRVAR(comparemoves_doc, | ||
| 349 | "comparemoves(moves1, moves2)\n" | ||
| 350 | "--\n\n" | ||
| 351 | "Compare the two move sequences\n" | ||
| 352 | "\n" | ||
| 353 | "Parameters:\n" | ||
| 354 | " - moves1: the first sequence of moves\n" | ||
| 355 | " - moves2: the second sequence of moves\n" | ||
| 356 | "\n" | ||
| 357 | "Returns: a string describing how the two moves sequences compare. " | ||
| 358 | "This can be one of:\n" | ||
| 359 | "\"EQUAL\" - The two sequences are equal up to swapping parallel moves\n" | ||
| 360 | "\"DIFFERENT\" - The two sequences are different\n" | ||
| 361 | ); | ||
| 362 | PyObject * | ||
| 363 | comparemoves(PyObject *self, PyObject *args) | ||
| 364 | { | ||
| 365 | long long cmp; | ||
| 366 | const char *m1, *m2; | ||
| 367 | |||
| 368 | if (!PyArg_ParseTuple(args, "ss", &m1, &m2)) | ||
| 369 | return NULL; | ||
| 370 | |||
| 371 | if ((cmp = nissy_comparemoves(m1, m2)) < 0) | ||
| 372 | return long_result(cmp); | ||
| 373 | |||
| 374 | switch (cmp) { | ||
| 375 | case NISSY_COMPARE_MOVES_EQUAL: | ||
| 376 | return string_result(cmp, "EQUAL"); | ||
| 377 | case NISSY_COMPARE_MOVES_DIFFERENT: | ||
| 378 | return string_result(cmp, "DIFFERENT"); | ||
| 379 | default: | ||
| 380 | return long_result(cmp); | ||
| 381 | } | ||
| 382 | } | ||
| 383 | |||
| 348 | static PyMethodDef nissy_methods[] = { | 384 | static PyMethodDef nissy_methods[] = { |
| 349 | { "inverse", inverse, METH_VARARGS, inverse_doc }, | 385 | { "inverse", inverse, METH_VARARGS, inverse_doc }, |
| 350 | { "applymoves", applymoves, METH_VARARGS, applymoves_doc }, | 386 | { "applymoves", applymoves, METH_VARARGS, applymoves_doc }, |
| @@ -355,6 +391,7 @@ static PyMethodDef nissy_methods[] = { | |||
| 355 | { "checkdata", checkdata, METH_VARARGS, checkdata_doc }, | 391 | { "checkdata", checkdata, METH_VARARGS, checkdata_doc }, |
| 356 | { "solve", solve, METH_VARARGS, solve_doc }, | 392 | { "solve", solve, METH_VARARGS, solve_doc }, |
| 357 | { "countmoves", countmoves, METH_VARARGS, countmoves_doc }, | 393 | { "countmoves", countmoves, METH_VARARGS, countmoves_doc }, |
| 394 | { "comparemoves", comparemoves, METH_VARARGS, comparemoves_doc }, | ||
| 358 | { NULL, NULL, 0, NULL } | 395 | { NULL, NULL, 0, NULL } |
| 359 | }; | 396 | }; |
| 360 | 397 | ||
diff --git a/shell/shell.c b/shell/shell.c index a9a1bc7..8800094 100644 --- a/shell/shell.c +++ b/shell/shell.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #define FLAG_COMMAND "-command" | 18 | #define FLAG_COMMAND "-command" |
| 19 | #define FLAG_STR_CUBE "-cubestr" | 19 | #define FLAG_STR_CUBE "-cubestr" |
| 20 | #define FLAG_MOVES "-moves" | 20 | #define FLAG_MOVES "-moves" |
| 21 | #define FLAG_MOVES2 "-moves2" | ||
| 21 | #define FLAG_TRANS "-trans" | 22 | #define FLAG_TRANS "-trans" |
| 22 | #define FLAG_SOLVER "-solver" | 23 | #define FLAG_SOLVER "-solver" |
| 23 | #define FLAG_NISSTYPE "-nisstype" | 24 | #define FLAG_NISSTYPE "-nisstype" |
| @@ -39,6 +40,7 @@ typedef struct { | |||
| 39 | char *str_command; | 40 | char *str_command; |
| 40 | char *str_cube; | 41 | char *str_cube; |
| 41 | char *str_moves; | 42 | char *str_moves; |
| 43 | char *str_moves2; | ||
| 42 | char *str_trans; | 44 | char *str_trans; |
| 43 | char *str_solver; | 45 | char *str_solver; |
| 44 | char *str_nisstype; | 46 | char *str_nisstype; |
| @@ -59,6 +61,7 @@ static int64_t gendata_exec(args_t *); | |||
| 59 | static int64_t solve_exec(args_t *); | 61 | static int64_t solve_exec(args_t *); |
| 60 | static int64_t solve_scramble_exec(args_t *); | 62 | static int64_t solve_scramble_exec(args_t *); |
| 61 | static int64_t countmoves_exec(args_t *); | 63 | static int64_t countmoves_exec(args_t *); |
| 64 | static int64_t comparemoves_exec(args_t *); | ||
| 62 | static int64_t help_exec(args_t *); | 65 | static int64_t help_exec(args_t *); |
| 63 | 66 | ||
| 64 | static int parse_args(int, char **, args_t *); | 67 | static int parse_args(int, char **, args_t *); |
| @@ -69,6 +72,7 @@ static bool set_cube(int, char **, args_t *); | |||
| 69 | static bool set_str_command(int, char **, args_t *); | 72 | static bool set_str_command(int, char **, args_t *); |
| 70 | static bool set_str_cube(int, char **, args_t *); | 73 | static bool set_str_cube(int, char **, args_t *); |
| 71 | static bool set_str_moves(int, char **, args_t *); | 74 | static bool set_str_moves(int, char **, args_t *); |
| 75 | static bool set_str_moves2(int, char **, args_t *); | ||
| 72 | static bool set_str_trans(int, char **, args_t *); | 76 | static bool set_str_trans(int, char **, args_t *); |
| 73 | static bool set_str_solver(int, char **, args_t *); | 77 | static bool set_str_solver(int, char **, args_t *); |
| 74 | static bool set_str_nisstype(int, char **, args_t *); | 78 | static bool set_str_nisstype(int, char **, args_t *); |
| @@ -91,6 +95,7 @@ struct { | |||
| 91 | OPTION(FLAG_COMMAND, 1, set_str_command), | 95 | OPTION(FLAG_COMMAND, 1, set_str_command), |
| 92 | OPTION(FLAG_STR_CUBE, 1, set_str_cube), | 96 | OPTION(FLAG_STR_CUBE, 1, set_str_cube), |
| 93 | OPTION(FLAG_MOVES, 1, set_str_moves), | 97 | OPTION(FLAG_MOVES, 1, set_str_moves), |
| 98 | OPTION(FLAG_MOVES2, 1, set_str_moves2), | ||
| 94 | OPTION(FLAG_TRANS, 1, set_str_trans), | 99 | OPTION(FLAG_TRANS, 1, set_str_trans), |
| 95 | OPTION(FLAG_SOLVER, 1, set_str_solver), | 100 | OPTION(FLAG_SOLVER, 1, set_str_solver), |
| 96 | OPTION(FLAG_NISSTYPE, 1, set_str_nisstype), | 101 | OPTION(FLAG_NISSTYPE, 1, set_str_nisstype), |
| @@ -185,6 +190,13 @@ struct { | |||
| 185 | countmoves_exec | 190 | countmoves_exec |
| 186 | ), | 191 | ), |
| 187 | COMMAND( | 192 | COMMAND( |
| 193 | "compare", | ||
| 194 | "compare " FLAG_MOVES " MOVES " FLAG_MOVES2 " MOVES2", | ||
| 195 | "Compare the two move sequences." | ||
| 196 | INFO_MOVESFORMAT, | ||
| 197 | comparemoves_exec | ||
| 198 | ), | ||
| 199 | COMMAND( | ||
| 188 | "help", | 200 | "help", |
| 189 | "help [" FLAG_COMMAND " COMMAND]", | 201 | "help [" FLAG_COMMAND " COMMAND]", |
| 190 | "If no COMMAND is specified, prints some generic information " | 202 | "If no COMMAND is specified, prints some generic information " |
| @@ -476,6 +488,29 @@ countmoves_exec(args_t *args) | |||
| 476 | } | 488 | } |
| 477 | 489 | ||
| 478 | static int64_t | 490 | static int64_t |
| 491 | comparemoves_exec(args_t *args) | ||
| 492 | { | ||
| 493 | long long cmp; | ||
| 494 | |||
| 495 | if ((cmp = nissy_comparemoves(args->str_moves, args->str_moves2)) < 0) | ||
| 496 | return cmp; | ||
| 497 | |||
| 498 | switch (cmp) { | ||
| 499 | case NISSY_COMPARE_MOVES_EQUAL: | ||
| 500 | printf("The two move sequences are equal\n"); | ||
| 501 | break; | ||
| 502 | case NISSY_COMPARE_MOVES_DIFFERENT: | ||
| 503 | printf("The two move sequences are different\n"); | ||
| 504 | break; | ||
| 505 | default: | ||
| 506 | printf("Error: unknown case\n"); | ||
| 507 | return -1; | ||
| 508 | } | ||
| 509 | |||
| 510 | return 0; | ||
| 511 | } | ||
| 512 | |||
| 513 | static int64_t | ||
| 479 | help_exec(args_t *args) | 514 | help_exec(args_t *args) |
| 480 | { | 515 | { |
| 481 | int i; | 516 | int i; |
| @@ -512,6 +547,7 @@ parse_args(int argc, char **argv, args_t *args) | |||
| 512 | .cube = "", | 547 | .cube = "", |
| 513 | .str_cube = "", | 548 | .str_cube = "", |
| 514 | .str_moves = "", | 549 | .str_moves = "", |
| 550 | .str_moves2 = "", | ||
| 515 | .str_trans = "", | 551 | .str_trans = "", |
| 516 | .str_solver = "", | 552 | .str_solver = "", |
| 517 | .str_nisstype = "", | 553 | .str_nisstype = "", |
| @@ -632,6 +668,14 @@ set_str_moves(int argc, char **argv, args_t *args) | |||
| 632 | } | 668 | } |
| 633 | 669 | ||
| 634 | static bool | 670 | static bool |
| 671 | set_str_moves2(int argc, char **argv, args_t *args) | ||
| 672 | { | ||
| 673 | args->str_moves2 = argv[0]; | ||
| 674 | |||
| 675 | return true; | ||
| 676 | } | ||
| 677 | |||
| 678 | static bool | ||
| 635 | set_str_trans(int argc, char **argv, args_t *args) | 679 | set_str_trans(int argc, char **argv, args_t *args) |
| 636 | { | 680 | { |
| 637 | args->str_trans = argv[0]; | 681 | args->str_trans = argv[0]; |
diff --git a/src/core/core_types.h b/src/core/core_types.h index 2ad8938..19a9f42 100644 --- a/src/core/core_types.h +++ b/src/core/core_types.h | |||
| @@ -1,4 +1,13 @@ | |||
| 1 | #define MOVES_STRUCT_MAXLEN 1000 | ||
| 2 | |||
| 1 | typedef struct { | 3 | typedef struct { |
| 2 | cube_t cube; | 4 | cube_t cube; |
| 3 | uint8_t orientation; | 5 | uint8_t orientation; |
| 4 | } oriented_cube_t; | 6 | } oriented_cube_t; |
| 7 | |||
| 8 | typedef struct { | ||
| 9 | size_t nnormal; | ||
| 10 | size_t ninverse; | ||
| 11 | uint8_t normal[MOVES_STRUCT_MAXLEN]; | ||
| 12 | uint8_t inverse[MOVES_STRUCT_MAXLEN]; | ||
| 13 | } moves_struct_t; | ||
diff --git a/src/core/moves.h b/src/core/moves.h index d3ff4a3..9c8cc90 100644 --- a/src/core/moves.h +++ b/src/core/moves.h | |||
| @@ -3,8 +3,12 @@ | |||
| 3 | 3 | ||
| 4 | STATIC uint8_t readmove(char); | 4 | STATIC uint8_t readmove(char); |
| 5 | STATIC int64_t readmoves(const char *, | 5 | STATIC int64_t readmoves(const char *, |
| 6 | size_t, size_t, uint64_t *, uint64_t *, uint8_t *, uint8_t *); | 6 | size_t, size_t, size_t *, size_t *, uint8_t *, uint8_t *); |
| 7 | STATIC int64_t readmoves_struct(const char *, moves_struct_t [static 1]); | ||
| 7 | STATIC int64_t countmoves(const char *); | 8 | STATIC int64_t countmoves(const char *); |
| 9 | STATIC bool moves_struct_equal( | ||
| 10 | const moves_struct_t [static 1], const moves_struct_t [static 1]); | ||
| 11 | STATIC long long comparemoves(const char *, const char *); | ||
| 8 | STATIC uint8_t readmodifier(char); | 12 | STATIC uint8_t readmodifier(char); |
| 9 | STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *); | 13 | STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *); |
| 10 | 14 | ||
| @@ -124,8 +128,8 @@ readmoves( | |||
| 124 | const char *buf, | 128 | const char *buf, |
| 125 | size_t nsize, | 129 | size_t nsize, |
| 126 | size_t invsize, | 130 | size_t invsize, |
| 127 | uint64_t *n, | 131 | size_t *n, |
| 128 | uint64_t *i, | 132 | size_t *i, |
| 129 | uint8_t *normal, | 133 | uint8_t *normal, |
| 130 | uint8_t *inverse | 134 | uint8_t *inverse |
| 131 | ) | 135 | ) |
| @@ -154,6 +158,13 @@ readmoves( | |||
| 154 | } | 158 | } |
| 155 | 159 | ||
| 156 | STATIC int64_t | 160 | STATIC int64_t |
| 161 | readmoves_struct(const char *moves, moves_struct_t ret[static 1]) | ||
| 162 | { | ||
| 163 | return readmoves(moves, MOVES_STRUCT_MAXLEN, MOVES_STRUCT_MAXLEN, | ||
| 164 | &ret->nnormal, &ret->ninverse, ret->normal, ret->inverse); | ||
| 165 | } | ||
| 166 | |||
| 167 | STATIC int64_t | ||
| 157 | countmoves(const char *buf) | 168 | countmoves(const char *buf) |
| 158 | { | 169 | { |
| 159 | uint8_t m; | 170 | uint8_t m; |
| @@ -168,6 +179,58 @@ countmoves(const char *buf) | |||
| 168 | return count; | 179 | return count; |
| 169 | } | 180 | } |
| 170 | 181 | ||
| 182 | STATIC bool | ||
| 183 | moves_struct_equal( | ||
| 184 | const moves_struct_t ms1[static 1], | ||
| 185 | const moves_struct_t ms2[static 1] | ||
| 186 | ) | ||
| 187 | { | ||
| 188 | size_t i; | ||
| 189 | |||
| 190 | if (ms1->nnormal != ms2->nnormal || ms1->ninverse != ms2->ninverse) | ||
| 191 | return false; | ||
| 192 | |||
| 193 | for (i = 0; i < ms1->nnormal; i++) | ||
| 194 | if (ms1->normal[i] != ms2->normal[i]) | ||
| 195 | return false; | ||
| 196 | |||
| 197 | for (i = 0; i < ms1->ninverse; i++) | ||
| 198 | if (ms1->inverse[i] != ms2->inverse[i]) | ||
| 199 | return false; | ||
| 200 | |||
| 201 | return true; | ||
| 202 | } | ||
| 203 | |||
| 204 | STATIC long long | ||
| 205 | comparemoves(const char *moves1, const char *moves2) | ||
| 206 | { | ||
| 207 | int64_t err; | ||
| 208 | moves_struct_t ms1, ms2; | ||
| 209 | |||
| 210 | if ((err = readmoves_struct(moves1, &ms1)) < 0) | ||
| 211 | return err; | ||
| 212 | sortparallel_moves(ms1.nnormal, ms1.normal); | ||
| 213 | sortparallel_moves(ms1.ninverse, ms1.inverse); | ||
| 214 | |||
| 215 | if ((err = readmoves_struct(moves2, &ms2)) < 0) | ||
| 216 | return err; | ||
| 217 | sortparallel_moves(ms2.nnormal, ms2.normal); | ||
| 218 | sortparallel_moves(ms2.ninverse, ms2.inverse); | ||
| 219 | |||
| 220 | if (moves_struct_equal(&ms1, &ms2)) | ||
| 221 | return NISSY_COMPARE_MOVES_EQUAL; | ||
| 222 | |||
| 223 | /* | ||
| 224 | TODO: more types of move comparison | ||
| 225 | - up to moving rotations around | ||
| 226 | - up to rotation | ||
| 227 | - up transformation (including mirror or not including it) | ||
| 228 | - ... | ||
| 229 | */ | ||
| 230 | |||
| 231 | return NISSY_COMPARE_MOVES_DIFFERENT; | ||
| 232 | } | ||
| 233 | |||
| 171 | STATIC int64_t | 234 | STATIC int64_t |
| 172 | writemoves( | 235 | writemoves( |
| 173 | size_t nmoves, | 236 | size_t nmoves, |
diff --git a/src/nissy.c b/src/nissy.c index 93a4841..4b5d476 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -354,6 +354,18 @@ nissy_countmoves( | |||
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | long long | 356 | long long |
| 357 | nissy_comparemoves( | ||
| 358 | const char *moves1, | ||
| 359 | const char *moves2 | ||
| 360 | ) | ||
| 361 | { | ||
| 362 | if (moves1 == NULL || moves2 == NULL) | ||
| 363 | return NISSY_ERROR_NULL_POINTER; | ||
| 364 | |||
| 365 | return comparemoves(moves1, moves2); | ||
| 366 | } | ||
| 367 | |||
| 368 | long long | ||
| 357 | nissy_setlogger( | 369 | nissy_setlogger( |
| 358 | void (*log)(const char *, void *), | 370 | void (*log)(const char *, void *), |
| 359 | void *user_data | 371 | void *user_data |
diff --git a/src/nissy.h b/src/nissy.h index 0c1d18d..38fe656 100644 --- a/src/nissy.h +++ b/src/nissy.h | |||
| @@ -42,6 +42,10 @@ for example 'rotation UF' or 'mirrored BL'. | |||
| 42 | #define NISSY_STATUS_STOP 1 | 42 | #define NISSY_STATUS_STOP 1 |
| 43 | #define NISSY_STATUS_PAUSE 2 | 43 | #define NISSY_STATUS_PAUSE 2 |
| 44 | 44 | ||
| 45 | /* Possible results of move sequence comparison */ | ||
| 46 | #define NISSY_COMPARE_MOVES_EQUAL 0 | ||
| 47 | #define NISSY_COMPARE_MOVES_DIFFERENT 99 | ||
| 48 | |||
| 45 | /* The solved cube */ | 49 | /* The solved cube */ |
| 46 | #define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL=A" | 50 | #define NISSY_SOLVED_CUBE "ABCDEFGH=ABCDEFGHIJKL=A" |
| 47 | 51 | ||
| @@ -375,6 +379,24 @@ nissy_countmoves( | |||
| 375 | ); | 379 | ); |
| 376 | 380 | ||
| 377 | /* | 381 | /* |
| 382 | Parameters: | ||
| 383 | moves1 - The first sequence of moves to compare. | ||
| 384 | moves2 - The second sequence of moves to compare. | ||
| 385 | |||
| 386 | Return values: | ||
| 387 | NISSY_ERROR_INVALID_MOVES - One of the given moves sequences is invalid. | ||
| 388 | NISSY_ERROR_NULL_POINTER - One of the arguments is NULL. | ||
| 389 | NISSY_COMPARE_MOVES_EQUAL - The two moves sequences are indentical, up | ||
| 390 | to swapping parallel moves. | ||
| 391 | NISSY_COMPARE_MOVES_DIFFERENT - The two moves sequences are different. | ||
| 392 | */ | ||
| 393 | long long | ||
| 394 | nissy_comparemoves( | ||
| 395 | const char *moves1, | ||
| 396 | const char *moves2 | ||
| 397 | ); | ||
| 398 | |||
| 399 | /* | ||
| 378 | Set a global logger function used by this library. Setting the logger to NULL | 400 | Set a global logger function used by this library. Setting the logger to NULL |
| 379 | disables logging. | 401 | disables logging. |
| 380 | 402 | ||
diff --git a/test/033_inverse_move/inverse_move_tests.c b/test/033_inverse_move/inverse_move_tests.c index e9bad0c..5453f83 100644 --- a/test/033_inverse_move/inverse_move_tests.c +++ b/test/033_inverse_move/inverse_move_tests.c | |||
| @@ -3,11 +3,11 @@ | |||
| 3 | extern char *movestr[]; | 3 | extern char *movestr[]; |
| 4 | 4 | ||
| 5 | int64_t readmoves(const char *, size_t n, size_t m, | 5 | int64_t readmoves(const char *, size_t n, size_t m, |
| 6 | uint64_t *, uint64_t *, uint8_t [n], uint8_t [m]); | 6 | size_t *, size_t *, uint8_t [n], uint8_t [m]); |
| 7 | uint8_t inverse_move(uint8_t); | 7 | uint8_t inverse_move(uint8_t); |
| 8 | 8 | ||
| 9 | void run(void) { | 9 | void run(void) { |
| 10 | uint64_t inv, nor; | 10 | size_t inv, nor; |
| 11 | int64_t tot; | 11 | int64_t tot; |
| 12 | uint8_t moves[2]; | 12 | uint8_t moves[2]; |
| 13 | 13 | ||
diff --git a/test/062_transform_move/transform_move_tests.c b/test/062_transform_move/transform_move_tests.c index 17cb0b6..218c6a1 100644 --- a/test/062_transform_move/transform_move_tests.c +++ b/test/062_transform_move/transform_move_tests.c | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | cube_t applytrans(cube_t, const char *); | 5 | cube_t applytrans(cube_t, const char *); |
| 6 | uint8_t transform_move(uint8_t, uint8_t); | 6 | uint8_t transform_move(uint8_t, uint8_t); |
| 7 | int64_t readmoves(const char *, size_t n, size_t m, | 7 | int64_t readmoves(const char *, size_t n, size_t m, |
| 8 | uint64_t *, uint64_t *, uint8_t [n], uint8_t [m]); | 8 | size_t *, size_t *, uint8_t [n], uint8_t [m]); |
| 9 | oriented_cube_t move_extended(oriented_cube_t, uint8_t); | 9 | oriented_cube_t move_extended(oriented_cube_t, uint8_t); |
| 10 | oriented_cube_t applymoves(oriented_cube_t, const char *); | 10 | oriented_cube_t applymoves(oriented_cube_t, const char *); |
| 11 | uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]); | 11 | uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]); |
| @@ -13,7 +13,7 @@ uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]); | |||
| 13 | void run(void) { | 13 | void run(void) { |
| 14 | char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX]; | 14 | char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX]; |
| 15 | uint8_t t, moves[MAXMOVES]; | 15 | uint8_t t, moves[MAXMOVES]; |
| 16 | uint64_t i, n, ninv; | 16 | size_t i, n, ninv; |
| 17 | int64_t tot; | 17 | int64_t tot; |
| 18 | oriented_cube_t cube; | 18 | oriented_cube_t cube; |
| 19 | 19 | ||
diff --git a/test/140_appendsolution/appendsolution_tests.c b/test/140_appendsolution/appendsolution_tests.c index c9cd81f..d4c2a1f 100644 --- a/test/140_appendsolution/appendsolution_tests.c +++ b/test/140_appendsolution/appendsolution_tests.c | |||
| @@ -14,7 +14,7 @@ See below for the output format. | |||
| 14 | 14 | ||
| 15 | uint8_t readtrans(const char [NISSY_SIZE_TRANSFORMATION]); | 15 | uint8_t readtrans(const char [NISSY_SIZE_TRANSFORMATION]); |
| 16 | int64_t readmoves(const char *, size_t n, size_t m, | 16 | int64_t readmoves(const char *, size_t n, size_t m, |
| 17 | uint64_t *, uint64_t *, uint8_t [n], uint8_t [m]); | 17 | size_t *, size_t *, uint8_t [n], uint8_t [m]); |
| 18 | void solution_moves_reset(solution_moves_t [static 1]); | 18 | void solution_moves_reset(solution_moves_t [static 1]); |
| 19 | bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); | 19 | bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); |
| 20 | int64_t appendsolution(const solution_moves_t [static 1], | 20 | int64_t appendsolution(const solution_moves_t [static 1], |
| @@ -23,7 +23,7 @@ int64_t appendsolution(const solution_moves_t [static 1], | |||
| 23 | void run(void) { | 23 | void run(void) { |
| 24 | int i, ntrans; | 24 | int i, ntrans; |
| 25 | int64_t tot; | 25 | int64_t tot; |
| 26 | uint64_t nm, np; | 26 | size_t nm, np; |
| 27 | char str[STRLENMAX], buf[STRLENMAX]; | 27 | char str[STRLENMAX], buf[STRLENMAX]; |
| 28 | solution_moves_t moves; | 28 | solution_moves_t moves; |
| 29 | solution_settings_t settings; | 29 | solution_settings_t settings; |
