aboutsummaryrefslogtreecommitdiff
path: root/src/core/moves.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-08-18 14:26:45 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-08-18 14:26:45 +0200
commit18c9a8b8905304cf5f8fc15825769046a3144866 (patch)
treea7807bb32b0a5d9ded7d3cedccc598f64a9b00fe /src/core/moves.h
parentf25a10e19eca294c4e6a99e4f80ce5cfd11a0e5f (diff)
downloadnissy-core-18c9a8b8905304cf5f8fc15825769046a3144866.tar.gz
nissy-core-18c9a8b8905304cf5f8fc15825769046a3144866.zip
Reorganized folder structure
Diffstat (limited to 'src/core/moves.h')
-rw-r--r--src/core/moves.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/core/moves.h b/src/core/moves.h
new file mode 100644
index 0000000..7da6405
--- /dev/null
+++ b/src/core/moves.h
@@ -0,0 +1,47 @@
1_static_inline bool allowednextmove(uint8_t *, uint8_t);
2_static_inline uint8_t inverse_trans(uint8_t);
3_static_inline uint8_t movebase(uint8_t);
4_static_inline uint8_t moveaxis(uint8_t);
5
6_static bool
7allowednextmove(uint8_t *moves, uint8_t n)
8{
9 uint8_t base[3], axis[3];
10
11 if (n < 2)
12 return true;
13
14 base[0] = movebase(moves[n-1]);
15 axis[0] = moveaxis(moves[n-1]);
16 base[1] = movebase(moves[n-2]);
17 axis[1] = moveaxis(moves[n-2]);
18
19 if (base[0] == base[1] || (axis[0] == axis[1] && base[0] < base[1]))
20 return false;
21
22 if (n == 2)
23 return true;
24
25 base[2] = movebase(moves[n-3]);
26 axis[2] = moveaxis(moves[n-3]);
27
28 return axis[1] != axis[2] || base[0] != base[2];
29}
30
31_static_inline uint8_t
32inverse_trans(uint8_t t)
33{
34 return inverse_trans_table[t];
35}
36
37_static_inline uint8_t
38movebase(uint8_t move)
39{
40 return move / 3;
41}
42
43_static_inline uint8_t
44moveaxis(uint8_t move)
45{
46 return move / 6;
47}

Generated with cgit - Back to sebastiano.tronto.net