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

Method init

app/src/main/java/solver/EightPuzzle.java:20–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18 };
19
20 static void init() {
21 if (ini) return;
22 long time = System.currentTimeMillis();
23 int[] arr = new int[9];
24 Arrays.fill(prun, (byte) -1);
25 prun[0] = 0;
26 int c = 1;
27 for (int d = 0; d < 24; d++) {
28 //c = 0;
29 for (int i=0; i<362880; i++)
30 if (prun[i] == d) {
31 Utils.set11Perm(arr, i, 9);
32 for (int m=0; m<4; m++) {
33 System.arraycopy(arr, 0, pz, 0, 9);
34 for (int n = 0; n < 2; n++) {
35 int next = move(m);
36 if (next == -1) break;
37 next = Utils.get11Perm(pz, 9);
38 if (prun[next] < 0) {
39 prun[next] = (byte) (d + 1);
40 c++;
41 }
42 }
43 }
44 }
45 //Log.w("dct", d + 1 + "\t" + c);
46 }
47 time = System.currentTimeMillis() - time;
48 Log.w("dct", "init "+time+"ms");
49 ini = true;
50 }
51
52 private static int move(int m) {
53 int pos = 0;

Callers 1

scrambleMethod · 0.95

Calls 3

set11PermMethod · 0.95
moveMethod · 0.95
get11PermMethod · 0.95

Tested by

no test coverage detected