MCPcopy Create free account
hub / github.com/MeigenChou/DCTimer-Android / phase1

Method phase1

app/src/main/java/cs/sq12phase/Search.java:224–288  ·  view source on GitHub ↗
(int shape, int prunvalue, int maxl, int depth, int lm)

Source from the content-addressed store, hash-verified

222 }
223
224 private boolean phase1(int shape, int prunvalue, int maxl, int depth, int lm) {
225 if (prunvalue == 0 && maxl < 4) {
226 movelen1 = depth;
227 return maxl == 0 && init2();
228 }
229
230 //try each possible move. First twist;
231 if (lm != 0) {
232 int shapex = Shape.spTwistMove[shape];
233 int prunx = Shape.ShapePrun[shapex];
234 if (prunx < maxl) {
235 move[depth] = 0;
236 if (phase1(shapex, prunx, maxl - 1, depth + 1, 0)) {
237 return true;
238 }
239 }
240 }
241
242 //Try top layer
243 if (lm <= 0) {
244 int m = 0;
245 int shapex = shape;
246 while (true) {
247 m += Shape.spTopMove[shapex];
248 shapex = m >> 4;
249 m &= 0x0f;
250 if (m >= 12) {
251 break;
252 }
253 int prun = Shape.ShapePrun[shapex];
254 if (prun > maxl) {
255 break;
256 } else if (prun < maxl) {
257 move[depth] = m;
258 if (phase1(shapex, prun, maxl - 1, depth + 1, 1)) {
259 return true;
260 }
261 }
262 }
263 }
264
265 //Try bottom layer
266 if (lm <= 1) {
267 int m = 0;
268 int shapex = shape;
269 while (true) {
270 m += Shape.spBottomMove[shapex];
271 shapex = m >> 4;
272 m &= 0x0f;
273 if (m >= 6) {
274 break;
275 }
276 int prun = Shape.ShapePrun[shapex];
277 if (prun > maxl) {
278 break;
279 } else if (prun < maxl) {
280 move[depth] = -m;
281 if (phase1(shapex, prun, maxl - 1, depth + 1, 2)) {

Callers 1

solutionMethod · 0.95

Calls 1

init2Method · 0.95

Tested by

no test coverage detected