#ifndef GENESIS_GEN_CA_H
#define GENESIS_GEN_CA_H

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

typedef uint8_t bitgrid_t[DROWS][DCOLS];

/* Generate a CA blob in a bounding box (x,y,w,h) within bitgrid.
   Rule: B678/S45678, 55% seed probability, 5 iterations, then retain only the
   largest 4-connected region within the box. Cells outside the box are 0.
   Emits EV_CA_ITERATION for each of the 5 steps. */
void ca_blob(bitgrid_t out, rng_t *rng, event_sink_t *sink,
             int x, int y, int w, int h);

/* Count filled cells in bitgrid. */
int bitgrid_count(bitgrid_t g);

#endif
