aboutsummaryrefslogtreecommitdiff
path: root/old/2020-unknown-date/moves.c
blob: de293ed99438841bec6ce7b8e40285e9c2b4c36f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdbool.h>
#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];
}

Generated with cgit - Back to sebastiano.tronto.net