aboutsummaryrefslogtreecommitdiff
path: root/old/2020-unknown-date/moves.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-11 21:37:34 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-11 21:37:34 +0100
commit3568412f8f230774d0d11d7ed1c897424f95d3ef (patch)
tree77223792d8c925a9b1fc32b3f4341e943b5f8209 /old/2020-unknown-date/moves.c
parent67e1b5e6e6a2c917a2fe58a37a1382c982b1e5c5 (diff)
downloadnissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.tar.gz
nissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.zip
Rewritten from scratch. Welocme nissy 2.0!
Diffstat (limited to 'old/2020-unknown-date/moves.c')
-rw-r--r--old/2020-unknown-date/moves.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/old/2020-unknown-date/moves.c b/old/2020-unknown-date/moves.c
new file mode 100644
index 0000000..de293ed
--- /dev/null
+++ b/old/2020-unknown-date/moves.c
@@ -0,0 +1,57 @@
1#include <stdbool.h>
2#include "pieces.h"
3#include "moves.h"
4#include "utils.h"
5
6/* Transition tables */
7int eofb_ttable[pow2to11][NULLMOVE];
8int eorl_ttable[pow2to11][NULLMOVE];
9int eoud_ttable[pow2to11][NULLMOVE];
10int coud_ttable[pow3to7][NULLMOVE];
11int cofb_ttable[pow3to7][NULLMOVE];
12int corl_ttable[pow3to7][NULLMOVE];
13int epose_ttable[factorial12/factorial8][NULLMOVE];
14int eposs_ttable[factorial12/factorial8][NULLMOVE];
15int eposm_ttable[factorial12/factorial8][NULLMOVE];
16int cp_ttable[factorial8][NULLMOVE];
17int centerpos_ttable[factorial6][NULLMOVE];
18
19void apply_move_ep(Move m, int a[12]) {
20 int aux[12];
21 intarrcopy(a, aux, 12);
22 for (int i = 0; i < 12; i++)
23 a[i] = aux[edge_cycle[m][i]];
24}
25
26void apply_move_cp(Move m, int a[8]) {
27 int aux[8];
28 intarrcopy(a, aux, 8);
29 for (int i = 0; i < 8; i++)
30 a[i] = aux[corner_cycle[m][i]];
31}
32
33void apply_move_centerpos(Move m, int a[6]) {
34 int aux[6];
35 intarrcopy(a, aux, 6);
36 for (int i = 0; i < 6; i++)
37 a[i] = aux[center_cycle[m][i]];
38}
39
40void init_ttables() {
41 /* TODO */
42}
43
44void apply_move(Move m, Cube *cube) {
45 cube->eofb = eofb_ttable[cube->eofb][m];
46 cube->eorl = eorl_ttable[cube->eorl][m];
47 cube->eoud = eoud_ttable[cube->eoud][m];
48 cube->coud = coud_ttable[cube->coud][m];
49 cube->cofb = cofb_ttable[cube->cofb][m];
50 cube->corl = corl_ttable[cube->corl][m];
51 cube->epose = epose_ttable[cube->epose][m];
52 cube->eposs = eposs_ttable[cube->eposs][m];
53 cube->eposm = eposm_ttable[cube->eposm][m];
54 cube->cp = cp_ttable[cube->cp][m];
55 cube->centerpos = centerpos_ttable[cube->centerpos][m];
56}
57

Generated with cgit - Back to sebastiano.tronto.net