diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-08 21:50:35 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-08 21:50:35 +0100 |
| commit | 849edbb69700a9f7520e159d94333ef5b798685b (patch) | |
| tree | 8239946c5962c397ab76b6757c61c284a8abca52 /src/pruning.c | |
| parent | 1573b0d3077aade290f03482b1620b2295d2c58c (diff) | |
| download | nissy-849edbb69700a9f7520e159d94333ef5b798685b.tar.gz nissy-849edbb69700a9f7520e159d94333ef5b798685b.zip | |
Just refortmatting and added one type
Diffstat (limited to 'src/pruning.c')
| -rw-r--r-- | src/pruning.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/pruning.c b/src/pruning.c index 50299f0..8c6858d 100644 --- a/src/pruning.c +++ b/src/pruning.c | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | static void genptable_bfs(PruneData *pd, int d, Move *ms); | 3 | static void genptable_bfs(PruneData *pd, int d, Move *ms); |
| 4 | static void genptable_branch(PruneData *pd,uint64_t ind,int d,Move *ms); | 4 | static void genptable_branch(PruneData *pd,uint64_t ind,int d,Move *ms); |
| 5 | static void genptable_fixnasty(PruneData *pd, int d); | ||
| 5 | static void ptable_update(PruneData *pd, Cube cube, int m); | 6 | static void ptable_update(PruneData *pd, Cube cube, int m); |
| 6 | static void ptable_update_index(PruneData *pd, uint64_t ind, int m); | 7 | static void ptable_update_index(PruneData *pd, uint64_t ind, int m); |
| 7 | static int ptableval_index(PruneData *pd, uint64_t ind); | 8 | static int ptableval_index(PruneData *pd, uint64_t ind); |
| @@ -114,6 +115,7 @@ genptable(PruneData *pd) | |||
| 114 | 0, pd->n - oldn, pd->n, pd->coord->max); | 115 | 0, pd->n - oldn, pd->n, pd->coord->max); |
| 115 | oldn = 1; | 116 | oldn = 1; |
| 116 | for (d = 0; d < 15 && pd->n < pd->coord->max; d++) { | 117 | for (d = 0; d < 15 && pd->n < pd->coord->max; d++) { |
| 118 | genptable_fixnasty(pd, d); | ||
| 117 | genptable_bfs(pd, d, ms); | 119 | genptable_bfs(pd, d, ms); |
| 118 | fprintf(stderr, "Depth %d done, generated %" | 120 | fprintf(stderr, "Depth %d done, generated %" |
| 119 | PRIu64 "\t(%" PRIu64 "/%" PRIu64 ")\n", | 121 | PRIu64 "\t(%" PRIu64 "/%" PRIu64 ")\n", |
| @@ -131,25 +133,7 @@ genptable(PruneData *pd) | |||
| 131 | static void | 133 | static void |
| 132 | genptable_bfs(PruneData *pd, int d, Move *ms) | 134 | genptable_bfs(PruneData *pd, int d, Move *ms) |
| 133 | { | 135 | { |
| 134 | int j, n; | ||
| 135 | uint64_t i; | 136 | uint64_t i; |
| 136 | Cube c, cc; | ||
| 137 | Trans t[NTRANS]; | ||
| 138 | |||
| 139 | for (i = 0; i < pd->coord->max; i++) { | ||
| 140 | if (ptableval_index(pd, i) == d) { | ||
| 141 | n = pd->coord->trans(i, t); | ||
| 142 | if (n == 1) | ||
| 143 | continue; | ||
| 144 | |||
| 145 | c = pd->coord->cube(i); | ||
| 146 | for (j = 0; j < n; j++) { | ||
| 147 | cc = apply_trans(t[j], c); | ||
| 148 | if (ptableval(pd, cc) > d) | ||
| 149 | ptable_update(pd, cc, d); | ||
| 150 | } | ||
| 151 | } | ||
| 152 | } | ||
| 153 | 137 | ||
| 154 | for (i = 0; i < pd->coord->max; i++) | 138 | for (i = 0; i < pd->coord->max; i++) |
| 155 | if (ptableval_index(pd, i) == d) | 139 | if (ptableval_index(pd, i) == d) |
| @@ -171,6 +155,30 @@ genptable_branch(PruneData *pd, uint64_t ind, int d, Move *ms) | |||
| 171 | } | 155 | } |
| 172 | } | 156 | } |
| 173 | 157 | ||
| 158 | static void | ||
| 159 | genptable_fixnasty(PruneData *pd, int d) | ||
| 160 | { | ||
| 161 | uint64_t i; | ||
| 162 | int j, n; | ||
| 163 | Cube c, cc; | ||
| 164 | Trans t[NTRANS]; | ||
| 165 | |||
| 166 | for (i = 0; i < pd->coord->max; i++) { | ||
| 167 | if (ptableval_index(pd, i) == d) { | ||
| 168 | n = pd->coord->trans(i, t); | ||
| 169 | if (n == 1) | ||
| 170 | continue; | ||
| 171 | |||
| 172 | c = pd->coord->cube(i); | ||
| 173 | for (j = 0; j < n; j++) { | ||
| 174 | cc = apply_trans(t[j], c); | ||
| 175 | if (ptableval(pd, cc) > d) | ||
| 176 | ptable_update(pd, cc, d); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | } | ||
| 180 | } | ||
| 181 | |||
| 174 | void | 182 | void |
| 175 | print_ptable(PruneData *pd) | 183 | print_ptable(PruneData *pd) |
| 176 | { | 184 | { |
