#ifndef GENESIS_GEN_CHOKEPOINTS_H
#define GENESIS_GEN_CHOKEPOINTS_H

#include <stdint.h>
#include "grid.h"
#include "events.h"

/* A cell's choke value is the number of passable cells that would become
   unreachable if the nearest chokepoint between that cell and the rest of
   the map were blocked. CHOKE_UNREACHABLE is the "untouched" sentinel. */
#define CHOKE_UNREACHABLE 30000

typedef int16_t choke_map_t[DROWS][DCOLS];
typedef uint8_t choke_flag_t[DROWS][DCOLS];

/* Compute:
   - choke_out[y][x]: how many cells would be cut off if the relevant nearby
     chokepoint were blocked. Lower = more isolated pocket.
   - is_chokepoint[y][x]: 1 if cell is a chokepoint (articulation point).
   - is_gate_site[y][x]: 1 if cell is the smallest chokepoint seen for its
     pocket (ideal vestibule site).

   Each emits at most one CHOKEPOINT_FOUND event per gate site. */
void compute_chokepoints(grid_t g, event_sink_t *sink,
                         choke_map_t choke_out,
                         choke_flag_t is_chokepoint,
                         choke_flag_t is_gate_site);

#endif
