Coding the game of unspoken rules in Scala 3

By Adrien Piquerez

Elevator Pitch

How do you build a multiplayer, online game where the rules are written by the players? Inspired by the game Mao, we created a game where winning lets you add new rules in live Scala code. In this talk, we’ll share how we built it end-to-end in Scala 3: from the game engine, to the live coding.

Description

What does it take to create a game where the rules are unknown, constantly evolving, and authored by the players themselves? Inspired by the chaotic and creative card game Mao, we’ve built a multiplayer, browser-based game entirely in Scala 3: backend, frontend, and user API. Players don’t just play the game, they program the rules in real-time.

This talk is a feedback session from our development journey. We’ll walk through a selection of the most interesting challenges we faced, from game engine to code editing, and share what worked (and what didn’t) when pushing Scala 3 into this weird and wonderful space.

Topics we’ll cover include: - Modularization of game logic and runtime - Live Scala code editing in the browser - Analyzing user-submitted code - Scala-style web animations and UI interactivity - Using LLMs to help non-programmers write game rules - Security against malicious code

Along the way, we’ll raise bigger questions: - Is Scala 3 a good language to build such a game? - Should players program in full Scala, or do we need a specialized DSL? - How do we lower the barrier to entry while preserving the expressive power of the language?

Whether you’re into Scala programming, online games, or coding experiment — this talk is for you.

Notes

The talk will focus on the technical aspects of how we built the game, with an emphasis on architecture, the tech stack (Cask, Laminar, Web animations, CodeMirror), as well as the integration with the Scala compiler, the security measures and the AI integration (LLM). Our goal is to inspire others to build web games or web applications using Scala 3, end-to-end.

It’s important to note that the game is more than just an experiment. It’s already playable and available online (currently in beta). By the time of the conference, it will be fully accessible to attendees, who can try it out firsthand. The game will also be open for discussion and contributions, on GitHub.