diff options
Diffstat (limited to '')
| -rw-r--r-- | python/nissy_module.c | 37 |
1 files changed, 37 insertions, 0 deletions
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 | ||
