diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-03-19 17:16:41 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-03-19 17:16:41 +0100 |
| commit | 0550a16c1cce868bbc3f3b5ad59f80e35cf2a6cd (patch) | |
| tree | 3051a8267f1050e172d5e799ef0c20fb608d9a74 /src/core/moves.h | |
| parent | ab95e3801f6659aa6b25ebd9a69b2e23dded130e (diff) | |
| download | nissy-core-0550a16c1cce868bbc3f3b5ad59f80e35cf2a6cd.tar.gz nissy-core-0550a16c1cce868bbc3f3b5ad59f80e35cf2a6cd.zip | |
Filter solutions for coordinate solver and fix ordering
Diffstat (limited to 'src/core/moves.h')
| -rw-r--r-- | src/core/moves.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/core/moves.h b/src/core/moves.h index 3a1158b..a45bc05 100644 --- a/src/core/moves.h +++ b/src/core/moves.h | |||
| @@ -6,6 +6,8 @@ STATIC_INLINE uint32_t allowednextmove_mask(uint8_t *, uint8_t); | |||
| 6 | 6 | ||
| 7 | STATIC_INLINE uint8_t movebase(uint8_t); | 7 | STATIC_INLINE uint8_t movebase(uint8_t); |
| 8 | STATIC_INLINE uint8_t moveaxis(uint8_t); | 8 | STATIC_INLINE uint8_t moveaxis(uint8_t); |
| 9 | STATIC_INLINE bool isbase(uint8_t); | ||
| 10 | STATIC_INLINE bool parallel(uint8_t, uint8_t); | ||
| 9 | STATIC_INLINE uint32_t disable_moves(uint32_t, uint8_t); | 11 | STATIC_INLINE uint32_t disable_moves(uint32_t, uint8_t); |
| 10 | 12 | ||
| 11 | STATIC cube_t move(cube_t, uint8_t); | 13 | STATIC cube_t move(cube_t, uint8_t); |
| @@ -13,6 +15,7 @@ STATIC cube_t premove(cube_t, uint8_t); | |||
| 13 | STATIC uint8_t inverse_move(uint8_t); | 15 | STATIC uint8_t inverse_move(uint8_t); |
| 14 | STATIC void invertmoves(uint8_t *, uint8_t, uint8_t *); | 16 | STATIC void invertmoves(uint8_t *, uint8_t, uint8_t *); |
| 15 | STATIC void sortparallel(uint8_t *, uint8_t); | 17 | STATIC void sortparallel(uint8_t *, uint8_t); |
| 18 | STATIC bool are_lastmoves_singlecw(int n, uint8_t [n]); | ||
| 16 | 19 | ||
| 17 | STATIC int readmoves(const char *, int, uint8_t *); | 20 | STATIC int readmoves(const char *, int, uint8_t *); |
| 18 | STATIC cube_t applymoves(cube_t, const char *); | 21 | STATIC cube_t applymoves(cube_t, const char *); |
| @@ -91,6 +94,18 @@ moveaxis(uint8_t move) | |||
| 91 | return move / 6; | 94 | return move / 6; |
| 92 | } | 95 | } |
| 93 | 96 | ||
| 97 | STATIC_INLINE bool | ||
| 98 | isbase(uint8_t move) | ||
| 99 | { | ||
| 100 | return move == 3 * movebase(move); | ||
| 101 | } | ||
| 102 | |||
| 103 | STATIC_INLINE bool | ||
| 104 | parallel(uint8_t m1, uint8_t m2) | ||
| 105 | { | ||
| 106 | return moveaxis(m1) == moveaxis(m2); | ||
| 107 | } | ||
| 108 | |||
| 94 | STATIC_INLINE uint8_t | 109 | STATIC_INLINE uint8_t |
| 95 | moveopposite(uint8_t move) | 110 | moveopposite(uint8_t move) |
| 96 | { | 111 | { |
| @@ -241,6 +256,19 @@ sortparallel(uint8_t *moves, uint8_t n) | |||
| 241 | SWAP(moves[i], moves[i+1]); | 256 | SWAP(moves[i], moves[i+1]); |
| 242 | } | 257 | } |
| 243 | 258 | ||
| 259 | STATIC bool | ||
| 260 | are_lastmoves_singlecw(int n, uint8_t moves[n]) | ||
| 261 | { | ||
| 262 | bool two; | ||
| 263 | |||
| 264 | if (n == 0) | ||
| 265 | return true; | ||
| 266 | |||
| 267 | two = n > 1 && parallel(moves[n-1], moves[n-2]); | ||
| 268 | |||
| 269 | return isbase(moves[n-1]) && (!two || isbase(moves[n-2])); | ||
| 270 | } | ||
| 271 | |||
| 244 | STATIC int | 272 | STATIC int |
| 245 | readmoves(const char *buf, int max, uint8_t *ret) | 273 | readmoves(const char *buf, int max, uint8_t *ret) |
| 246 | { | 274 | { |
