aboutsummaryrefslogtreecommitdiff
path: root/src/arch/coordinates_unoptimized.h
blob: de760187cc358d3cbc6fa533bf35b3be5273afac (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
STATIC_INLINE int64_t coord_cp(cube_t);
STATIC_INLINE cube_t invcoord_cp(int64_t);
STATIC_INLINE int64_t coord_epud(cube_t);
STATIC_INLINE cube_t invcoord_epud(int64_t);

STATIC_INLINE int64_t
coord_cp(cube_t cube)
{
	int i;
	uint8_t c[8], e[12];

	pieces(&cube, c, e);
	for (i = 0; i < 8; i++)
		c[i] &= PBITS;

	return permtoindex(8, c);
}

STATIC_INLINE cube_t
invcoord_cp(int64_t i)
{
	uint8_t c[8];

	indextoperm(i, 8, c);

	return STATIC_CUBE(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7],
	    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
}

STATIC_INLINE int64_t
coord_epud(cube_t cube)
{
	int i;
	uint8_t c[8], e[12];

	pieces(&cube, c, e);

	for (i = 0; i < 8; i++)
		e[i] &= PBITS;

	return permtoindex(8, e);
}

STATIC_INLINE cube_t
invcoord_epud(int64_t i)
{
	uint8_t e[8];

	indextoperm(i, 8, e);

	return STATIC_CUBE(0, 1, 2, 3, 4, 5, 6, 7,
	    e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], 8, 9, 10, 11);
}

Generated with cgit - Back to sebastiano.tronto.net