1 |
08a8ebc7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2023 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.objectlib.tablebases;
|
11 |
|
|
|
12 |
|
|
import android.content.res.Resources;
|
13 |
|
|
|
14 |
|
|
import org.distorted.library.type.Static3D;
|
15 |
|
|
import org.distorted.objectlib.objects.TwistyCuboid;
|
16 |
|
|
|
17 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
18 |
|
|
|
19 |
|
|
public class TablebasesCuboid232 extends TablebasesAbstract
|
20 |
|
|
{
|
21 |
|
|
public TablebasesCuboid232()
|
22 |
|
|
{
|
23 |
|
|
super();
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
27 |
|
|
|
28 |
|
|
public TablebasesCuboid232(Resources res)
|
29 |
|
|
{
|
30 |
|
|
super(res,org.distorted.objectlib.R.raw.ivy_2_tablebase);
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34 |
|
|
|
35 |
|
|
int[][] getBasicAngles()
|
36 |
|
|
{
|
37 |
|
|
int[] tmp2 = {2,2};
|
38 |
|
|
int[] tmp4 = {4,4,4};
|
39 |
|
|
return new int[][] { tmp2,tmp4,tmp2 };
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
43 |
|
|
|
44 |
|
|
Static3D[] getRotationAxis()
|
45 |
|
|
{
|
46 |
|
|
return TwistyCuboid.ROT_AXIS;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50 |
|
|
|
51 |
|
|
float[][] getPosition()
|
52 |
|
|
{
|
53 |
|
|
return new float[][]
|
54 |
|
|
{
|
55 |
|
|
{ -0.5f, -1.0f, -0.5f },
|
56 |
|
|
{ -0.5f, -1.0f, 0.5f },
|
57 |
|
|
{ -0.5f, 1.0f, -0.5f },
|
58 |
|
|
{ -0.5f, 1.0f, 0.5f },
|
59 |
|
|
{ 0.5f, -1.0f, -0.5f },
|
60 |
|
|
{ 0.5f, -1.0f, 0.5f },
|
61 |
|
|
{ 0.5f, 1.0f, -0.5f },
|
62 |
|
|
{ 0.5f, 1.0f, 0.5f },
|
63 |
|
|
|
64 |
|
|
{ -0.5f, 0.0f, -0.5f },
|
65 |
|
|
{ -0.5f, 0.0f, 0.5f },
|
66 |
|
|
{ 0.5f, 0.0f, -0.5f },
|
67 |
|
|
{ 0.5f, 0.0f, 0.5f },
|
68 |
|
|
};
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
72 |
|
|
|
73 |
|
|
float[][] getCuts()
|
74 |
|
|
{
|
75 |
|
|
return new float[][] { {0.0f}, {-0.5f,0.5f}, {0.0f} };
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79 |
|
|
|
80 |
|
|
boolean[][] getRotatable()
|
81 |
|
|
{
|
82 |
|
|
return new boolean[][] { {false,true},{true,false,true},{true,false} };
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86 |
|
|
// specifically for the tablebase
|
87 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88 |
|
|
// 8!*3! --> https://www.jaapsch.net/puzzles/cube223.htm
|
89 |
|
|
|
90 |
|
|
int getSize()
|
91 |
|
|
{
|
92 |
|
|
return 241920;
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96 |
|
|
|
97 |
|
|
private void getCornerQuats(int[] output, int[] perm)
|
98 |
|
|
{
|
99 |
|
|
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103 |
|
|
|
104 |
|
|
private void getEdgeQuats(int[] output, int[] perm)
|
105 |
|
|
{
|
106 |
|
|
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110 |
|
|
|
111 |
|
|
private int[] getCornerPerm(int[] quats)
|
112 |
|
|
{
|
113 |
|
|
return null;
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117 |
|
|
|
118 |
|
|
private int[] getEdgePerm(int[] quats)
|
119 |
|
|
{
|
120 |
|
|
return null;
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124 |
|
|
|
125 |
|
|
private int[] uncollapseEdgePerm(int[] perm)
|
126 |
|
|
{
|
127 |
|
|
int[] ret = new int[4];
|
128 |
|
|
|
129 |
|
|
ret[0] = perm[0];
|
130 |
|
|
ret[1] = 1;
|
131 |
|
|
ret[2] = perm[1];
|
132 |
|
|
ret[3] = perm[2];
|
133 |
|
|
|
134 |
|
|
if( ret[0]>=1 ) ret[0]++;
|
135 |
|
|
if( ret[2]>=1 ) ret[2]++;
|
136 |
|
|
if( ret[3]>=1 ) ret[3]++;
|
137 |
|
|
|
138 |
|
|
return ret;
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142 |
|
|
|
143 |
|
|
public int[] getQuats(int index)
|
144 |
|
|
{
|
145 |
|
|
int[] quats = new int[12];
|
146 |
|
|
|
147 |
|
|
int edge_perm_num = index%6;
|
148 |
|
|
int corn_perm_num = index/6;
|
149 |
|
|
|
150 |
|
|
int[] edge_perm = new int[3];
|
151 |
|
|
TablebaseHelpers.getPermutationFromNum(edge_perm,3,edge_perm_num);
|
152 |
|
|
|
153 |
|
|
int[] corn_perm = new int[8];
|
154 |
|
|
TablebaseHelpers.getPermutationFromNum(corn_perm,8,corn_perm_num);
|
155 |
|
|
|
156 |
|
|
int[] edge_perm2 = uncollapseEdgePerm(edge_perm);
|
157 |
|
|
getCornerQuats(quats,corn_perm);
|
158 |
|
|
getEdgeQuats(quats,edge_perm2);
|
159 |
|
|
|
160 |
|
|
return quats;
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
164 |
|
|
|
165 |
|
|
private int[] collapseEdgePerm(int[] perm)
|
166 |
|
|
{
|
167 |
|
|
int[] ret = new int[3];
|
168 |
|
|
|
169 |
|
|
ret[0] = perm[0];
|
170 |
|
|
ret[1] = perm[2];
|
171 |
|
|
ret[2] = perm[3];
|
172 |
|
|
|
173 |
|
|
if( ret[0]>1 ) ret[0]--;
|
174 |
|
|
if( ret[1]>1 ) ret[1]--;
|
175 |
|
|
if( ret[2]>1 ) ret[2]--;
|
176 |
|
|
|
177 |
|
|
return ret;
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
181 |
|
|
|
182 |
|
|
public int getIndex(int[] quats)
|
183 |
|
|
{
|
184 |
|
|
int[] edge_perm = getEdgePerm(quats);
|
185 |
|
|
int[] corn_perm = getCornerPerm(quats);
|
186 |
|
|
int[] edge_perm2= collapseEdgePerm(edge_perm); // edge1 is fixed!
|
187 |
|
|
|
188 |
|
|
int corn_perm_num = TablebaseHelpers.computePermutationNum(corn_perm);
|
189 |
|
|
int edge_perm_num = TablebaseHelpers.computePermutationNum(edge_perm2);
|
190 |
|
|
|
191 |
|
|
return edge_perm_num + 6*corn_perm_num;
|
192 |
|
|
}
|
193 |
|
|
}
|