From 3568412f8f230774d0d11d7ed1c897424f95d3ef Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 11 Nov 2021 21:37:34 +0100 Subject: Rewritten from scratch. Welocme nissy 2.0! --- old/2020-unknown-date/moves.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 old/2020-unknown-date/moves.c (limited to 'old/2020-unknown-date/moves.c') 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 @@ +#include +#include "pieces.h" +#include "moves.h" +#include "utils.h" + +/* Transition tables */ +int eofb_ttable[pow2to11][NULLMOVE]; +int eorl_ttable[pow2to11][NULLMOVE]; +int eoud_ttable[pow2to11][NULLMOVE]; +int coud_ttable[pow3to7][NULLMOVE]; +int cofb_ttable[pow3to7][NULLMOVE]; +int corl_ttable[pow3to7][NULLMOVE]; +int epose_ttable[factorial12/factorial8][NULLMOVE]; +int eposs_ttable[factorial12/factorial8][NULLMOVE]; +int eposm_ttable[factorial12/factorial8][NULLMOVE]; +int cp_ttable[factorial8][NULLMOVE]; +int centerpos_ttable[factorial6][NULLMOVE]; + +void apply_move_ep(Move m, int a[12]) { + int aux[12]; + intarrcopy(a, aux, 12); + for (int i = 0; i < 12; i++) + a[i] = aux[edge_cycle[m][i]]; +} + +void apply_move_cp(Move m, int a[8]) { + int aux[8]; + intarrcopy(a, aux, 8); + for (int i = 0; i < 8; i++) + a[i] = aux[corner_cycle[m][i]]; +} + +void apply_move_centerpos(Move m, int a[6]) { + int aux[6]; + intarrcopy(a, aux, 6); + for (int i = 0; i < 6; i++) + a[i] = aux[center_cycle[m][i]]; +} + +void init_ttables() { + /* TODO */ +} + +void apply_move(Move m, Cube *cube) { + cube->eofb = eofb_ttable[cube->eofb][m]; + cube->eorl = eorl_ttable[cube->eorl][m]; + cube->eoud = eoud_ttable[cube->eoud][m]; + cube->coud = coud_ttable[cube->coud][m]; + cube->cofb = cofb_ttable[cube->cofb][m]; + cube->corl = corl_ttable[cube->corl][m]; + cube->epose = epose_ttable[cube->epose][m]; + cube->eposs = eposs_ttable[cube->eposs][m]; + cube->eposm = eposm_ttable[cube->eposm][m]; + cube->cp = cp_ttable[cube->cp][m]; + cube->centerpos = centerpos_ttable[cube->centerpos][m]; +} + -- cgit v1.3