u/wingedsheep38

Argentum — an open-source Magic: The Gathering client

Argentum — an open-source Magic: The Gathering client

Hey all — I've been working on a MTG engine / client and figured this crowd might actually enjoy it: magic.wingedsheep.com. No download, no account needed, just open it and go.

Some stuff you can do right now:

- Draft a real booster draft with friends: Spin up a lobby for up to 8, crack packs, pass, and build your deck — then jump straight into games with the pool you drafted.
- Rules engine: The rules are properly implemented — the stack, priority, combat, triggers, the layer system, state-based actions — so it plays like real Magic, not a simplified version. You just make plays and it handles the fiddly rules bits for you.
- Play with friends with an invite link, or play against an AI if no one's around.
- Sealed and custom decks too, if drafting's not your thing.

It's a passion project and still very much a work in progress, so it won't have every card yet — but a good chunk of recent Standard sets are already in, plus some older ones going back a fair way, so there's plenty to play with. I'm adding more cards and sets all the time. It's open source too, so if you're into that side of things the code's on GitHub.

Would genuinely love for people to try it and tell me what feels off — bugs, cards behaving weird, whatever. There's a Discord for that too.

Play: https://magic.wingedsheep.com
Discord: https://discord.gg/dy6eSRPWzu
Source: https://github.com/wingedsheep/argentum-engine

https://preview.redd.it/0oepg915hkah1.png?width=4096&format=png&auto=webp&s=d821fde7e388eec569795dfa8fdd613834176cf1

reddit.com
u/wingedsheep38 — 6 days ago
▲ 35 r/Kotlin

Argentum — a Magic: The Gathering rules engine in Kotlin

Magic has over 28,000 unique cards and one of the most notoriously complex rules systems in games. I've been building an engine that implements it properly.

The core is a pure function: (GameState, GameAction) -> (GameState, List<GameEvent>). State is fully immutable, modeled as an ECS. There's no card-specific logic in the engine at all — the hard machinery (the 613 layer system, the stack, priority, replacement effects, state-based actions) lives in one place, and cards are pure data defined through a Kotlin DSL.

The whole thing is built as four layers, each with a strict responsibility:

- SDK — the data contract. Cards, effects, targets, and dynamic values are all pure, serializable data structures — no execute(), no lambdas. A dynamic value like Tarmogoyf's power is an AST node (DynamicAmount), not a (GameState) -> Int, so it can be serialized, inspected for UI text, and lazily evaluated. This layer defines what happens.
- Rules engine — the functional core. A zero-dependency Kotlin library (no Spring, no I/O) that interprets that data. Immutable GameState, ECS entities, and — because it can't block a thread waiting on network input mid-resolution — reentrant, serializable continuations: when a spell needs a choice ("search your library"), it pauses, pushes a continuation frame, and resumes when the answer arrives. This layer defines how.
- Game server — thin Spring Boot orchestration with zero game logic. It routes WebSocket messages, manages sessions, and does server-side state masking (fog of war) so a modified client can't read your opponent's hand. It's an anti-corruption layer: the engine's GameState never leaves the server, only client-safe DTOs.
- Web client — a dumb terminal. No game rules, no legal-action computation. It renders what the server sends and captures intent; the server is authoritative for everything.

The payoff of the layering: the engine is a pure library, so it's exhaustively testable without a server, and it's portable — the same engine also powers a Gymnasium-style RL/MCTS wrapper for agent research, with no server or browser involved.

It's playable at magic.wingedsheep.com — booster draft tournaments, multiplayer, up to 6-player free-for-all.

Most of it was written with Claude Code under a strict architecture I kept it to. Source and a writeup below

Repo: https://github.com/wingedsheep/argentum-engine
Writeup: https://wingedsheep.com/building-argentum-a-magic-the-gathering-rules-engine/
Discord Channel: https://discord.com/invite/dy6eSRPWzu

reddit.com
u/wingedsheep38 — 6 days ago