Note: This repository is entirely vibe-coded, and the read me is out of date (currently only 1 human player is implemented, and some features were cut for time like the camera integration and wristbands.)
Turn the FREE-WILi embedded platform into an AI-powered social deduction game host where AI agents think, speak, and scheme alongside human players.
This repo currently runs a Python host application that drives a FREE-WILi device over USB using freewili-python. The active game mode is a Mafia MVP:
src/main.pyconnects to the device, shows the hardware menu, and starts the moderator web UI.src/game/engine.pyruns the day/night loop, state transitions, human push-to-talk capture, and AI turns.src/game/agents.pyuses Gemini for structured Mafia decisions.src/game/announcer.pyuses ElevenLabs for TTS and sends audio to the FREE-WILi display processor.src/moderator/app.pyserves a small local Flask UI for watching state and logs.
The older README described a future on-device WASM architecture. That is not what this codebase is today. The current implementation is host-driven Python with the FREE-WILi acting as the physical interface.
ai_onlyandmixedare the main playable paths exposed by the startup menu.debugmode exists to force the human player into Mafia for demos.- Human speech capture uses FREE-WILi audio events plus Gemini transcription.
- Camera capture and wristband assignment are currently skipped or stubbed in the active flow.
working_backup/contains older experiments and is not part of the active runtime.
- FREE-WILi badge/device
- Host Linux laptop connected over USB
- Speaker, mic, display, LEDs, and buttons on the FREE-WILi
- Optional camera and wristband hardware were part of the hackathon concept, but they are not fully wired into the active runtime path
- Gemini API for AI player reasoning and speech transcription
- ElevenLabs for text-to-speech
- Flask for the local moderator panel
- Python 3.10+
- A working FREE-WILi connection
GEMINI_API_KEYELEVENLABS_API_KEY
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtCreate a .env file in the repo root:
GEMINI_API_KEY=...
ELEVENLABS_API_KEY=...sudo ./venv/bin/python src/main.pySkip the menu and start AI-only immediately:
sudo ./venv/bin/python src/main.py --skip-menuThe moderator panel is served on http://localhost:5000.
Host Python Runtime
├─ src/main.py
│ ├─ hardware connection/bootstrap
│ ├─ menu selection
│ └─ Flask moderator thread
├─ src/game/engine.py
│ ├─ game state orchestration
│ ├─ human push-to-talk capture
│ ├─ AI turn scheduling
│ └─ phase transitions
├─ src/game/agents.py
│ └─ Gemini-backed structured decisions
├─ src/game/announcer.py
│ └─ ElevenLabs TTS -> FREE-WILi playback
└─ src/moderator/app.py
└─ local state/log viewer
FREE-WILi playback is strict. The shared implementation now lives in src/game/audio.py.
Rules the code assumes:
- Build playback WAVs as mono 16-bit PCM.
- Default playback sample rate is
8 kHz. - Upload to the display processor under
/sounds/. - Play by basename only, not by full device path.
Canonical code paths:
src/game/audio.pysrc/game/announcer.pytests/test_tts_playback.pysrc/utils/cleanup_hw.py
Human speech currently flows like this:
- The player holds
GREEN. src/game/engine.pystreams FREE-WILi audio events while the button is held.- The audio is written to
/tmp/temp_human_<name>.wav. src/game/speech.pyuploads that WAV to Gemini for transcription.
This replaced an older on-device recording path that was failing during the hackathon.
Hackathon/
├── README.md
├── Design document.md
├── audio_config.json
├── requirements.txt
├── src/
│ ├── main.py
│ ├── moderator/
│ ├── game/
│ │ ├── agents.py
│ │ ├── announcer.py
│ │ ├── audio.py
│ │ ├── engine.py
│ │ ├── state.py
│ │ └── display.py
│ ├── assets/sfx/
│ ├── demo/
│ └── utils/
├── tests/
├── references/
└── working_backup/
Run focused unit tests:
./venv/bin/python -m unittest tests.test_announcer_audio tests.test_speechRefresh the device audio assets:
sudo ./venv/bin/python src/utils/cleanup_hw.py --refresh-assetssrc/assets/sfx/is the canonical local SFX directory used by the runtime utilities.- There are archived or duplicate experiment artifacts in the repo from hackathon development; the active runtime paths are the modules under
src/game/,src/main.py, andsrc/moderator/. - Some hardware-facing tests require the device and Linux permissions that the unit tests do not.
Note from hackathon submission day: "Hackathon project — license TBD."