aboutsummaryrefslogtreecommitdiff
path: root/src/steps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/steps.c')
-rw-r--r--src/steps.c78
1 files changed, 14 insertions, 64 deletions
diff --git a/src/steps.c b/src/steps.c
index 81af269..a04d5e2 100644
--- a/src/steps.c
+++ b/src/steps.c
@@ -132,90 +132,40 @@ validate_singlecw_ending(Alg *alg)
132/* Public functions **********************************************************/ 132/* Public functions **********************************************************/
133 133
134void 134void
135compute_ind(StepAlt *a, Cube *cube, Movable *ind) 135compute_ind(Step *s, Cube *cube, Movable *ind)
136{ 136{
137 int i; 137 int i;
138 Cube mvd; 138 Cube mvd;
139 Trans t, tt; 139 Trans t, tt;
140 140
141 for (i = 0; i < a->n_coord; i++) { 141 for (i = 0; i < s->n_coord; i++) {
142 t = a->coord_trans[i]; 142 t = s->coord_trans[i];
143 copy_cube(cube, &mvd); 143 copy_cube(cube, &mvd);
144 apply_trans(t, &mvd); 144 apply_trans(t, &mvd);
145 145
146 ind[i].val = index_coord(a->coord[i], &mvd, &tt); 146 ind[i].val = index_coord(s->coord[i], &mvd, &tt);
147 ind[i].t = transform_trans(tt, t); 147 ind[i].t = transform_trans(tt, t);
148 } 148 }
149} 149}
150 150
151int
152estimate_stepalt(StepAlt *a, Movable *ind, int goal)
153{
154 int i, ret, est[a->n_coord];
155
156 for (i = 0; i < a->n_coord; i++) {
157 est[i] = ptableval(a->pd[i], ind[i].val);
158 if (est[i] == a->pd[i]->base && a->compact_pd[i])
159 est[i] = ptableval(a->fallback_pd[i],
160 ind[i].val/a->fbmod[i]);
161 if (ind[i].val != 0 && est[i] == 0) /* est == 0 iff solved */
162 est[i] = 1;
163/*
164TODO: remove this debug code
165printf("%d: est=%d | ", i, est[i]);
166*/
167
168 if (est[i] > goal)
169 return est[i];
170 }
171
172 for (i = 0; i < a->n_dbtrick; i++)
173 if (est[a->dbtrick[i][0]] > 0 &&
174 est[a->dbtrick[i][0]] == est[a->dbtrick[i][1]] &&
175 est[a->dbtrick[i][0]] == est[a->dbtrick[i][2]])
176 est[a->dbtrick[i][0]] += 1;
177
178 for (i = 0, ret = -1; i < a->n_coord; i++)
179 ret = MAX(ret, est[i]);
180
181/*
182TODO: remove this debug code
183printf("Final estimate: %d\n", ret);
184*/
185
186 return ret;
187}
188
189void 151void
190prepare_step(Step *step, SolveOptions *opts) 152prepare_cs(ChoiceStep *cs, SolveOptions *opts)
191{ 153{
192 int i, j; 154 int i, j;
193 PDGenData pdg; 155 PDGenData pdg;
194 StepAlt *a; 156 Step *s;
195 157
196 for (i = 0; step->alt[i] != NULL; i++) { 158 for (i = 0; cs->step[i] != NULL; i++) {
197 a = step->alt[i]; 159 s = cs->step[i];
198 init_moveset(a->moveset); 160 init_moveset(s->moveset);
199 pdg.moveset = a->moveset; 161 pdg.moveset = s->moveset;
200 for (j = 0; j < a->n_coord; j++) { 162 for (j = 0; j < s->n_coord; j++) {
201 gen_coord(a->coord[j]); 163 gen_coord(s->coord[j]);
202 164
203 pdg.coord = a->coord[j]; 165 pdg.coord = s->coord[j];
204 pdg.compact = a->compact_pd[j];
205 pdg.pd = NULL; 166 pdg.pd = NULL;
206 167
207 a->pd[j] = genptable(&pdg, opts->nthreads); 168 s->pd[j] = genptable(&pdg, opts->nthreads);
208
209 if (a->compact_pd[j]) {
210 gen_coord(a->fallback_coord[j]);
211
212 pdg.coord = a->fallback_coord[j];
213 pdg.compact = false;
214 pdg.pd = NULL;
215
216 a->fallback_pd[j] =
217 genptable(&pdg, opts->nthreads);
218 }
219 } 169 }
220 } 170 }
221} 171}

Generated with cgit - Back to sebastiano.tronto.net