aboutsummaryrefslogtreecommitdiff
path: root/src/core/moves.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-03-19 17:16:41 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-03-19 17:16:41 +0100
commit0550a16c1cce868bbc3f3b5ad59f80e35cf2a6cd (patch)
tree3051a8267f1050e172d5e799ef0c20fb608d9a74 /src/core/moves.h
parentab95e3801f6659aa6b25ebd9a69b2e23dded130e (diff)
downloadnissy-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.h28
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
7STATIC_INLINE uint8_t movebase(uint8_t); 7STATIC_INLINE uint8_t movebase(uint8_t);
8STATIC_INLINE uint8_t moveaxis(uint8_t); 8STATIC_INLINE uint8_t moveaxis(uint8_t);
9STATIC_INLINE bool isbase(uint8_t);
10STATIC_INLINE bool parallel(uint8_t, uint8_t);
9STATIC_INLINE uint32_t disable_moves(uint32_t, uint8_t); 11STATIC_INLINE uint32_t disable_moves(uint32_t, uint8_t);
10 12
11STATIC cube_t move(cube_t, uint8_t); 13STATIC cube_t move(cube_t, uint8_t);
@@ -13,6 +15,7 @@ STATIC cube_t premove(cube_t, uint8_t);
13STATIC uint8_t inverse_move(uint8_t); 15STATIC uint8_t inverse_move(uint8_t);
14STATIC void invertmoves(uint8_t *, uint8_t, uint8_t *); 16STATIC void invertmoves(uint8_t *, uint8_t, uint8_t *);
15STATIC void sortparallel(uint8_t *, uint8_t); 17STATIC void sortparallel(uint8_t *, uint8_t);
18STATIC bool are_lastmoves_singlecw(int n, uint8_t [n]);
16 19
17STATIC int readmoves(const char *, int, uint8_t *); 20STATIC int readmoves(const char *, int, uint8_t *);
18STATIC cube_t applymoves(cube_t, const char *); 21STATIC 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
97STATIC_INLINE bool
98isbase(uint8_t move)
99{
100 return move == 3 * movebase(move);
101}
102
103STATIC_INLINE bool
104parallel(uint8_t m1, uint8_t m2)
105{
106 return moveaxis(m1) == moveaxis(m2);
107}
108
94STATIC_INLINE uint8_t 109STATIC_INLINE uint8_t
95moveopposite(uint8_t move) 110moveopposite(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
259STATIC bool
260are_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
244STATIC int 272STATIC int
245readmoves(const char *buf, int max, uint8_t *ret) 273readmoves(const char *buf, int max, uint8_t *ret)
246{ 274{

Generated with cgit - Back to sebastiano.tronto.net