amphro/primordial

A cell growing game, where the strategy is interpreted by Gen AI.

★ 0Forks 0TypeScriptGitHub ↗Compare

README

PRIMORDIAL

A cellular automaton game where your only weapon is a plain-English strategy.

Two colonies of cells fight for control of a petri dish. Before the battle starts, each player writes a strategy — the AI converts it to rules — and then the entire game resolves in one shot. You watch it play out round by round.

Experimental hobby project — use at your own risk.

How to play · Design notes


Tech stack

  • Frontend: React + Vite, HTML Canvas
  • Runtime: Cloudflare Workers
  • Game state: Cloudflare Durable Objects (one per room, WebSocket hub)
  • Database: Cloudflare D1 (users, games)
  • Sessions: Stateless signed cookies (7-day expiry)
  • KV: Cloudflare KV (balance config overrides)
  • AI: Cloudflare Workers AI (@cf/meta/llama-3.3-70b-instruct-fp8-fast)

Running locally

Prerequisites: Node.js 20+, a Cloudflare account with Workers, D1, KV, and AI access.

npm install

Copy .dev.vars.example to .dev.vars and fill in your values. Guest login works without Google credentials.

Create your own Cloudflare resources and update wrangler.jsonc with your IDs:

wrangler d1 create primordial-db
wrangler kv namespace create primordial-sessions
# Then update database_id and kv id in wrangler.jsonc

Apply migrations and start:

npm run db:migrate:local
npm run dev:worker    # terminal 1 — worker on :8787
npm run dev:ui        # terminal 2 — Vite on :5173

Background server logs go to logs/ (gitignored).


Project structure

shared/        Deterministic sim — runs identically on server and client
worker/        Cloudflare Worker: API, auth, Durable Object (GameRoom)
src/           React client
migrations/    D1 SQL migrations
docs/          GitHub Pages site
.claude/       Skills and settings for Claude Code contributors

Contributing

See CONTRIBUTING.md. This is a solo project — best-effort responses.

For Claude Code contributors: CLAUDE.md has architecture invariants. Load .claude/skills/primordial-sim for the sim reference.

Security

Report vulnerabilities privately — see SECURITY.md.

License

MIT — Thomas Dvornik, 2026

Contributors

amphro

Issues