| 87 | static boolean inited = false; |
| 88 | |
| 89 | static void initPruning(byte[] Prun, int done, int metric) { |
| 90 | int done0 = 0; |
| 91 | int depth = -1; |
| 92 | while (done != done0) { |
| 93 | done0 = done; |
| 94 | ++depth; |
| 95 | //Log.w("dct", depth+"\t"+done); |
| 96 | for (int i = 0; i < 3678 * 2; i++) { |
| 97 | if (Prun[i] != depth) { |
| 98 | continue; |
| 99 | } |
| 100 | // try twist |
| 101 | { |
| 102 | int idx = spTwistMove[i]; |
| 103 | if (Prun[idx] == -1) { |
| 104 | ++done; |
| 105 | Prun[idx] = (byte) (depth + 1); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | if (metric == Search.FACE_TURN_METRIC) { |
| 110 | // try top move |
| 111 | for (int m = 0, inc = 0, idx = i; m != 12; m += inc) { |
| 112 | idx = spTopMove[idx]; |
| 113 | inc = idx & 0xf; |
| 114 | idx >>= 4; |
| 115 | if (Prun[idx] == -1) { |
| 116 | ++done; |
| 117 | Prun[idx] = (byte) (depth + 1); |
| 118 | } |
| 119 | } |
| 120 | // try bottom |
| 121 | for (int m = 0, inc = 0, idx = i; m != 12; m += inc) { |
| 122 | idx = spBottomMove[idx]; |
| 123 | inc = idx & 0xf; |
| 124 | idx >>= 4; |
| 125 | if (Prun[idx] == -1) { |
| 126 | ++done; |
| 127 | Prun[idx] = (byte) (depth + 1); |
| 128 | } |
| 129 | } |
| 130 | } else if (metric == Search.WCA_TURN_METRIC) { |
| 131 | // try top/bottom move |
| 132 | for (int m = 0, inc = 0, idx = i; m != 12; m += inc) { |
| 133 | idx = spTopMove[idx]; |
| 134 | inc = idx & 0xf; |
| 135 | idx >>= 4; |
| 136 | for (int m2 = 0, inc2 = 0, idx2 = idx; m2 != 12; m2 += inc2) { |
| 137 | idx2 = spBottomMove[idx2]; |
| 138 | inc2 = idx2 & 0xf; |
| 139 | idx2 >>= 4; |
| 140 | if (Prun[idx2] == -1) { |
| 141 | ++done; |
| 142 | Prun[idx2] = (byte) (depth + 1); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |