Files

23 lines
629 B
C

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Three rooms in a straight corridor. Link astar. */
#include <astar.h>
int main(void)
{
AStarNode rooms[3];
AStarGraph map = { rooms, 3, 1 };
AStarPathIterator it;
AStarNode *room;
byte i;
for (i = 0; i < 3; ++i)
astar_initNode(rooms + i, NULL, i < 2, FALSE);
if (!astar_searchGrid(&map, 0, 0, 2, 0))
return 1;
astar_startPathIteration(&it, &map, 2, 0);
printf("BACK FROM GOAL:");
while ((room = astar_advancePathIteration(&it)) != NULL)
printf(" %u", (unsigned) (room - rooms));
printf("\n");
return 0;
}