- addclosed(&state, cur);
- count = HL_hexes_at_range(cur->hex, 1, neighbors, 6);
- for (i=0;i<count;i++) {
- neighbor = neighbors[i];
- cost = g(&state, current) + metric(current, neighbor);
- if (inopen(&state, neighbor) && cost < g(&state, neighbor)) {
- removeopen(&state, neighbor);
- } else
- if (inclosed(&state, neighbor) && cost < g(&state, neighbor)) {
- /* should never happen with
- * admissible heuristic
- */
- removeclosed(&state, neighbor);
- } else
- if (!inopen(&state, neighbor) && !inclosed(&state, neighbor)) {
- addopen(&state, neighbor);
- setg(&state, neighbor, cost);
- setrank(&state, neighbor, cost + h(neighbor,end));
- setparent(&state, neighbor, current);
+ closehex(s, x);
+ for (dir = 0; y = s->neighbor(x->hex, dir),dir<6; dir++) {
+ if (y == 0) continue; /* no hex in that direction */
+ if (in_closed(s, y)) {
+ continue;
+ }
+
+ cost = x->g + s->metric(x->hex, y);
+
+ yopen = in_open(s, y);
+ if (!yopen) {
+ yopen = add_open(s, y);
+ tent_better = 1;
+ } else if (cost < yopen->g) {
+ tent_better = 1;