MetaMatching
Used in a published dissertationA web platform I built for a friend’s PhD dissertation in behavioral science. It runs a real-time, three-player decision game, follows the study’s experimental design to the round, and exports every round for analysis.
What it does
Three participants play together in a live session. Each round, every player picks a row on a grid; the payouts reward individual choices or a shared group outcome, which is what the study measures. A session runs 9 blocks of 21 rounds.
A moderator creates a room, shares an invite code, and starts the run, and can fill empty seats with bots for testing. When a session ends, the moderator downloads a CSV with one row per round. No off-the-shelf survey tool could run a synchronous multiplayer design like this, which is why I built it from scratch, working with my friend on the experiment.
How it’s built and run
- Stack
- Node.js with Express 4 and Socket.IO 4, EJS templates, and MongoDB. Sessions are shared between HTTP and sockets.
- Hosting
- A systemd service running as its own user, with filesystem and privilege hardening and automatic restarts, behind nginx and Cloudflare. Installed and updated by script.
- Data
- Round data stays out of the database: it lives in memory during a session and is written to CSV and JSON at the end. Downloads are limited to the room’s moderator and admins, and participant files are kept out of version control.
- Access
- Invite codes for participants. Accounts use salted scrypt password hashes.
- Tests
- A schedule test that proves the counterbalancing, and an end-to-end test that drives a live server with bot players and checks the payouts. Both run manually; there is no CI.
Engineering notes
-
Counterbalanced schedules
Each block contains every combination of player, condition, and incentive exactly once, plus rounds with no incentive, shuffled into a fresh order. The schedule actually used is written into the export, and a test checks the counts across all 189 rounds.
-
Surviving a refresh mid-session
A study session can’t restart because one participant’s browser reloaded. Players keep their seat and game state across a refresh or dropped connection, and a short grace window keeps brief disconnects from disturbing the other two players.
-
Paying out each round exactly once
When the last person and a bot lock in at almost the same moment, a guard stops the round being scored twice. Payouts go out in turn order and are capped at what is left in the shared token pool.