3
Show HN: A (de)compiler and parser/engine for custom Magic: The Gathering cards
Hey HN! I've been working on this for the past few months and I think it's at the point where I'm ready for some user feedback.
It's a WASM engine attempting to accurately model all of MTG's rules and cards. AFAIK, this is the first MTG engine which tries to accomplish this by live compiling the entire card collection at runtime, instead of coding each individual card.
You can create your own unique cards to playtest against ("Compile Card" button is what you're looking for), as long as they follow the engine's supported grammar (which I'm working on so that it fully supports Magic's ~30k legally playable cards, currently at 23k partially/17k fully supported).
It also supports 4-way P2P multiplayer lobbies via PeerJS, though I haven't had enough time to test everything network related so there may be some hidden bugs there!
My dev process was heavily influenced by the recent surge in agentic coding, but I think I've settled on an architecture which successfully manages to avoid slop creeping in:
Each card from its original, normalized oracle text into a CardDefinition struct which contains every single behavior for that particular card. By the time this card definition is compiled, we no longer have access to the original oracle text.
Each effect in the card's compiled definition can be decompiled into human readable text, after which a series of normalization steps based on the AST structure of the card's compilation and a post-pass to cleanup awkward wording is applied. The resulting compiled oracle text is compared against the original card's using vector embeddings, which gives us a semantic similarity score.
The entire purpose of this development workflow is making it obvious to the AI which cards are working correctly and which ones still need better support, without having to rely on behavioral tests for every single card. It took me some time until I finally managed to get the architecture to the point where the AI doesn't cheat its way into improving the card coverage, but the whole experience has been a fantastic way of getting used to this new way of coding and I'm excited to see how the future of our profession looks like in a few years.
I'm looking for any kind of feedback, both UI/UX and engine related, so please share your thoughts!