Revision 3cf8f87d
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/solvers/pduo/SolverPyraminxDuo.java | ||
---|---|---|
32 | 32 |
private static final int ERROR_TWO_CENTERS_SWAP = -9; |
33 | 33 |
private static final int ERROR_CORNER_TWISTED = -10; |
34 | 34 |
|
35 |
private static final int ERROR_EDGE_GY = -11; |
|
36 |
private static final int ERROR_EDGE_GB = -12; |
|
37 |
private static final int ERROR_EDGE_GR = -13; |
|
38 |
private static final int ERROR_EDGE_YB = -14; |
|
39 |
private static final int ERROR_EDGE_YR = -15; |
|
40 |
private static final int ERROR_EDGE_BR = -16; |
|
41 |
|
|
35 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 43 |
|
37 | 44 |
private boolean cornerEqual(int[] corner, int c1, int c2, int c3) |
... | ... | |
95 | 102 |
|
96 | 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
97 | 104 |
|
98 |
private int[] computeCornerTwists(int[][] corners)
|
|
105 |
private int computeCornerTwist(int index, int[][] corners)
|
|
99 | 106 |
{ |
100 |
return new int[] {0,0,0,0}; // TODO
|
|
107 |
return 0; // TODO
|
|
101 | 108 |
} |
102 | 109 |
|
103 | 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
107 | 114 |
if( centers[0]==color1 ) |
108 | 115 |
{ |
109 | 116 |
if( centers[1]==color2 ) return 1; |
110 |
if( centers[2]==color2 ) return 0;
|
|
111 |
if( centers[3]==color2 ) return 2;
|
|
117 |
if( centers[2]==color2 ) return 2;
|
|
118 |
if( centers[3]==color2 ) return 0;
|
|
112 | 119 |
|
113 | 120 |
return -1; |
114 | 121 |
} |
115 | 122 |
if( centers[1]==color1 ) |
116 | 123 |
{ |
117 | 124 |
if( centers[0]==color2 ) return 1; |
118 |
if( centers[2]==color2 ) return 1;
|
|
119 |
if( centers[3]==color2 ) return 0;
|
|
125 |
if( centers[2]==color2 ) return 0;
|
|
126 |
if( centers[3]==color2 ) return 2;
|
|
120 | 127 |
|
121 | 128 |
return -1; |
122 | 129 |
} |
123 | 130 |
if( centers[2]==color1 ) |
124 | 131 |
{ |
125 |
if( centers[0]==color2 ) return 0;
|
|
126 |
if( centers[1]==color2 ) return 1;
|
|
132 |
if( centers[0]==color2 ) return 2;
|
|
133 |
if( centers[1]==color2 ) return 0;
|
|
127 | 134 |
if( centers[3]==color2 ) return 1; |
128 | 135 |
|
129 | 136 |
return -1; |
130 | 137 |
} |
131 | 138 |
if( centers[3]==color1 ) |
132 | 139 |
{ |
133 |
if( centers[0]==color2 ) return 2;
|
|
134 |
if( centers[1]==color2 ) return 0;
|
|
140 |
if( centers[0]==color2 ) return 0;
|
|
141 |
if( centers[1]==color2 ) return 2;
|
|
135 | 142 |
if( centers[2]==color2 ) return 1; |
136 | 143 |
|
137 | 144 |
return -1; |
... | ... | |
153 | 160 |
{ |
154 | 161 |
int[][] corners = new int[4][3]; |
155 | 162 |
int[] centers = new int[4]; |
163 |
int[] corner_twist = new int[4]; |
|
156 | 164 |
|
157 | 165 |
for(int i=0; i<4; i++) |
158 | 166 |
{ |
159 |
centers[i] = object.getCubitFaceStickerIndex(i+4,0); |
|
167 |
centers[i] = object.getCubitFaceStickerIndex(i+4,0) - 4;
|
|
160 | 168 |
|
161 | 169 |
for(int j=0; j<3; j++) |
162 | 170 |
corners[i][j] = object.getCubitFaceStickerIndex(i,j); |
... | ... | |
173 | 181 |
|
174 | 182 |
if( (twist_ry-twist_gr+1)%3 != 0 ) return ERROR_TWO_CENTERS_SWAP; |
175 | 183 |
|
176 |
int[] corner_twists = computeCornerTwists(corners); |
|
177 |
int total_twist = corner_twists[0]+corner_twists[1]+corner_twists[2]+corner_twists[3]; |
|
184 |
int total_twist=0; |
|
185 |
|
|
186 |
for(int i=0; i<4; i++) |
|
187 |
{ |
|
188 |
corner_twist[i] = computeCornerTwist(i,corners); |
|
189 |
if( corner_twist[i]<0 ) return corner_twist[i]; |
|
190 |
total_twist += corner_twist[i]; |
|
191 |
} |
|
178 | 192 |
|
179 | 193 |
if( (total_twist-twist_gr)%3 !=0 ) return ERROR_CORNER_TWISTED; |
180 | 194 |
|
181 | 195 |
int green_face = getFaceOfGreenCenter(centers); |
182 | 196 |
|
183 |
return green_face + 4*(corner_twists[3] + 3*(corner_twists[2] + 3*(corner_twists[1] + 3*corner_twists[0])));
|
|
197 |
return green_face + 4*(corner_twist[3] + 3*(corner_twist[2] + 3*(corner_twist[1] + 3*corner_twist[0])));
|
|
184 | 198 |
} |
185 | 199 |
|
186 | 200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
189 | 203 |
{ |
190 | 204 |
switch(index) |
191 | 205 |
{ |
192 |
case ERROR_CORNER_YBR_MISSING: String c0 = res.getString(R.string.color_YBR); |
|
193 |
return res.getString(R.string.solver_generic_missing_corner,c0); |
|
194 |
case ERROR_CORNER_GBR_MISSING: String c1 = res.getString(R.string.color_GBR); |
|
195 |
return res.getString(R.string.solver_generic_missing_corner,c1); |
|
196 |
case ERROR_CORNER_GYR_MISSING: String c2 = res.getString(R.string.color_GYR); |
|
197 |
return res.getString(R.string.solver_generic_missing_corner,c2); |
|
198 |
case ERROR_CORNER_GYB_MISSING: String c3 = res.getString(R.string.color_GYB); |
|
199 |
return res.getString(R.string.solver_generic_missing_corner,c3); |
|
206 |
case ERROR_CORNER_YBR_MISSING: String c01 = res.getString(R.string.color_yellow3); |
|
207 |
String c02 = res.getString(R.string.color_blue3); |
|
208 |
String c03 = res.getString(R.string.color_red4); |
|
209 |
return res.getString(R.string.solver_generic_missing_corner,c01,c02,c03); |
|
210 |
case ERROR_CORNER_GBR_MISSING: String c11 = res.getString(R.string.color_green3); |
|
211 |
String c12 = res.getString(R.string.color_blue3); |
|
212 |
String c13 = res.getString(R.string.color_red4); |
|
213 |
return res.getString(R.string.solver_generic_missing_corner,c11,c12,c13); |
|
214 |
case ERROR_CORNER_GYR_MISSING: String c21 = res.getString(R.string.color_green3); |
|
215 |
String c22 = res.getString(R.string.color_yellow3); |
|
216 |
String c23 = res.getString(R.string.color_red4); |
|
217 |
return res.getString(R.string.solver_generic_missing_corner,c21,c22,c23); |
|
218 |
case ERROR_CORNER_GYB_MISSING: String c31 = res.getString(R.string.color_green3); |
|
219 |
String c32 = res.getString(R.string.color_yellow3); |
|
220 |
String c33 = res.getString(R.string.color_blue4); |
|
221 |
return res.getString(R.string.solver_generic_missing_corner,c31,c32,c33); |
|
200 | 222 |
case ERROR_CENTER_G_MISSING : String colorG = res.getString(R.string.color_green2); |
201 | 223 |
return res.getString(R.string.solver_generic_missing_center,colorG); |
202 | 224 |
case ERROR_CENTER_Y_MISSING : String colorY = res.getString(R.string.color_yellow2); |
Also available in: Unified diff
Progress with the Pyraminx Duo solver