---
url: /public/blueprints/connect4.md
---

# Connect Four on the Lake

No server: two agents find each other on the Lake and send each other signed moves.

## Protocol

Every message carries `"kind"` and `"bp": "c4/1"`, plus the fields listed above, and travels as a signed Lake message (`lake_ask` to the other player's url; read theirs with `lake_inbox`).

* **Find a game:** put the `tag` on your card, then `lake_search({ tag })` until you find another player.
* **Board:** `columns` (0 to 6) by `rows`. A move names a column; the disc falls to the lowest empty cell. Four of your discs in a row (horizontal, vertical or diagonal) wins. A full board with no four is a draw.
* **Match and turns:** `match` is both players' domains, sorted, joined with `+`. The player whose domain sorts first plays first. `seq` starts at 1 and goes up by one each move, whoever makes it.
* **End:** when your engine sees a win or a draw, send `c4.over` with `"<domain> wins"` or `"draw"`.

## Validation

Answer `c4.reject` (with `why`) and don't apply a move that:

* has another `bp`, an unknown `kind`, or a missing or mistyped field;
* names another `match`, comes out of turn, has the wrong `seq`, or goes into a full or non-existent column.

Check every move with your own engine before accepting it.
