Revision d7e2f778
Added by Leszek Koltunski almost 2 years 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; |
|
35 |
private static final int ERROR_CORNERS_CANNOT = -11; |
|
36 |
|
|
41 | 37 |
|
42 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 39 |
|
... | ... | |
102 | 98 |
|
103 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
104 | 100 |
|
105 |
private int computeCornerTwist(int index, int[][] corners) |
|
101 |
private int[] computeMissingCornerColor(int[][] corners) |
|
102 |
{ |
|
103 |
int[] ret = new int[4]; |
|
104 |
|
|
105 |
for(int i=0; i<4; i++) |
|
106 |
for(int j=0; j<4; j++) |
|
107 |
if( corners[i][0]!=j && corners[i][1]!=j && corners[i][2]!=j ) ret[i]=j; |
|
108 |
|
|
109 |
return ret; |
|
110 |
} |
|
111 |
|
|
112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
113 |
|
|
114 |
private int computeCornerTwist(int index, int[] corner, int[] missing) |
|
106 | 115 |
{ |
107 |
return 0; // TODO |
|
116 |
int twist1=0, twist2=0, twist3=0; |
|
117 |
|
|
118 |
switch(index) |
|
119 |
{ |
|
120 |
case 0: if( corner[1]==missing[1] ) twist1=1; |
|
121 |
if( corner[2]==missing[1] ) twist1=2; |
|
122 |
if( corner[0]==missing[2] ) twist2=2; |
|
123 |
if( corner[2]==missing[2] ) twist2=1; |
|
124 |
if( corner[0]==missing[3] ) twist3=1; |
|
125 |
if( corner[1]==missing[3] ) twist3=2; |
|
126 |
break; |
|
127 |
case 1: if( corner[1]==missing[0] ) twist1=1; |
|
128 |
if( corner[2]==missing[0] ) twist1=2; |
|
129 |
if( corner[0]==missing[2] ) twist2=1; |
|
130 |
if( corner[1]==missing[2] ) twist2=2; |
|
131 |
if( corner[0]==missing[3] ) twist3=2; |
|
132 |
if( corner[2]==missing[3] ) twist3=1; |
|
133 |
break; |
|
134 |
case 2: if( corner[1]==missing[0] ) twist1=1; |
|
135 |
if( corner[2]==missing[0] ) twist1=2; |
|
136 |
if( corner[0]==missing[1] ) twist2=2; |
|
137 |
if( corner[2]==missing[1] ) twist2=1; |
|
138 |
if( corner[0]==missing[3] ) twist3=1; |
|
139 |
if( corner[1]==missing[3] ) twist3=2; |
|
140 |
break; |
|
141 |
case 3: if( corner[1]==missing[0] ) twist1=1; |
|
142 |
if( corner[2]==missing[0] ) twist1=2; |
|
143 |
if( corner[0]==missing[1] ) twist2=1; |
|
144 |
if( corner[1]==missing[1] ) twist2=2; |
|
145 |
if( corner[0]==missing[2] ) twist3=2; |
|
146 |
if( corner[2]==missing[2] ) twist3=1; |
|
147 |
break; |
|
148 |
} |
|
149 |
|
|
150 |
return ( twist1!=twist2 || twist1!=twist3 ) ? ERROR_CORNERS_CANNOT : twist1; |
|
108 | 151 |
} |
109 | 152 |
|
110 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
182 | 225 |
if( (twist_ry-twist_gr+1)%3 != 0 ) return ERROR_TWO_CENTERS_SWAP; |
183 | 226 |
|
184 | 227 |
int total_twist=0; |
228 |
int[] missing = computeMissingCornerColor(corners); |
|
185 | 229 |
|
186 | 230 |
for(int i=0; i<4; i++) |
187 | 231 |
{ |
188 |
corner_twist[i] = computeCornerTwist(i,corners); |
|
232 |
corner_twist[i] = computeCornerTwist(i,corners[i],missing);
|
|
189 | 233 |
if( corner_twist[i]<0 ) return corner_twist[i]; |
190 | 234 |
total_twist += corner_twist[i]; |
191 | 235 |
} |
... | ... | |
229 | 273 |
return res.getString(R.string.solver_generic_missing_center,colorR); |
230 | 274 |
case ERROR_TWO_CENTERS_SWAP : return res.getString(R.string.solver_generic_two_centers); |
231 | 275 |
case ERROR_CORNER_TWISTED : return res.getString(R.string.solver_generic_corner_twist); |
232 |
case ERROR_EDGE_GY : String c41 = res.getString(R.string.color_green3); |
|
233 |
String c42 = res.getString(R.string.color_yellow5); |
|
234 |
return res.getString(R.string.solver_generic_two_corners,c41,c42); |
|
235 |
case ERROR_EDGE_GB : String c51 = res.getString(R.string.color_green3); |
|
236 |
String c52 = res.getString(R.string.color_blue5); |
|
237 |
return res.getString(R.string.solver_generic_two_corners,c51,c52); |
|
238 |
case ERROR_EDGE_GR : String c61 = res.getString(R.string.color_green3); |
|
239 |
String c62 = res.getString(R.string.color_red5); |
|
240 |
return res.getString(R.string.solver_generic_two_corners,c61,c62); |
|
241 |
case ERROR_EDGE_YB : String c71 = res.getString(R.string.color_yellow3); |
|
242 |
String c72 = res.getString(R.string.color_blue5); |
|
243 |
return res.getString(R.string.solver_generic_two_corners,c71,c72); |
|
244 |
case ERROR_EDGE_YR : String c81 = res.getString(R.string.color_yellow3); |
|
245 |
String c82 = res.getString(R.string.color_red5); |
|
246 |
return res.getString(R.string.solver_generic_two_corners,c81,c82); |
|
247 |
case ERROR_EDGE_BR : String c91 = res.getString(R.string.color_blue3); |
|
248 |
String c92 = res.getString(R.string.color_red5); |
|
249 |
return res.getString(R.string.solver_generic_two_corners,c91,c92); |
|
276 |
case ERROR_CORNERS_CANNOT : return res.getString(R.string.solver_generic_corners_cannot); |
|
250 | 277 |
} |
251 | 278 |
|
252 | 279 |
return null; |
src/main/res/values-de/strings.xml | ||
---|---|---|
84 | 84 |
<string name="solver_generic_two_centers">Zwei Zentren müssen ausgetauscht werden!</string> |
85 | 85 |
<string name="solver_generic_missing_center">Die %1$s Mitte fehlt!</string> |
86 | 86 |
<string name="solver_generic_missing_corner">Die %1$s-%2$s-%3$s Ecke fehlt!</string> |
87 |
<string name="solver_generic_two_corners">Zwei Ecken passen nicht zusammen (%1$s-%2$s)</string>
|
|
87 |
<string name="solver_generic_corners_cannot">Ecken können nicht verdreht werden, sodass alle Flächen einfarbig sind!</string>
|
|
88 | 88 |
|
89 | 89 |
<string name="solver_cube3_error1">Es gibt nur %1$d %2$s Facelets.</string> |
90 | 90 |
<string name="solver_cube3_error2">Nicht alle 12 Kanten gibt es genau einmal!</string> |
src/main/res/values-es/strings.xml | ||
---|---|---|
84 | 84 |
<string name="solver_generic_two_centers">¡Hay que cambiar dos centros!</string> |
85 | 85 |
<string name="solver_generic_missing_center">¡Falta el centro %1$s!</string> |
86 | 86 |
<string name="solver_generic_missing_corner">¡Falta la esquina %1$s-%2$s-%3$s!</string> |
87 |
<string name="solver_generic_two_corners">Dos esquinas no coinciden (%1$s-%2$s)</string>
|
|
87 |
<string name="solver_generic_corners_cannot">¡Las esquinas no se pueden torcer para que todos los lados sean monocromáticos!</string>
|
|
88 | 88 |
|
89 | 89 |
<string name="solver_cube3_error1">Solo hay %1$d facetas %2$s.</string> |
90 | 90 |
<string name="solver_cube3_error2">¡No todos los 12 bordes existen exactamente una vez!</string> |
src/main/res/values-fr/strings.xml | ||
---|---|---|
84 | 84 |
<string name="solver_generic_two_centers">Deux centres doivent être échangés !</string> |
85 | 85 |
<string name="solver_generic_missing_center">Centre %1$s manquant !</string> |
86 | 86 |
<string name="solver_generic_missing_corner">Coin %1$s-%2$s-%3$s manquant !</string> |
87 |
<string name="solver_generic_two_corners">Deux coins ne correspondent pas (%1$s-%2$s)</string>
|
|
87 |
<string name="solver_generic_corners_cannot">Les coins ne peuvent pas être tordus afin que tous les côtés soient monochromes !</string>
|
|
88 | 88 |
|
89 | 89 |
<string name="solver_cube3_error1">Il n\'y a que %1$d facettes %2$s.</string> |
90 | 90 |
<string name="solver_cube3_error2">Les 12 arêtes n\'existent pas exactement une fois !</string> |
src/main/res/values-ja/strings.xml | ||
---|---|---|
85 | 85 |
<string name="solver_generic_two_centers">2つのセンターを交換しなければならない!</string> |
86 | 86 |
<string name="solver_generic_missing_center">%1$sのセンターが欠けてる!</string> |
87 | 87 |
<string name="solver_generic_missing_corner">%1$s%2$s%3$sのコーナーがない!</string> |
88 |
<string name="solver_generic_two_corners">2 つの角が一致しません (%1$s-%2$s)</string>
|
|
88 |
<string name="solver_generic_corners_cannot">すべての面がモノクロになるようにコーナーをねじることはできません。</string>
|
|
89 | 89 |
|
90 | 90 |
<string name="solver_cube3_error1">%2$s小顔は%1$dつだけ</string> |
91 | 91 |
<string name="solver_cube3_error2">12 のエッジすべてが 存在するわけではありません。</string> |
src/main/res/values-ko/strings.xml | ||
---|---|---|
84 | 84 |
<string name="solver_generic_two_centers">두 개의 센터를 교환해야 합니다!</string> |
85 | 85 |
<string name="solver_generic_missing_center">%1$s 중앙이 사라졌습니다!</string> |
86 | 86 |
<string name="solver_generic_missing_corner">%1$s-%2$s-%3$s 모서리 금지!</string> |
87 |
<string name="solver_generic_two_corners">두 모서리가 일치하지 않음 (%1$s-%2$s)</string>
|
|
87 |
<string name="solver_generic_corners_cannot">모든면이 단색이되도록 모서리를 비틀 수 없습니다!</string>
|
|
88 | 88 |
|
89 | 89 |
<string name="solver_cube3_error1">%2$s작은 얼굴은 %1$d개뿐입니다.</string> |
90 | 90 |
<string name="solver_cube3_error2">12개의 가장자리 모두가 정확하게 한 번 존재하지 않습니다!</string> |
src/main/res/values-pl/strings.xml | ||
---|---|---|
84 | 84 |
<string name="solver_generic_two_centers">Dwa środki muszą być wymienione!</string> |
85 | 85 |
<string name="solver_generic_missing_center">Brakuje %1$s środka!</string> |
86 | 86 |
<string name="solver_generic_missing_corner">Brakuje %1$s-%2$s-%3$s rogu!</string> |
87 |
<string name="solver_generic_two_corners">Dwa rogi nie zgadzają się ze sobą (%1$s-%2$s)</string>
|
|
87 |
<string name="solver_generic_corners_cannot">Narożników nie można skręcić tak, aby wszystkie boki były monochromatyczne!</string>
|
|
88 | 88 |
|
89 | 89 |
<string name="solver_cube3_error1">Jest tylko %1$d %2$s ścian.</string> |
90 | 90 |
<string name="solver_cube3_error2">Któraś z 12 krawędzi nie istnieje!</string> |
src/main/res/values-ru/strings.xml | ||
---|---|---|
84 | 84 |
<string name="solver_generic_two_centers">Два центра должны быть обменены!</string> |
85 | 85 |
<string name="solver_generic_missing_center">Нет %1$s центра!</string> |
86 | 86 |
<string name="solver_generic_missing_corner">Нет %1$s-%2$s-%3$s угла!</string> |
87 |
<string name="solver_generic_two_corners">Два угла не совпадают (%1$s-%2$s)</string>
|
|
87 |
<string name="solver_generic_corners_cannot">Углы нельзя скручивать так, чтобы все стороны были однотонными!</string>
|
|
88 | 88 |
|
89 | 89 |
<string name="solver_cube3_error1">Всего %1$d %2$s граней!</string> |
90 | 90 |
<string name="solver_cube3_error2">Не все 12 ребер существуют в единичном экземпляре!</string> |
src/main/res/values-zh-rCN/strings.xml | ||
---|---|---|
90 | 90 |
<string name="solver_generic_two_centers">必须要交换两个中心!</string> |
91 | 91 |
<string name="solver_generic_missing_center">%1$s中心不見了!</string> |
92 | 92 |
<string name="solver_generic_missing_corner">没有%1$s-%2$s-%3$s的角落!</string> |
93 |
<string name="solver_generic_two_corners">两个角不匹配 (%1$s-%2$s)</string>
|
|
93 |
<string name="solver_generic_corners_cannot">角不能扭曲,这样所有的面都是单色的!</string>
|
|
94 | 94 |
|
95 | 95 |
<string name="solver_cube3_error1">只有%1$d个%2$s小面</string> |
96 | 96 |
<string name="solver_cube3_error2">并非所有12条边都只存在一次!</string> |
src/main/res/values-zh-rTW/strings.xml | ||
---|---|---|
84 | 84 |
<string name="solver_generic_two_centers">兩個中鋒要互換!</string> |
85 | 85 |
<string name="solver_generic_missing_center">%1$s的中心不见了!</string> |
86 | 86 |
<string name="solver_generic_missing_corner">沒有%1$s-%2$s-%3$s的角落!</string> |
87 |
<string name="solver_generic_two_corners">兩個角不匹配 (%1$s-%2$s)</string>
|
|
87 |
<string name="solver_generic_corners_cannot">角不能扭曲,這樣所有的面都是單色的!</string>
|
|
88 | 88 |
|
89 | 89 |
<string name="solver_cube3_error1">只有%1$d個%2$s小臉</string> |
90 | 90 |
<string name="solver_cube3_error2">並非所有12條邊都只存在一次!</string> |
src/main/res/values/strings.xml | ||
---|---|---|
104 | 104 |
<string name="solver_generic_two_centers">Two centers have to be exchanged!</string> |
105 | 105 |
<string name="solver_generic_missing_center">The %1$s center missing!</string> |
106 | 106 |
<string name="solver_generic_missing_corner">The %1$s-%2$s-%3$s corner missing!</string> |
107 |
<string name="solver_generic_two_corners">Two corners do not match (%1$s-%2$s)</string>
|
|
107 |
<string name="solver_generic_corners_cannot">Corners cannot be twisted so that all faces are monochromatic!</string>
|
|
108 | 108 |
|
109 | 109 |
<string name="solver_cube3_error1">There are only %1$d %2$s facelets.</string> |
110 | 110 |
<string name="solver_cube3_error2">Not all 12 edges exist exactly once!</string> |
Also available in: Unified diff
Pyraminx Duo solver: initial error cases should be finished.