1
0
Fork
You've already forked fifai
0
A prompt-based fotball game
  • TypeScript 49.6%
  • JavaScript 23.5%
  • CSS 16.2%
  • HTML 10.7%
Simen A. W. Olsen 5290a93aeb
feat: Add fifai
2026年07月06日 13:11:04 +02:00
public feat: Add fifai 2026年07月06日 13:11:04 +02:00
src feat: Add fifai 2026年07月06日 13:11:04 +02:00
.env.example feat: Add fifai 2026年07月06日 13:11:04 +02:00
.gitignore feat: Add fifai 2026年07月06日 13:11:04 +02:00
package.json feat: Add fifai 2026年07月06日 13:11:04 +02:00
pnpm-lock.yaml feat: Add fifai 2026年07月06日 13:11:04 +02:00
README.md feat: Add fifai 2026年07月06日 13:11:04 +02:00
rules.md feat: Add fifai 2026年07月06日 13:11:04 +02:00
tsconfig.json feat: Add fifai 2026年07月06日 13:11:04 +02:00

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 (default gemini-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.