Revision f9980f6a
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/objectlib/tablebases/TablebasesIvyCube.java | ||
---|---|---|
18 | 18 |
|
19 | 19 |
public class TablebasesIvyCube extends TablebasesAbstract |
20 | 20 |
{ |
21 |
private static final int[] mTmp = new int[6]; |
|
22 |
|
|
23 |
private static final int[][] MAP = { {0,4,2,2,5,3,4,5,3,0,1,1}, |
|
24 |
{1,5,3,3,4,2,5,4,2,1,0,0}, |
|
25 |
{2,0,4,5,0,5,1,1,4,3,3,2}, |
|
26 |
{3,1,5,4,1,4,0,0,5,2,2,3}, |
|
27 |
{4,2,0,1,3,0,3,2,1,5,4,5}, |
|
28 |
{5,3,1,0,2,1,2,3,0,4,5,4} }; |
|
29 |
|
|
21 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
22 | 31 |
|
23 | 32 |
public TablebasesIvyCube() |
... | ... | |
29 | 38 |
|
30 | 39 |
public TablebasesIvyCube(Resources res) |
31 | 40 |
{ |
32 |
super(res,org.distorted.objectlib.R.raw.pduo_2_tablebase);
|
|
41 |
super(res,org.distorted.objectlib.R.raw.ivy_2_tablebase);
|
|
33 | 42 |
} |
34 | 43 |
|
35 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
60 | 69 |
{-DIST_CORNER, DIST_CORNER,-DIST_CORNER }, |
61 | 70 |
{-DIST_CORNER,-DIST_CORNER, DIST_CORNER }, |
62 | 71 |
{ DIST_CORNER,-DIST_CORNER,-DIST_CORNER }, |
63 |
{ 0, 0, DIST_CENTER }, |
|
64 |
{ 0, 0,-DIST_CENTER }, |
|
65 |
{ 0, DIST_CENTER, 0 }, |
|
66 |
{ 0,-DIST_CENTER, 0 }, |
|
67 | 72 |
{ DIST_CENTER, 0, 0 }, |
68 | 73 |
{-DIST_CENTER, 0, 0 }, |
74 |
{ 0, DIST_CENTER, 0 }, |
|
75 |
{ 0,-DIST_CENTER, 0 }, |
|
76 |
{ 0, 0, DIST_CENTER }, |
|
77 |
{ 0, 0,-DIST_CENTER }, |
|
69 | 78 |
}; |
70 | 79 |
} |
71 | 80 |
|
... | ... | |
81 | 90 |
|
82 | 91 |
boolean[][] getRotatable() |
83 | 92 |
{ |
84 |
boolean[] tmp = new boolean[] {false,true}; |
|
85 |
return new boolean[][] { tmp,tmp,tmp,tmp }; |
|
93 |
boolean[] tmp1 = new boolean[] {false,true}; |
|
94 |
boolean[] tmp2 = new boolean[] {true,false}; |
|
95 |
|
|
96 |
return new boolean[][] { tmp1,tmp2,tmp2,tmp1 }; |
|
86 | 97 |
} |
87 | 98 |
|
88 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
97 | 108 |
|
98 | 109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
99 | 110 |
|
100 |
int[] getQuats(int index) |
|
111 |
private int findFirst(int[] table, int value) |
|
112 |
{ |
|
113 |
int len = table.length; |
|
114 |
|
|
115 |
for(int i=0; i<len; i++) |
|
116 |
if( table[i]==value ) return i; |
|
117 |
|
|
118 |
return -1; |
|
119 |
} |
|
120 |
|
|
121 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
122 |
|
|
123 |
public int[] getQuats(int index) |
|
101 | 124 |
{ |
102 |
return new int[] {0,0,0,0, 0,0,0,0,0,0}; |
|
125 |
int perm_num = index%360; |
|
126 |
index /= 360; |
|
127 |
int twist0 = index%3; |
|
128 |
index /= 3; |
|
129 |
int twist1 = index%3; |
|
130 |
index /= 3; |
|
131 |
int twist2 = index%3; |
|
132 |
index /= 3; |
|
133 |
int twist3 = index%3; |
|
134 |
|
|
135 |
int[] ret = new int[10]; |
|
136 |
|
|
137 |
ret[0] = twist0==0 ? 0 : (twist0==1 ? 2:1); |
|
138 |
ret[1] = twist1==0 ? 0 : (twist1==1 ? 5:6); |
|
139 |
ret[2] = twist2==0 ? 0 : (twist2==1 ? 3:4); |
|
140 |
ret[3] = twist3==0 ? 0 : (twist3==1 ? 8:7); |
|
141 |
|
|
142 |
TablebaseHelpers.getEvenPermutationFromNum(mTmp,6,perm_num); |
|
143 |
|
|
144 |
for(int i=0; i<6; i++) |
|
145 |
{ |
|
146 |
int cubitThatMoves = mTmp[i]; |
|
147 |
ret[cubitThatMoves+4] = findFirst(MAP[cubitThatMoves],i); |
|
148 |
} |
|
149 |
|
|
150 |
return ret; |
|
103 | 151 |
} |
104 | 152 |
|
105 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
106 | 154 |
|
107 |
int getIndex(int[] quats) |
|
155 |
public int getIndex(int[] quats)
|
|
108 | 156 |
{ |
109 |
return 0; |
|
157 |
int twist0 = quats[0]==0 ? 0 : (quats[0]==1 ? 2:1); |
|
158 |
int twist1 = quats[1]==0 ? 0 : (quats[1]==6 ? 2:1); |
|
159 |
int twist2 = quats[2]==0 ? 0 : (quats[2]==4 ? 2:1); |
|
160 |
int twist3 = quats[3]==0 ? 0 : (quats[3]==7 ? 2:1); |
|
161 |
|
|
162 |
int c4 = MAP[0][quats[4]]; |
|
163 |
int c5 = MAP[1][quats[5]]; |
|
164 |
int c6 = MAP[2][quats[6]]; |
|
165 |
int c7 = MAP[3][quats[7]]; |
|
166 |
int c8 = MAP[4][quats[8]]; |
|
167 |
int c9 = MAP[5][quats[9]]; |
|
168 |
|
|
169 |
mTmp[c4]=0; |
|
170 |
mTmp[c5]=1; |
|
171 |
mTmp[c6]=2; |
|
172 |
mTmp[c7]=3; |
|
173 |
mTmp[c8]=4; |
|
174 |
mTmp[c9]=5; |
|
175 |
|
|
176 |
int perm_num = TablebaseHelpers.computeEvenPermutationNum(mTmp); |
|
177 |
|
|
178 |
return perm_num + 360*(twist0+ 3*(twist1+ 3*(twist2+ 3*twist3))); |
|
110 | 179 |
} |
111 | 180 |
} |
112 | 181 |
|
Also available in: Unified diff
Ivy solver finished