7 void pcheck(struct HL_astar *p, int x1, int y1, int x2, int y2, int expect) {
10 from = HL_cantor_xy(x1,y1);
11 to = HL_cantor_xy(x2,y2);
18 dist = HL_findpath(p,0);
19 ok(p->error == 0, "found path from (%02d, %02d) to (%02d, %02d) with no error",
22 "found path from (%02d, %02d) to (%02d, %02d) path length = %d (expect %d)",
23 x1, y1, x2, y2, dist, expect);
26 /* make hex 55 missing */
27 int neighbor55(int hex, int dir) {
31 neighbor = HL_adjacent_hex(hex, dir++);
32 } while (neighbor == HL_cantor_xy(5,5));
44 ok(p != NULL, "allocated astar struct");
45 ok(p->malloced == 1, "allocated astar sets malloced");
46 ok(p->open == NULL, "initial open list empty");
47 ok(p->closed == NULL, "initial closed list empty");
49 p->start = HL_cantor_xy(1, 1);
50 p->goal = HL_cantor_xy(1, 2);
52 length = HL_findpath(p, 0);
53 ok(p->error == 0, "path finding returns no error");
55 pcheck(p, 1,1, 1,3, 2);
56 pcheck(p, 1,1, 2,1, 1);
57 pcheck(p, 1,1, 2,2, 2);
58 pcheck(p, 1,1, 3,1, 2);
59 pcheck(p, 1,1, 4,7, 8);
62 p->neighbor = neighbor55;