[HN Gopher] Open source rules engine for Magic: The Gathering
       ___________________________________________________________________
        
       Open source rules engine for Magic: The Gathering
        
       Author : moxvallix
       Score  : 170 points
       Date   : 2023-12-15 05:40 UTC (1 days ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | mnky9800n wrote:
       | There should be a screenshot on the homepage to show what
       | gameplay is like
        
         | 542458 wrote:
         | Looks like this, but most aspects are customizable.
         | http://3.bp.blogspot.com/-YCBsMRvKDQk/T1JrA2inI1I/AAAAAAAABu...
        
         | archargelod wrote:
         | There are a couple gameplay videos on youtube.
         | 
         | https://www.youtube.com/watch?v=DKyJcVmHhEI
        
       | archargelod wrote:
       | That's my favourite way to play magic. Real cardboard magic is
       | very expensive hobby. Digital magic (like Mtg Arena) is usually
       | toxic, too competitive and meta-driven for my liking.
       | 
       | So, instead, I enjoy playing against AI. And AI here is actually
       | decent. It can't do combo or play slow control decks well, but
       | with aggro archetypes it's an actual challenge.
       | 
       | If you want to try it - start with Adventure - it is a mode where
       | you get a starter deck and go into the open world to explore and
       | challenge other planeswalkers. You earn cards and gold that can
       | be spent on more cards. It's fun because you don't get stuck
       | playing the same best cards over and over. All cards from a long
       | magic history are available and have equal chances to show up in
       | rewards. It takes a skill to build a deck from pile of random
       | variable quality cards. But, oh boy, does it feel good when you
       | get good at it.
        
         | 542458 wrote:
         | I mostly play commander, and find the AI to be pretty dumb to
         | be honest. That's not saying it's not fun! But I find that even
         | with the AI using simple deck archetypes I usually have to put
         | three of them on an enemy team before they hit moderately-
         | skilled-human-player levels of challenge. The AI is pretty bad
         | at threat assessment, so removal, counters and board wipes get
         | used pretty randomly sometimes.
        
           | archargelod wrote:
           | If you want to feel more challenge - try the "experimental"
           | difficulty level for opponents. And maybe enable AI cheating
           | (they would see cards in your hand).
           | 
           | Normally, I believe, AI can blunder or miss some triggers.
           | But with these settings they'll try to play more optimally.
        
         | prepend wrote:
         | Has anyone recreated Shandalar in this engine?
        
           | archargelod wrote:
           | The adventure mode is basically the Shandalar. It was added
           | only a couple years ago by a single developer[0]. But it had
           | excellent support since, especially in 2023. And right now
           | it's very feature-rich with a lot of dungeons, bosses,
           | artifacts, simple quest system, etc. New stuff comes out
           | every month.
           | 
           | [0] - https://www.slightlymagic.net/forum/viewtopic.php?f=26&
           | t=304...
        
         | ncallaway wrote:
         | Are there any... archives of past MtG games or tournaments? Is
         | there a standard format for recording a draft and a game of
         | magic?
         | 
         | Curious if there's any existing data to start training AIs on,
         | or if these are more of the classic build an AI approach
        
           | freeone3000 wrote:
           | There's lots of _footage_ of games, and programs like 17lands
           | to extract games you have played from the arena log, and
           | commentary of games... but no easy-to-ingest recordings
        
         | echelon wrote:
         | > toxic
         | 
         | I hear this about a lot of gaming communities. Smash, Xbox, any
         | FPS.
         | 
         | Why does this happen? How and to what degree does it manifest?
         | How do you avoid it?
        
           | loveiswork wrote:
           | > Why does this happen?
           | 
           | A blend of anonymity, low self-soothing ability, human
           | instinct to talk trash during competition, people tying
           | identity to performance, skew towards younger people playing,
           | etc.
           | 
           | > How and to what degree does it manifest?
           | 
           | How? Mostly through voice and chat systems in-game. Also
           | through quitting the game, or blatantly "throwing" a match.
           | 
           | To what degree? From "You suck" to racial slurs to harm
           | yourself. It's ubiquitous across competitive games -- you'll
           | probably experience it every session.
           | 
           | > How do you avoid it?
           | 
           | The best way is to find a consistent group of folks to play
           | with. Stay away from "random queue". Certain games you can
           | turn off chat features, submit reports, etc. You can also
           | just ignore it and accept it as part of the thing.
        
             | tedunangst wrote:
             | There's really very little one can do to be "toxic" in mtg
             | arena, outside playing a control deck, which is clearly
             | part of the game or they'd stop making counterspells.
             | "Arena is toxic" means "I lost".
        
           | moate wrote:
           | If you want to avoid toxic behavior in your game, don't allow
           | multiplayer.
           | 
           | Some people will always be shitty, some people will want to
           | play your game, and some number of people will meet both
           | those criteria. The only way to fix it is after the fact, but
           | there's no way to avoid it.
           | 
           | As to the "how and to what degree" depends on the game and
           | the type of person it attracts. The second something is
           | competitive, toxicity is inevitable because many people take
           | losing personally.
        
             | akerl_ wrote:
             | Imagine if we took this approach outside of gaming.
             | 
             | "If you want to avoid toxic behavior at your workplace,
             | don't get a job".
             | 
             | We should be building systems and environments that can
             | sustain interpersonal interaction while combatting
             | toxicity.
        
               | moate wrote:
               | The better allegory (and actual advice that might be
               | useful): If you want to avoid a toxic workplace, work by
               | yourself.
               | 
               | Now, that said I'm being specifically pedantic: these are
               | steps to AVOID toxic environments. To COMBAT toxicity is
               | a whole other problem with way too many variables. I went
               | for the solvable problem.
        
           | vmilner wrote:
           | Even playing bridge (card game) with random people online can
           | be pretty grim, though playing online games organised by some
           | national authority (eg the English Bridge Union) is a lot
           | better.
        
         | JoshTriplett wrote:
         | > Digital magic (like Mtg Arena) is usually toxic, too
         | competitive and meta-driven for my liking.
         | 
         | I found that Gatherer had a much more friendly environment. If
         | you take a land-destruction or a counter/permission deck into a
         | game there, folks will just resign when they realize what kind
         | of deck you're playing, and word will get around to not play
         | with you unless you change decks. It's more the kind of
         | environment where you can play a fun, _decent_ , creative deck,
         | and have a good time with other folks doing the same.
        
         | piyh wrote:
         | Playing face to face with friends is the best part of magic.
         | 
         | I've proxied 30+ edh decks on my laser printer. I still money
         | on real cards, but increasing my kitchen table meta diversity
         | with proxies was a great move. Building infinite budget
         | Slivers, having perfect mana bases, and exploring jank to cedh
         | power levels are what I've wanted from this game all my life.
        
           | PNewling wrote:
           | Woah, did you have to hand cut all of those decks or how did
           | you do that?
        
         | grensley wrote:
         | How is Arena toxic? There's basically no opportunity for the
         | players to converse besides bland preset options which rarely
         | even gets used outside of a greeting at the start of the game.
        
       | j_m_b wrote:
       | Great to see Forge making the front page! It runs on mobile too
       | and the UI is frankly better than the desktop version. Definitely
       | install a snapshot version so that your client stays up to date.
       | The bots can play surprisingly well with agro and even control
       | decks, but can't play any kind of combo... Or even assemble Tron.
       | 
       | I've even used this to play local network games against other
       | players. If they had a global server that allowed you to find
       | games, it would be the perfect way to play MtG.
        
       | 7373737373 wrote:
       | Would it be possible to apply MuZero to this?
        
         | mdaniel wrote:
         | I went looking for MuZero implementations in order to see how,
         | exactly, they interact with the game space. Based on this one,
         | which had the most stars in the muzero topic, it appears that
         | it needs to be able to discern legal next steps from the
         | current game state https://github.com/werner-duvaud/muzero-
         | general/blob/master/...
         | 
         | So, I guess for the cards Forge has implemented one could
         | MuZero it, but I believe it's a bit chicken and egg with a
         | "free text" game like M:TG -- in order to train one would need
         | to know legal steps for any random game state, but in order to
         | have legal steps one would need to be able to read and
         | interpret English rules and card text
        
           | piyh wrote:
           | I was floated the idea of doing an AI competition for
           | Sabberstone, the open source rules engine for Hearthstone.
           | Even though Hearthstone is hugely limited in game complexity
           | compared to MtG, building an interface for a program to take
           | actions in Sabberstone and evaluate boardstates is not
           | trivial.
        
       | bhickey wrote:
       | How does it compare with Xmage and cockatrice?
        
         | archargelod wrote:
         | It's similar to Xmage, but with heavy leaning into PVE.
         | 
         | There are around a dozen original modes to play against AI
         | opponents: Adventure (a la Shandalar 1997), Quest, Planar
         | Conquest, Gauntlet, Puzzles. Plus practically every somewhat
         | popular format, including digital-only: Momir from Shandalar,
         | Drafts, Sealed, Cube, Commander, Oathbreaker, Brawl, Archenemy,
         | etc. etc.
         | 
         | There's a way to setup online multiplayer games, but no hubs or
         | rooms like in Xmage. It's also somewhat under-utilised feature
         | and therefore not so well supported.
         | 
         | I haven't actually tried cockatrice, but I believe it's more
         | like a tabletop simulator, e.g. you have to shuffle, draw, and
         | play the game almost manually? Forge is completely automatic
         | like Xmage, Shandalar and Magic Online. It also could be a fun
         | way to learn the rules of the game.
        
       | khaki54 wrote:
       | Is the adventure mode like that old Microprose Magic the
       | Gathering game? My brother and I loved playing that as kids!
        
       | Waterluvian wrote:
       | Oh this is a gold mine for me. Recently I've wondered how games
       | architect card game rules. So many rules feel kind of bespoke, so
       | I wasn't sure if you could implement a sort of logic so that
       | rules become configuration, or if each rule is just a function.
        
         | Daegalus wrote:
         | You might enjoy this official article on a bug in Arena rules
         | engine that goes into how they designed their systems.
         | 
         | https://magic.wizards.com/en/news/mtg-arena/on-whiteboards-n...
        
           | mdaniel wrote:
           | That's interesting, thank you. It seems what's old is new
           | again: I had a lot of contact with CLIPS early in my career
           | but I found that most of the programming tasks weren't heavy
           | rules based as much as CRUD and reporting apps. Given that
           | Forge is in Java, they may enjoy Drools
           | <https://github.com/apache/incubator-kie-drools#readme>
           | (which used to be a JBoss project but I guess has been
           | donated to the Apache Foundation)
        
           | LelouBil wrote:
           | > Now we come to the other program that we rules engineers
           | spend our time working on, along with the GRE, which is the
           | Game Rules Parser (GRP). This program (written in Python)
           | takes raw English rules text of Magic cards and converts them
           | into one or more CLIPS rules. It's what allows 80% or so of
           | newly written Magic cards to just work in MTG Arena
           | automatically.
           | 
           | Wow, didn't even think about this being a possibility! But I
           | guess if they have a very strict dictionary and grammar rules
           | for card effects this kind of thing can work !
        
             | moate wrote:
             | Tons of creatures with only evergreen/deciduous abilities
             | would probably be super easy to template for something to
             | parse, as would most lands.
             | 
             | 80% feels "right" as someone who's done some game design in
             | the tabletop space.
        
               | OskarS wrote:
               | Yeah, obviously a creature with Haste or Trample or
               | whatever is very easy to make a simple parser for. But I
               | can imagine because WotC is so strict on how they word
               | text on cards, even more advanced interactions would be
               | pretty straight-forward to parse. Like, if a card says:
               | 
               | "When <card name> enters the battlefield, return target
               | non-land card from your graveyard to your hand".
               | 
               | Both parts of that sentence is always worded the same, so
               | it's probably quite straight-forward to make a parser for
               | this: just have a parse rule for "When <card name> enters
               | the battlefield, <triggered ability X>", with a database
               | of triggered abilities (and their implementation) that
               | include all the ones that have already been printed.
        
       | mdaniel wrote:
       | It must be M:TG week, which I think is fantastic!
       | 
       | https://news.ycombinator.com/item?id=38646892 is the I guess
       | annual(?) repost of the "Magic: The Gathering Is Turing Complete
       | (2019)" paper
       | 
       | and then there were some other M:TG threads that may interest
       | those who didn't see them
       | 
       | https://news.ycombinator.com/item?id=38525978 _(I hacked Magic
       | the Gathering: Arena for a 100% win rate)_
       | 
       | https://news.ycombinator.com/item?id=38533105 _(Fine-tuning
       | Mistral 7B on Magic the Gathering Draft)_
        
       | 7373737373 wrote:
       | Has anyone tried simulating the Turing complete deck?
       | https://youtu.be/pdmODVYPDLA
        
       | mdaniel wrote:
       | In case anyone is curious, it uses Scryfall for the card art
       | https://github.com/Card-Forge/forge/blob/forge-1.6.59/forge-...
       | and I wish they'd offer a torrent (or IPFS) because I can't
       | imagine the amount of bandwidth it must cost them and I would
       | seed the hell out of any such thing
       | 
       | Now, one possible reason would be copyright something-something
       | but as it currently stands it's not like one needs to log in to
       | download the card art one at a time, so ... I struggle to think
       | of what risk they're driving down
        
       | freediver wrote:
       | Oh neat, would get us much closer to having a 'best deck
       | simulator' like this:
       | 
       | https://www.youtube.com/watch?v=Xq4T44EvPvo
        
       | agazso wrote:
       | I downloaded this and it looks cool and comprehensive, but for me
       | the card artwork is missing.
       | 
       | Maybe some server is hugged by HN? Or something needs to be set?
        
         | 542458 wrote:
         | It's a bit unintuitive, but IIRC you need to go into the
         | settings and tell it to download the card art. Two reasons for
         | this: 1, copyright and 2, it's a big download if you get them
         | at full quality.
        
           | agazso wrote:
           | Thanks, I found it in the 'Content Downloaders' menu!
           | 
           | It estimates the download time to 6 hours, and it's not
           | because of the size but most likely their server works
           | slowly. And in the meanwhile it does not let you play, well
           | tomorrow then :)
        
             | Marthinwurer wrote:
             | There's a setting somewhere to auto download cards when
             | they're seen. That should get you up and running quicker!
        
       | pdntspa wrote:
       | Wow, if this is what I think it was I remember using this to play
       | MTG online vs some friends waaaaaaaaaaaaay back in the day. This
       | was/is a really good alternative to MTGO
       | 
       | edit- It is!
        
       | LelouBil wrote:
       | Here is an equivalent for Yu-Gi-Oh!
       | 
       | https://github.com/edo9300/ygopro-core
       | 
       | I find the CardScript repository very interesting to look at:
       | https://github.com/ProjectIgnis/CardScripts
       | 
       | And here is the actual game client :
       | 
       | https://github.com/edo9300/edopro
        
         | mdaniel wrote:
         | https://github.com/ProjectIgnis/CardScripts#contributing
         | 
         | > Please keep all bug reports and questions on Discord; do NOT
         | open an issue or pull request for this purpose.
         | 
         | Yikes : - ( chat streams are where information goes to die
        
       | ryanbigg wrote:
       | I've done some work on something "less serious" in Ruby:
       | 
       | https://github.com/radar/mtg
       | 
       | I view it as a wide project full of little interlinked code
       | katas.
       | 
       | I've thought about the card parsing stuff but that's beyond my
       | ability.
        
       ___________________________________________________________________
       (page generated 2023-12-16 23:00 UTC)