Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

WAR OF TOYS

A real-time strategy game in a child's room: toy soldiers, Unity 6 (URP, 3D), two players over Photon Fusion 2 (host mode). Each player has an AI Commander: an LLM agent that reads a fog-filtered snapshot through nine MCP tools, answers rules questions with hybrid RAG (BM25 + embeddings), and proposes a schema-validated action plan that the player approves or rejects. Laya, a small fast decision layer (ai/laya), answers routine situations from a taught move book and hands the harder ones to the LLM.

Repo layout

Path Content
Assets/_Project/ Game code, scenes (map_childroom), GameData, EditMode tests
ai/ Python AI layer: gateway/ (FastAPI), agent/, mcp_server/, rag/, laya/, contracts/
evaluation/ Prompt set, runners, metrics and results
scripts/ setup-ai.ps1, run-gateway.ps1
docs/ Demo rehearsal and evidence
TASKS.md Task board and status

Requirements

  • Unity 6000.6.2f1
  • Python 3.12 (for ai/)
  • Ollama with llama3.1:8b (optional; local fallback)
  • Groq API key (optional; the default provider is groq-first, falling back to Ollama)

Setup (AI layer)

scripts\setup-ai.ps1

It creates ai/.venv, installs the dependencies, installs PyTorch (CPU build, about 200 MB; without it Laya returns 503 and the rest still works), pulls llama3.1:8b if Ollama is installed, creates ai/.env with a random GATEWAY_TOKEN (never printed), and runs the tests. Flags: -DryRun, -SkipOllama, -SkipTests. Put GROQ_API_KEY in ai/.env yourself if you want Groq. Never commit ai/.env.

Run

  1. Open the project in Unity and load Assets/_Project/Scenes/map_childroom.unity.
  2. Start the gateway in a terminal: scripts\run-gateway.ps1 (http://127.0.0.1:8765).
  3. Press Play. K toggles the AI Commander panel; T opens the Laya teach panel.

Multiplayer

  1. Build to a folder outside the repo (for example C:\Builds\Emberfront).
  2. Host in the Editor or from the exe, join from the other instance. Command-line form: Emberfront.exe -screen-fullscreen 0 -screen-width 1024 -screen-height 600 -host RoomName and the same with -join RoomName (-screen-fullscreen 0 keeps it windowed).
  3. The Photon region is pinned to eu. Both sides must use the same region; override with -region <code>.

AI on a built client

The Editor reads the token from ai/.env. A build does not, so give it the gateway token either way:

  • a gateway_token.txt next to Emberfront.exe, or
  • the environment variable EMBERFRONT_GATEWAY_TOKEN.

Copy it from ai/.env into the file without printing it (PowerShell, from the repo root; adjust the target folder):

$t = (Select-String -Path ai\.env -Pattern '^GATEWAY_TOKEN=(.+)$').Matches[0].Groups[1].Value
[IO.File]::WriteAllText('C:\Builds\Emberfront\gateway_token.txt', $t)

The gateway URL can be changed with EMBERFRONT_GATEWAY_URL (default http://127.0.0.1:8765).

Tests

  • Unity EditMode: Window > General > Test Runner > EditMode (Assets/_Project/Tests/EditMode).
  • Python: cd ai then .venv\Scripts\python -m pytest -q
  • Evaluation: evaluation/README.md (ai\.venv\Scripts\python evaluation\run_eval.py, then evaluation\metrics.py)

More

  • ai/README.md: AI layer overview, env vars
  • ai/laya/README.md: Laya design and teaching
  • evaluation/results/laya.md: Laya evaluation (2026-11-24)
  • evaluation/results/summary.md: model and agent comparison
  • TASKS.md: task status

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages