Skip to content
hen1227Public

About

Let a browser agent turn an idea of a game variation such as "Tic-Tac-Toe, but the pieces are rock paper and scissors" into a safe, modular, online multiplayer board game with powerful bot!

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

GamesLab

Make your own variations of board games!

It's as easy as telling an Agent (with web capabilties) to change a rule or aspect of a board game and watch it come to life ready for multiplayer immediately!

Built for the OpenAI WebMCP Challenge.

Live: https://gameslab.henhen1227.com — open it in ChatGPT's in-app browser, or in Chrome with WebMCP enabled, and the page hands your agent its tools.

Games are data, not code

A game is completely rule defined: the board, the pieces, how they move, what happens when they meet, and how you win. There is no scripting hook and nowhere to put one! Every list is capped and nothing recurses, so the cost of a position is known before anyone plays it.

By only allowing specific structured rule-based defintions, a game a stranger wrote ten seconds ago safe to open.

The agent part

The site publishes WebMCP tools on document.modelContext So you can say "chess but the bishops jump" to your browser's agent finds chess, changes the rules, and hands you a working version to play.

Neither half could do that alone. The model knows what chess is and what a bishop does; the page knows what a legal rule is and can prove the game is valid.

While the agent is working, the user can add comments to its actions which the agent sees before moving on.

The WASM Rust Engine

Some rules are just silly and don't make a good game. This should be pretty easy to identify. Using a speedy rust Alpha-Beta pruning bot, we can use the rules to guess what a "winning" position looks like and search millions of games and positions in no time flat (<250ms). We can validate that one side doesn't "always" win or the game doesn't "always" draw.

Obviously a bot that works for nearly any tile-based board game won't be the best of it's kind, but it doesn't need to be. It needs to be competent enough to determine when a game is bad, or give the human author someone to validate the game works how they want.

This rust bot is targeted to WASM and deployed on the website. So no matter what game the user builds with-in the game's ruleset, there is a bot to test the game against.

Explaining a completely new game's rules

When playing online it's important everyone is clear on the rules even if the game is brand new and no one's written a description yet. Using the game's generalized rule set, and by having a bot play hundreds of games, we can snapshot "interesting" positions and list them. It uses this to show how pieces capture, the game progresses, and how the game is won.

Running it

npm install

Two processes in development. The Go server is the authority; Vite proxies /api and /ws to it, so both halves are same-origin and nothing needs configuring.

npm run backend:dev
npm run dev

Then open http://localhost:5173. The library seeds itself on first start with Chess, Checkers, Connect Four, Tic-Tac-Toe, Reversi, Plague, Honeycomb, RPS Total War and RPS Infiltration.

To run it the way it ships — one binary, no dev server:

npm run serve

The WebAssembly package is committed under frontend/src/engine/wasm/, so neither the build nor the container needs a Rust toolchain. Rebuild it after changing engine-rs/:

npm run wasm

Everything, before you push:

npm run check

Deploying

The binary is static and pure Go, so it cross-compiles to anything and needs nothing installed on the far end:

cd backend && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o gameslab ./cmd/gameslab

It listens on a TCP port or a Unix socket, whichever -addr looks like. There's a container too:

docker build -t gameslab . && docker run -p 8080:8080 -v gameslab-data:/data gameslab

deploy/ has both: a systemd unit with nginx vhosts, and a Compose file with a Caddyfile. deploy/deploy.sh builds and ships to a server over ssh.

The public URL has to be HTTPS, or browser agents won't connect.

Where things are

AGENTS.md working on this repo: the invariants, the traps, the layout
docs/rulespec.md the rule format
docs/agent-experience-plan.md why the tool surface is scoped the way it is
frontend/src/webmcp/ the tools, and the descriptors behind them
frontend/src/engine/ the TypeScript engine and the lowering
backend/internal/game/spec/ the Go engine
engine-rs/ the Rust one
specs/ every game, as JSON

License

MIT — see LICENSE.

About

Let a browser agent turn an idea of a game variation such as "Tic-Tac-Toe, but the pieces are rock paper and scissors" into a safe, modular, online multiplayer board game with powerful bot!

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages