Magic: The Gathering is Turing Complete
arxiv.org
arxiv.org
[1] http://beza1e1.tuxen.de/articles/accidentally_turing_complet...
It's like pulling the state table out of a Turing machine and showing it off all by itself. It doesn't take much to extend it into a full Turing machine, but it's also not doing much at all by itself. A Turing machine is simple, and half a Turing machine is really simple. It's missing the point of "accidental Turing completeness" if it can't iterate to an actual result.
Edit: Just saw the HTML/CSS3 example on the page. Mind blown.
* https://www.jefftk.com/p/nomic-report-iii-conclusion
- turns go clockwise
- play one card per turn
- if someone breaks a rule, they take back their card and draw one extra
- first to shed all their cards, followed by saying "Mao!" wins
- saying "Mao" any other times means drawing three cards (so if someone broke a rule playing their last card and had to take back their card, they end up drawing three cards
- Similar to the previous rule: not saying "Mao" upon successfully playing the last card also means drawing three cards. And it is breaking the rules, so the player has to take back the card and draw a card.
- asking any question means drawing a card (be brutal: "WHAT?!" counts as a question)
- one player starts with making up two extra rules
- the winner of a round makes up a new rule, the old rules stay
... then grab a bunch of friends, say "you'll figure it out", come up with two rules of your own and start playing. You'll likely win the round (because they will all ask questions in confusion), and be allowed to add another rule.
Restart after a couple of rounds. Troll until they threaten to quit (at which point you explain the rules) or until they actually figure it out. Watch their expressions go from frustration to gleefully anticipation, and go look for a fresh victim together.
Can't think of anyone in my direct environment crazy enough to try this.
It was a long-lived informal group of game-players that started in the 1970s, and has continued (with almost-total replacement of the membership over time) until roughly the present day. We played very different games at different times--pencil-and-paper roleplaying games; Risk and Diplomacy; Civilization; Cosmic Encounter; Illuminati; MMORPGS; Nomic; custom versions of several of the above using modified rules and our own maps and other materials.
Nomic worked quite well for one of the iterations of the group. It was very entertaining--though exhausting to play--and it was educational about the legislative process.
I think the most significant thing I learned about legislation is that, regardless of what it is theoretically supposed to accomplish, what it actually does accomplish is to reward legislators who are skillful at gaming the legislative process.
I learned other things, too:
- Given an incentive, people can be incredibly flexible and creative in trying to outmaneuver one another in dealmaking.
- Very often, the most capacious bladder wins.
- If you succeed in making rules about what is allowed, you must expect that others will make rules redefining the terms used in those rules.
- Any self-serving proposal can be made to sound like it's for the common good with the right combination of incentives, creativity, and charisma.
- No matter how bitterly someone opposes your proposal, you can still get their support if you can find the right payoff and add it to your proposal.
- There is no way to limit what other legislators can do to a proposal through amendments (we tried all sorts of things, and they all ultimately failed).
I also learned that real-world legislators have to have incredible endurance. A hotly-contested game of Nomic can drag on for hours and leave all the participants completely exhausted. Real legislation must be much more grueling. The stakes are higher, the costs and rewards are more significant, and the game never ends.
No MTG is not at all similar to role playing games.
"Though similar to role-playing fantasy games such as Dungeons and Dragons, it has significantly more cards and more complex rules than other card games."
As if similarity to D&D said anything at all about number of cards relative to other card games.
http://dnd.wizards.com/products/tabletop-games/rpg-products/...
That and D&D being associated with all things nerd, which was very out of vogue through the 90's.
While there are certain play patterns, the space of potential actions is extremely large and there is a great number of synergistic interactions between cards that needs to be taken into account.
From an AI perspective Magic is also very hard because it is:
* Non-deterministic
* Partially observable
* AntagonisticYes, that's certainly the promise of MTG - and is the reason why I was drawn to it originally and continue to be, at least passively, interested in it.
The idea is that there are so many different cards and so many potential interactions that every deck could be fantastically unique and every game could produce very unique outcomes.
I have found, in 25 years of playing MTG that this is not the case. The reality is that in every release, or set of "legal" cards, there are a few overwhelmingly advantageous cards and card combinations that must either be adhered to or prepared against. Further, "classes" of decks (counter decks, control decks, blast decks, etc.) need to be fairly simple and anti-fragile to work effectively given the random draw, etc.
My opinion, circa 1998 or 1999, was that to really open up the playing space, WOTC needed to produce sets of very complex cards that had abilities and interactions that in themselves were as complicated as the game was. Cards whose abilities and interactions we would still be discovering years later. Perhaps even random attributes/abilities For obvious reasons this is not the direction they went and would be a big hurdle for new players.
And so every set has, effectively, its own channel+fireball and we all play that or prepare for it and for all the turing-completeness, there's not that many surprises at the game store on Friday night ...
Someone really ought to design a format that bans all the straightforward but powerful cards, forcing a bit more creativity into the mix, but I fear the banned list would be prohibitively long and surprisingly difficult to come up with after the first round of obvious bans. There's always some new infinite combo that's a little too easy to pull off once the super fast quick wins are out of the way.
Edit: there's always that person (I've occasionally been him) who doesn't play to win and just tries to mess with the game's limits as much as possible. I knew someone with a "Jester Deck" that played cards that so mangled the rules that no one could even figure out how to finish the game any more. That was pretty interesting.
Most of the games AI has surpassed humans at have several things in common, and one of the biggest is they don't contain a great deal of hidden information. Chess is all in the open, with very set defined options. There are a ton of different game states, but none of them involve "what if my opponent suddenly drew the one card that I cannot in any way do anything about to prevent ruination".
TL;dr- robots will never defeat the "heart of the cards" unless you stack the game in their favor.
Unless you're allowing the AI to know the contents of the deck it's opposing in magic, you're probably making those decision trees impossibly complex. "Is countering this lightning bolt optimal or not" has a lot more meaning when you know what else is in the deck with the lightning bolt.
Also, how does the AI select its deck? Does the player know going in what deck it will be playing? Part of the problem here is that you can build a weird, off meta deck for either the AI or player that can win a single game but what does that mean? Most decks are designed for a full tournament grind based on an expected range of decks to play against.
I guess you'd have to have the AI compete in a full tournament, but then the skill level of the individual players becomes a variable. IDK, it just seems like a really big hill to climb.
I mean when we get to that level, couldn't we just use our unlimited time and resources to just create a model of the entire universe and just observe all the people playing the game and at all skill levels as well?
Could be interesting to see what happened, I just don't think you'd be able to build an "unbeatable" machine that didn't also cheat the RNG elements of the game/have the full decklist of its opponent.
For go modeling basically you have in input an image of the go board, and for DOTA an image of your screen and the action you have are "limited" and do not change wildly depending of the state of your screen (except if you're dead on Dota).
For Magic, you can't just use deep reinforcement learning with an image input, you need to somehow track the state of your deck, cards, instant effects, what your opponent did ...
This article is all about how those synergies are Turing complete and thus cannot be easily calculated since doing so reduces down to solving the halting problem.
edit: that being said I suspect that writing an AI that plays "well enough" to beat human players, as opposed to optimally, is quite doable.
That seems like a contradiction.
Maybe you are asking whether it is possible for the winning strategy of a very simple deterministic game to be non-computable. In other words, maybe there's a possible way of defining computability which is orthogonal to complexity. The CS definitions of both terms are closely connected to Turing machines, though. Can you imagine a simple deterministic game that couldn't be "solved" by an algorithm?
The usual complexity classes of decision problems, such as P and NP, are subsets of what a Turing machine can solve, and so are weaker complexity classes.
So it seems perfectly possible (and in fact highly likely) that this result does not hold if players play optimally, especially if deck selection is included in the strategy.
For MTG strategy to be computable you must be able to compute whether entering this computation is a good choice, which requires solving the halting problem.
>In this paper we show that optimal play in real-world Magic is at least as hard as the Halting Problem, solving a problem that has been open for a decade
I think the Turing completeness is definitely still part of the appeal of Magic, because the bizarre edge cases and complexity occasionally do creep in to even serious play and add a lot of interest, but the complexity is of the iceberg variety, where most of it rarely makes itself visible most of the time.
Choice-lock. If any player is unable to make a choice for some finite countable number of consecutive turns, they lose.
This could have also prevented combining infinite turn combos with the ante-related cards to produce "I have created a game state where I can take ownership all the cards in your deck, and then win," which was fun to do in the original M:tG PC game, even though running through the combo to actually take all of the cards was a bit tedious.
You'd just need to add additional construction that every N turns gives each player a choice but where that choice does not affect the behavior of the machine.
Being "equivalent to a TM" and being "equivalent to the Python compiler" mean the exact same thing. Pretty much every widely used model of computation is equivalent in computing power to Turing machines. The notable exceptions are all weaker than Turing machines, such as arithmetic circuits.
What is this input? Board size?
https://www.sciencedirect.com/science/article/pii/0022000083...
In reality, the number of possible moves is not constant and depends on the current position.
For instance there are many different card games, what's to say Magic is more complex than them?
Magic has been around since 1993, and releases new cards every year. There are currently > 15,000 unique cards in the game.
When playing, you don't know what the next card drawn will be. You also don't know what is in your opponents hand.
In poker for example, there is a very small pool of possible top decks and hands.
Search trees in Magic (especially "eternal" formats that allow you to pick cards from any expansion) would be too massive to compute.
These cards are not vanilla either (not just statpools) - they contain over 100 categorical effects and many of them have unique effects.
I'd guess at least 1000 have unique effects and interactions.
Add on to that the fact that magic is both a pro-active and re-active card game. In most card games (aka hearthstone for example) you cast cards on your turn. In Magic you can cast many cards "in response" e.g. counterspells. You can also just play some cards on opponents turn.
Beyond this the game is split into a number of phases and card timing by phase is very important. Sometimes you want to cast on end step vs combat - the same spell does the same thing but might be much lower risk depending on the phase.
Of course by now the title and even the submission link has completely changed (it was linked to an article before).
Chess is fully computable. Magic is not.
When I posted this, the thread linked to a sensationalist article. The link was later edited along with the title.
If sockets were given absurd timeouts and/or you could run MtG at much higher speeds, (and it was given a medium through which it could communicate), it would have no problem making a socket connection. It is only the practicality of the matter that becomes a barrier.
The halting problem is like the pigeonhole principle. Just because there is no general compression algorithm doesn't mean we don't use compression all day every day. We have solutions for many interesting subsets of the problem domain, and that's good enough.
We can also tell if a program will halt in no more than N clock cycles by providing the analysis with a budget. If the budget is exhausted then the program would keep running for an unknown duration longer than the limit. Possibly 1 cycle. For third party code, you could just refuse to run that code at all. There are some useful programs that would get rejected but there are many useful ones that would not. So implementing an "infinite loop detector" as a "really big loop detector" wouldn't be the dumbest thing to try, anymore than implementing video compression is.
The difference is that with data compression, you don't get random-looking inputs and would explain why text, voice, image domains are amenable to compression algorithms. In contrast, the state space of programs is exponential in the budget N and looks very random. The exponential explosion makes the analysis very inefficient relative to hardware ability. And then the random-looking state sequences are especially not very compressible. These characteristics are harder to leverage.
The pigeonhole principle works for lossless compression but I don't see the analog to Halt or Rice's theorem, etc.
Personal importance: something like mgtg and duplo train tracks, which isn’t intended to build a Turing computer, is used to build one, it’s challenging and a creative outlet of tech knowledge. My favorite example is red stone in Minecraft.
MTG has ways to return to a previously seen play state, technically allowing a game to continue infinitely, depending on your deck, of course.
By game theory they shouldn't; eventually a player will be able to end the game while ahead and should do so; but we're already disregarding the motivation of winning for MTG.
(An expansion introduces a rule that each round automatically advances one of the game-ending parameters, but says you can play either with or without that rule.)
In TM there is almost no re-using of cards. Once a card is played, it either is discarded (red), provides a one-time bonus (green) or provides passive/active effect (blue). Only blue cards could be considered as being re-usable, but even that is only as far as the actual passive/active effect goes (which is separate from the effect it may generate when entering the game). Compare it with MtG, where many cards provide effects which allow discarded cards to be returned to the game (ranging from simple "ressurect creature" effects to such that allow shuffling whole stack of discarded cards back into the deck).
Also there is no stack in TM. And gaming the stack to your advantage is one of the core mechanics of MtG. A card you played may have different effects depending on cards your enemy plays in response, and these may have their effects altered by the cards you play in response, etc.
When it comes to cards themselves, and their effect on gameplay, it blows netrunner away.
Just look how effect layers are constructed, or even a simple stack and priority itself, not to mention infinite loops.
I do agree that i had way more fun playing Netrunner, mostly because you cannot be mana screwed/flooded like in mtg - as you can spend action to get resources or cards.
"In this work, we solve this problem by reformulating the construction to exclusively use cards with mandatory effects."
So it's more a of a subset of MTG's rules. Still, there are commercial video games out beyond MTG and they've been out for some time. Why has the game theory field not kept up with them?
Why assume that it hasn't? The paper cites http://drops.dagstuhl.de/opus/volltexte/2018/8805/pdf/LIPIcs... which claims to "show the undecidability of whether a team has a forced win in a number of well known videogames including: Team Fortress 2, Super Smash Brothers: Brawl, and Mario Kart."
Unlike previous attempts, which used cards that leave some room for Player agenda, this new version doesn't.
- finite number of pieces (eg. cards)
- finite number of actions each round
- clear endgame criteria
is computionally solvable. What comes with randomness is stochasticity, but if that made game unsolvable what about poker (solved for limit heads-up) and even scrabble?
Probably it's kind of semantic problem. I'm not complexity nor game theory expert.
https://www.toothycat.net/~hologram/Turing/
If you then think about the sheer number of existing M:tG cards and the implied number of possible combinations of those cards and changes to the rules (even if "optimized" to combinations that eliminate obviously nonsensical strategies like only having spells that require green mana and no sources of green mana) and the ways those cards can interact, then the computational complexity of the game explodes in ways that no other game can compare to.
And that's not even what these people showed, I think. They showed that beyond this, the complexity is worse than NP-hard.
I am planning to update the toothycat.net site pretty soon with this new result, though.
Why are you making “strong” claims in a field you admittedly are not an expert in? This is not how polite nor useful conversations happen.
Naturally people have implemented Turing machines in mtg. www.toothycat.net/~hologram/Turing
Also, the endgame criteria of mgt can be changed, but that said there is only a finite number of simple possible endgames in a sense.
There are many combo wins that involve having (technically) infinite tokens, dealing infinite damage, gaining infinite life, taking infinite turns. You get the idea.
I said technically because in practice, setting this to a very large number is enough for the win. Dealing 1e6 damage is, although possible, already way overkill in most cases when your opponent starts with 20 life.
https://i.redd.it/wyn3d22evs011.jpg
This is not the worst I've seen, simply what I was able to turn-up on short notice.
EDIT: To clarify (the UI isn't great), what you see above is a selection of the "cards" (creatures/tokens) in play, more are off screen.
As you've rightly pointed out, a better UI isn't going to solve the UX issue of ridiculous game state; but it could better depict the state itself.
an infinite amount of pieces(there are cards that restore your library, generate infinite amount of mana/tokens)
infinite amount of actions each round, by each player too!
Endgame criteria which can be changed by cards themselves.
- doesn't let you repeat actions, or patterns of actions (move back and forth in a stalemate like pattern).
Detecting non-trivial stalemates is hard, though.
One other example of this is css. Did you know css is Turing complete?
Note that most programming languages are Turing complete because that is the domain: To express every possible computation in the language, and thus in these cases Turing completeness is not a design smell.
Let me rephrase more specifically: CSS3 + HTML5 is turing complete. Since CSS is always used in the context of HTML I left that out, but rigor is important!
source: https://stackoverflow.com/questions/2497146/is-css-turing-co...
Note that this happened with the later versions of CSS indicating that the specification became turing complete after years and years of tacking on features. This is the pattern of bloat accumulating over time.
There are probably many games that can somehow encode a halting problem if the board size is made arbitrarily large.
EDIT: This from the real abstract sounds very strange:
"Our result is also highly unusual in that all moves of both players are forced in the construction. This shows that even recognising who will win a game in which neither player has a non-trivial decision to make for the rest of the game is undecidable."
Your sentence "There are probably many games that can somehow encode a halting problem if the board size is made arbitrarily large" is actually key. You're completely right - there are many. What's unusual about our result here is that we found a way to embed a fully functional Turing machine inside not an arbitrary extension of a board game, but inside a board game exactly the way it's normally played.
> "Our result is also highly unusual in that all moves of both players are forced in the construction. This shows that even recognising who will win a game in which neither player has a non-trivial decision to make for the rest of the game is undecidable."
It's not so strange: the game is Turing complete, so the winner can be undecidable because who wins is the result of some arbitrarily complex computation.
Imagine we play a "game" where I win if there's a nontrivial zero of the Riemann zeta function with real part not equal to one half, otherwise you win. Neither of us has any decisions to make in this game. It's still very difficult to determine who's going to win.
The tape is represented by tokens whose strength increases with their distance from the read head, such that the current cell is the weakest one. On every loop iteration, it gets killed (read) and triggers different effects depending on its type, such as getting replaced (writing a new value), changing the effects that will be active on the next iteration (changing state) and dealing damage to one side of the tape but not the other (moving the read head).
I think what they do is set up a sequence of cards that 'initialises' the game state with various creatures and resources. These together with the game rules form the Turing machine. Then they have a sequence of cards that correspond to the 'paper tape' of symbols a Turing machine operates on.
restore your library,
grab cards from exile(out of game, literally),
Reverse win conditions,
Prevent losing,
Generate infinite loops - both deterministic and not(with randomness).
Create tokens(sometimes coupled with above) - which provide unlimited resources with a sac outlet.
And those aren't fringe cases - for example in EDH format quite a lot of decks win by creating some kind of infinite loop, or by generating infinite resources(or sky high amount of them)
So i would argue that resources aren't finite.
20k is the number of unique cards, but you can put as much as 4 copies of the same card in your deck for the vast majority of cards. You can also put as many "normal" lands as you wish in your deck.
Every card that either has the subtype "basic" or that has a card text that explicitly states so (for example: Relentless Rats), can be included in any number of copies. All other cards can be included at most 4 times or at most 1 time if it is a EDH/Commander deck.
There are 11 cards with subtype basic: https://scryfall.com/search?q=t%3Abasic&unique=cards&as=grid...
And 4 non-basic cards that can be included in any number: https://scryfall.com/search?q=o%3A%22A+deck+can+have+any+num...
I wonder if it's irrational?
No, you can recycle resources and there are cards that remove termination conditions of the game. For example Platinum Angel or Lich's Mastery.
Beyond that, those are not cards in the sense of poker cards with stats and an effect. Many of these have unique effects specific to that card.
There are also 100+ categorical effects. Creature types, color types.
Plus Magic is played on both players turns unlike other card games. Divide both turns into phases with pros and cons of casting.
It's more complex than it sounds when you just call it a "card game" - it is much more deep than most any other card game and does not truly feel like a card game except the fact that you play with cards.
The game has infinite loops, race conditions, etc which come in many unpredictable shapes.
>"Our result is also highly unusual in that all moves of both players are forced in the construction. This shows that even recognising who will win a game in which neither player has a non-trivial decision to make for the rest of the game is undecidable."
It is very straightforward. They are saying that, in the turing machine scenario they've set up, for each player's move, the decision they have to make is obvious, so the players don't have to collaborate in order to produce the scenario, it will arise naturally out of the state of the game with two rational players trying to win.