#ifndef GENESIS_GEN_DIJKSTRA_H
#define GENESIS_GEN_DIJKSTRA_H

#include "grid.h"

#define DIST_UNREACHABLE 30000

typedef int16_t dist_map_t[DROWS][DCOLS];

/* 4-connected BFS from (sx,sy) through passable terrain (floor/corridor/door).
   dist[][] filled with shortest path length in cells; DIST_UNREACHABLE if no path.
   If extra_passable_x/y >= 0, that wall cell is treated as passable for the search. */
void bfs_from(grid_t g, int sx, int sy, dist_map_t dist,
              int extra_passable_x, int extra_passable_y);

/* Returns 1 if every passable cell (floor/corridor/door/bridge) in g is
   4-connected to every other, 0 otherwise. Trivially true if zero passable
   cells. If out_unreached is non-NULL, writes the count of passable cells that
   were NOT reached from the first seed. */
int is_connected(grid_t g, int *out_unreached);

#endif
