Revision 4fc4e364
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/objectlib/tablebases/TablebasesSkewbDiamond.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
public class TablebasesSkewbDiamond extends TablebasesAbstract |
24 | 24 |
{ |
25 |
private static final int[][][] FREE_CENTER = |
|
26 |
{ |
|
27 |
{ {0,5, 6}, {1,4,10}, {2,7, 9}, {3,8,11} }, |
|
28 |
{ {2,3,10}, {0,7, 8}, {1,6,11}, {4,5, 9} }, |
|
29 |
{ {1,8, 9}, {2,5,11}, {0,3, 4}, {6,7,10} }, |
|
30 |
{ {4,7,11}, {3,6, 9}, {5,8,10}, {0,1, 2} } |
|
31 |
}; |
|
32 |
|
|
33 |
|
|
34 |
private static final int[][][] CORNER = |
|
35 |
{ |
|
36 |
{ {0,9},{2,4},{10,11},{6,8},{1,5},{3,7} }, |
|
37 |
{ {1,3},{0,11},{5,7},{9,10},{2,8},{4,6} }, |
|
38 |
{ {10,11},{6,8},{0,9},{2,4},{3,7},{1,5} }, |
|
39 |
{ {5,7},{9,10},{1,3},{0,11},{4,6},{2,8} }, |
|
40 |
{ {2,6},{1,7},{4,8},{3,5},{0,10},{9,11} }, |
|
41 |
{ {4,8},{3,5},{2,6},{1,7},{9,11},{0,10} } |
|
42 |
}; |
|
43 |
|
|
44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
45 |
|
|
25 | 46 |
public TablebasesSkewbDiamond() |
26 | 47 |
{ |
27 | 48 |
super(); |
... | ... | |
108 | 129 |
|
109 | 130 |
private int computeCenterQuat(int originalLocation, int newLocation) |
110 | 131 |
{ |
111 |
return 0;
|
|
132 |
return FREE_CENTER[originalLocation][newLocation][0];
|
|
112 | 133 |
} |
113 | 134 |
|
114 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
115 | 136 |
|
116 |
private int computeCornerQuat(int originalLocation, int newLocation, int twist)
|
|
137 |
private void computeCenterPerm(int[] output, int q0, int q1, int q2, int q3)
|
|
117 | 138 |
{ |
118 |
return 0; |
|
139 |
for(int j=0; j<4; j++) |
|
140 |
{ |
|
141 |
int[] q = FREE_CENTER[0][j]; |
|
142 |
if( q[0]==q0 || q[1]==q0 || q[2]==q0 ) { output[0]=j; break; } |
|
143 |
} |
|
144 |
for(int j=0; j<4; j++) |
|
145 |
{ |
|
146 |
int[] q = FREE_CENTER[1][j]; |
|
147 |
if( q[0]==q1 || q[1]==q1 || q[2]==q1 ) { output[1]=j; break; } |
|
148 |
} |
|
149 |
for(int j=0; j<4; j++) |
|
150 |
{ |
|
151 |
int[] q = FREE_CENTER[2][j]; |
|
152 |
if( q[0]==q2 || q[1]==q2 || q[2]==q2 ) { output[2]=j; break; } |
|
153 |
} |
|
154 |
for(int j=0; j<4; j++) |
|
155 |
{ |
|
156 |
int[] q = FREE_CENTER[3][j]; |
|
157 |
if( q[0]==q3 || q[1]==q3 || q[2]==q3 ) { output[3]=j; break; } |
|
158 |
} |
|
119 | 159 |
} |
120 | 160 |
|
121 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
122 | 162 |
|
123 |
private int[] computeCenterPerm(int q0, int q1, int q2, int q3)
|
|
163 |
private int computeCornerQuat(int originalLocation, int newLocation, int twist)
|
|
124 | 164 |
{ |
125 |
return null;
|
|
165 |
return CORNER[originalLocation][newLocation][twist];
|
|
126 | 166 |
} |
127 | 167 |
|
128 | 168 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
129 | 169 |
|
130 | 170 |
private int computeCornerPerm(int[] output, int[] quats) |
131 | 171 |
{ |
132 |
return 0; |
|
172 |
int totalTwist = 0; |
|
173 |
|
|
174 |
for(int i=0; i<6; i++) |
|
175 |
{ |
|
176 |
int q = quats[i]; |
|
177 |
int[][] perm = CORNER[i]; |
|
178 |
|
|
179 |
for(int j=0; j<6; j++) |
|
180 |
{ |
|
181 |
int[] p = perm[j]; |
|
182 |
|
|
183 |
if( p[0]==q ) { output[i]=j; break; } |
|
184 |
if( p[1]==q ) { output[i]=j; if( i<5 ) totalTwist++; break; } |
|
185 |
} |
|
186 |
|
|
187 |
if( i<5 ) totalTwist*=2; |
|
188 |
} |
|
189 |
|
|
190 |
return totalTwist; |
|
133 | 191 |
} |
134 | 192 |
|
135 | 193 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
167 | 225 |
|
168 | 226 |
public int getIndex(int[] quats) |
169 | 227 |
{ |
170 |
int[] center_perm = computeCenterPerm(quats[6],quats[8],quats[11],quats[13]); |
|
228 |
int[] center_perm = new int[4]; |
|
229 |
computeCenterPerm(center_perm, quats[6],quats[8],quats[11],quats[13]); |
|
171 | 230 |
int centers_perm_num = TablebaseHelpers.computeEvenPermutationNum(center_perm); |
172 | 231 |
int[] corners_perm = new int[6]; |
173 | 232 |
int totalTwist = computeCornerPerm(corners_perm,quats); |
174 | 233 |
int corners_perm_num = TablebaseHelpers.computeEvenPermutationNum(corners_perm); |
175 | 234 |
|
176 |
return centers_perm_num + 12*(totalTwist + 128*corners_perm_num); |
|
235 |
int ret = centers_perm_num + 12*(totalTwist + 32*corners_perm_num); |
|
236 |
|
|
237 |
if( ret<0 || ret>=138240 ) |
|
238 |
{ |
|
239 |
android.util.Log.e("D", "centers_perm: "+centers_perm_num+" twist: "+totalTwist+" corners_perm: "+corners_perm_num); |
|
240 |
} |
|
241 |
|
|
242 |
return centers_perm_num + 12*(totalTwist + 32*corners_perm_num); |
|
177 | 243 |
} |
178 | 244 |
} |
179 | 245 |
|
Also available in: Unified diff
Progress with the Diamond Skewb solver.