From 5355de2921126e2b75e24abd57e17556e22a6ed0 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 7 Aug 2025 15:09:46 +0200 Subject: Added API function for solution variations --- src/nissy.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/nissy.h') diff --git a/src/nissy.h b/src/nissy.h index 38fe656..959b2d8 100644 --- a/src/nissy.h +++ b/src/nissy.h @@ -27,6 +27,7 @@ for example 'rotation UF' or 'mirrored BL'. #define NISSY_SIZE_TRANSFORMATION 12U #define NISSY_SIZE_SOLVE_STATS 10U #define NISSY_SIZE_DATAID 255U +#define NISSY_SIZE_MOVES 1000U /* Flags for NISS options */ #define NISSY_NISSFLAG_NORMAL 1U @@ -98,6 +99,12 @@ not known. */ #define NISSY_ERROR_INVALID_SOLVER -50LL +/* +The value NISSY_ERROR_INVALID_VARIATION means that the given method of +finding variations for a solution is not known. +*/ +#define NISSY_ERROR_INVALID_VARIATION -51LL + /* The value NISSY_ERROR_NULL_POINTER means that one of the provided pointer arguments is NULL. For example, it may be returned by solve when called @@ -204,6 +211,36 @@ nissy_applytrans( char result[static NISSY_SIZE_CUBE] ); +/* +Find variations of a given move sequence, for example by changing +the direction of the last quarter turn(s), or linearizing a NISS move +sequence. The result consists of one or more move sequences, one per line, +and it always ends in a newline character. + +Parameters: + moves - The moves of which to find the variation. Must be at most + NISSY_SIZE_MOVES long. + variations - Specify which kind of variations to find, e.g. "lastqt". + result_size - The size of the result buffer. + result - The result buffer. + +Return values: + NISSY_ERROR_NULL_POINTER - One of the provided pointers is NULL. + NISSY_ERROR_INVALID_MOVES - The given moves are invalid. + NISSY_ERROR_INVALID_VARIATION - The given transformer is not known. + NISSY_ERROR_BUFFER_SIZE - Either the result buffer is too small or the + given move sequence is longer than + NISSY_SIZE_MOVES. + Any value >= 0 - The number of variations found. +*/ +long long +nissy_variations( + const char *moves, + const char *variation, + unsigned long long result_size, + char *result +); + /* Get the cube with the given ep, eo, cp and co values. The values must be in the ranges specified below, but if the option "fix" is given any values outside its @@ -365,6 +402,8 @@ nissy_solve( ); /* +Count the given moves. + Parameters: moves - The moves to be counted. @@ -379,6 +418,8 @@ nissy_countmoves( ); /* +Compare the two moves sequences. Both must be at most NISSY_SIZE_MOVES long. + Parameters: moves1 - The first sequence of moves to compare. moves2 - The second sequence of moves to compare. -- cgit v1.3