|
|
||
|---|---|---|
| public | feat: Add fifai | |
| src | feat: Add fifai | |
| .env.example | feat: Add fifai | |
| .gitignore | feat: Add fifai | |
| package.json | feat: Add fifai | |
| pnpm-lock.yaml | feat: Add fifai | |
| README.md | feat: Add fifai | |
| rules.md | feat: Add fifai | |
| tsconfig.json | feat: Add fifai | |
⚽ fifai
Prompt-based soccer for a group. Two managers each write their tactics in plain language, the AI referees a full 90-minute match, and everyone watches it play out live on a shared clock — in a couple of minutes, not ninety.
The idea (kept simple)
The whole game is one function over plain data:
simulate(home, away, rules) → MatchResult
The AI is only the referee. It holds no memory: you hand it the tactics + the rules, it hands back a full match as data. Everything else is kept apart:
| File | Concern |
|---|---|
src/schema.ts |
the data (types). Knows nothing else. |
rules.md |
the referee's constitution. Edit to change the AI. |
src/engine.ts |
the referee: tactics + rules → a match. |
src/store.ts |
persistence (SQLite). |
src/server.ts |
the web shell + shared playback clock. |
public/ |
what everyone watches. |
Generation and "live" are separate: the match is generated once as data, then the server replays it on a clock so every viewer sees the same minute.
Run it
pnpm install
pnpm dev
Open http://localhost:3000 on your machine (or share your LAN IP so the group can join), fill in two sets of tactics, and kick off.
No API key needed to try it — without one, fifai uses a deterministic mock
referee. To use the real AI referee, copy .env.example to .env and set
GEMINI_API_KEY (get one at https://aistudio.google.com/apikey).
Test it
pnpm test # smoke tests (mock engine, no key, no network)
pnpm sim # referee a match straight to your terminal
pnpm sim "Real Prompt" "high press, attack the wings" "Deep FC" "park the bus"
Knobs
Set in .env (see .env.example):
FIFAI_PLAYBACK_SECONDS— real seconds to play back a full 90' (default 120).FIFAI_MODEL— referee model (defaultgemini-2.5-flash).FIFAI_ENGINE=mock— force the mock referee even with a key set.PORT— default 3000.
The fun lives in rules.md (how the referee judges) and in the tactics people write.