diff options
Diffstat (limited to '')
| -rw-r--r-- | src/pruning.c | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/src/pruning.c b/src/pruning.c index 5073d69..716379e 100644 --- a/src/pruning.c +++ b/src/pruning.c | |||
| @@ -144,7 +144,25 @@ genptable(PruneData *pd) | |||
| 144 | static void | 144 | static void |
| 145 | genptable_bfs(PruneData *pd, int d, Move *ms) | 145 | genptable_bfs(PruneData *pd, int d, Move *ms) |
| 146 | { | 146 | { |
| 147 | int j; | ||
| 147 | uint64_t i; | 148 | uint64_t i; |
| 149 | Cube c, cc; | ||
| 150 | |||
| 151 | for (i = 0; i < pd->coord->max; i++) { | ||
| 152 | /* | ||
| 153 | * TODO: only do this if the position is "nasty", | ||
| 154 | * i.e. self-symmetrical with respect to the base | ||
| 155 | * coordinate but not overall. | ||
| 156 | */ | ||
| 157 | if (ptableval_index(pd, i) == d) { | ||
| 158 | c = pd->coord->cube(i); | ||
| 159 | for (j = 0; j < pd->coord->ntrans; j++) { | ||
| 160 | cc = apply_trans(pd->coord->trans[j], c); | ||
| 161 | if (ptableval(pd, cc) > d) | ||
| 162 | ptable_update(pd, cc, d); | ||
| 163 | } | ||
| 164 | } | ||
| 165 | } | ||
| 148 | 166 | ||
| 149 | for (i = 0; i < pd->coord->max; i++) | 167 | for (i = 0; i < pd->coord->max; i++) |
| 150 | if (ptableval_index(pd, i) == d) | 168 | if (ptableval_index(pd, i) == d) |
| @@ -154,11 +172,6 @@ genptable_bfs(PruneData *pd, int d, Move *ms) | |||
| 154 | static void | 172 | static void |
| 155 | genptable_branch(PruneData *pd, uint64_t ind, int d, Move *ms) | 173 | genptable_branch(PruneData *pd, uint64_t ind, int d, Move *ms) |
| 156 | { | 174 | { |
| 157 | int i, j; | ||
| 158 | Cube ci, cc, c; | ||
| 159 | |||
| 160 | ci = pd->coord->cube(ind); | ||
| 161 | |||
| 162 | /* | 175 | /* |
| 163 | * Here we deal with the following problem: | 176 | * Here we deal with the following problem: |
| 164 | * The set of positions reached by applying each move to | 177 | * The set of positions reached by applying each move to |
| @@ -186,6 +199,15 @@ genptable_branch(PruneData *pd, uint64_t ind, int d, Move *ms) | |||
| 186 | * efficient and allows for removing the ntrans and trans | 199 | * efficient and allows for removing the ntrans and trans |
| 187 | * field from struct coordinate. | 200 | * field from struct coordinate. |
| 188 | */ | 201 | */ |
| 202 | /* Work in progress, first attempt */ | ||
| 203 | |||
| 204 | /* | ||
| 205 | int i, j; | ||
| 206 | Cube ci, cc, c; | ||
| 207 | |||
| 208 | |||
| 209 | ci = pd->coord->cube(ind); | ||
| 210 | |||
| 189 | for (i = 0; i < pd->coord->ntrans; i++) { | 211 | for (i = 0; i < pd->coord->ntrans; i++) { |
| 190 | c = i == 0 ? ci : | 212 | c = i == 0 ? ci : |
| 191 | apply_trans(pd->coord->trans[i], ci); | 213 | apply_trans(pd->coord->trans[i], ci); |
| @@ -195,6 +217,18 @@ genptable_branch(PruneData *pd, uint64_t ind, int d, Move *ms) | |||
| 195 | ptable_update(pd, cc, d+1); | 217 | ptable_update(pd, cc, d+1); |
| 196 | } | 218 | } |
| 197 | } | 219 | } |
| 220 | */ | ||
| 221 | |||
| 222 | int i; | ||
| 223 | Cube c, cc; | ||
| 224 | |||
| 225 | c = pd->coord->cube(ind); | ||
| 226 | |||
| 227 | for (i = 0; ms[i] != NULLMOVE; i++) { | ||
| 228 | cc = apply_move(ms[i], c); | ||
| 229 | if (ptableval(pd, cc) > d+1) | ||
| 230 | ptable_update(pd, cc, d+1); | ||
| 231 | } | ||
| 198 | } | 232 | } |
| 199 | 233 | ||
| 200 | void | 234 | void |
| @@ -225,15 +259,17 @@ ptablesize(PruneData *pd) | |||
| 225 | static void | 259 | static void |
| 226 | ptable_update(PruneData *pd, Cube cube, int n) | 260 | ptable_update(PruneData *pd, Cube cube, int n) |
| 227 | { | 261 | { |
| 228 | uint64_t ind = pd->coord->index(cube); | 262 | ptable_update_index(pd, pd->coord->index(cube), n); |
| 229 | ptable_update_index(pd, ind, n); | ||
| 230 | } | 263 | } |
| 231 | 264 | ||
| 232 | static void | 265 | static void |
| 233 | ptable_update_index(PruneData *pd, uint64_t ind, int n) | 266 | ptable_update_index(PruneData *pd, uint64_t ind, int n) |
| 234 | { | 267 | { |
| 235 | uint8_t oldval2 = pd->ptable[ind/2]; | 268 | uint8_t oldval2; |
| 236 | int other = (ind % 2) ? oldval2 % 16 : oldval2 / 16; | 269 | int other; |
| 270 | |||
| 271 | oldval2 = pd->ptable[ind/2]; | ||
| 272 | other = (ind % 2) ? oldval2 % 16 : oldval2 / 16; | ||
| 237 | 273 | ||
| 238 | pd->ptable[ind/2] = (ind % 2) ? 16*n + other : 16*other + n; | 274 | pd->ptable[ind/2] = (ind % 2) ? 16*n + other : 16*other + n; |
| 239 | pd->n++; | 275 | pd->n++; |
