diff options
Diffstat (limited to '')
| -rw-r--r-- | old/2020-unknown-date/moves.c | 57 |
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 */ | ||
| 7 | int eofb_ttable[pow2to11][NULLMOVE]; | ||
| 8 | int eorl_ttable[pow2to11][NULLMOVE]; | ||
| 9 | int eoud_ttable[pow2to11][NULLMOVE]; | ||
| 10 | int coud_ttable[pow3to7][NULLMOVE]; | ||
| 11 | int cofb_ttable[pow3to7][NULLMOVE]; | ||
| 12 | int corl_ttable[pow3to7][NULLMOVE]; | ||
| 13 | int epose_ttable[factorial12/factorial8][NULLMOVE]; | ||
| 14 | int eposs_ttable[factorial12/factorial8][NULLMOVE]; | ||
| 15 | int eposm_ttable[factorial12/factorial8][NULLMOVE]; | ||
| 16 | int cp_ttable[factorial8][NULLMOVE]; | ||
| 17 | int centerpos_ttable[factorial6][NULLMOVE]; | ||
| 18 | |||
| 19 | void 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 | |||
| 26 | void 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 | |||
| 33 | void 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 | |||
| 40 | void init_ttables() { | ||
| 41 | /* TODO */ | ||
| 42 | } | ||
| 43 | |||
| 44 | void 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 | |||
