Architecting Yu-Gi-Oh!

Peter Bestoso
16 min readDec 28, 2020

The dubbed Yu-Gi-Oh! Anime from the early 2000s is literally everyone’s favorite TV show. Perhaps, while enjoying one of the many fantastic episodes, you’ve asked yourself: “What is the high-level system architecture for the computer systems powering competitive Duel Monsters?” Wonder no more, gentle reader — we’re going to crack into that question now:

Three kinds of Duel Monster cards. From left to right: a Magic Card, a Monster, and a Trap (Season 1, Episode 3)

The Basics

In the show, Duel Monsters is a collectible card game published by a company called Industrial Illusions. Although the game can be played ‘analog’ with just two decks of cards, almost all of the matches we see throughout the series take place in Duel Arenas that render the game’s monsters and spells as looming holograms. In this article, we will not be examining how the holograms work because I have no clue how holograms work.

Two children play Duel Monsters on a wooden table; it is not visually interesting (Season 1, Episode 18)

Besides depicting the monsters graphically, the Duel Arena also maintains the game state and keeps track of most rules and card effects. For example, player Life Point totals are always kept up-to-date and displayed by the Duel Arena.

A Duel Arena projects holographic monsters and displays current Life Point totals. By this arena’s design, there is almost nowhere a spectator can stand for a clear view of both players’ scores (Season 1, Episode 32)

Some gameplay tasks, such as shuffling or searching through a deck for a particular card, are not handled by the Duel Arena. Instead, players execute these tasks manually just as they would while playing the analog version of the game. Cards appear to be ‘read’ and registered only when players lay them on console areas at either end of the arena.

Closeup of the player area. Printed cards are placed on cells representing legal card positions, with the opponent’s side of the field shown via video feed. In this shot, the opponent has apparently placed their monster card upside-down by mistake (Season 1, Episode 4)

Cheating

This paradigm is further indicated by certain cheating tactics employed by series antagonists. For example, characters sometimes covertly introduce outside cards from concealed hiding places, swapping them for cards legally drawn from their decks.

If the Duel Arena were scanning a player’s entire deck at the start of each game or tracking the cards in a player’s hand, these illicit maneuvers would not be possible. We conclude that the game state as known to the Duel Arena must include only those cards in play, and that the arena must be able to read newly played cards ‘on the fly’.

A cheating player draws a hidden card by sleight of hand. The Duel Arena does not detect the illegal play (Season 1, Episode 32)

In at least one instance, a character sends signals to a Duel Arena from outside the game to change the attack power of a monster. Although this specific functionality is probably only intended for use during hardware development and testing, its existence confirms that Duel Arenas are connected to the internet or another network during play.

A monster’s attack strength is reduced in response to admin commands issued remotely. This outside intervention also causes graphical glitches, suggesting it is not business-as-usual (Season 1, Episode 10)

Duel Disks (An Aside)

Later in the series, players eschew fixed Duel Arenas in favor of portable “Duel Disks”. For this document, we assume that while two Duel Disks split the task of rendering the game graphically, only one Duel Disk is elected at the start of a duel to track the game state and communicate with any online services. As a result, a pair of linked Duel Disks form a single system that, for our purposes, is interchangeable with a Duel Arena.

Instead of playing his cards at a Duel Arena console, this player lays them on his carried Duel Disk. A pouting spectator, behind, also wears a Duel Disk but is not participating in this duel (Season 2, Episode 9)

A Joint Venture

Crucially, the Duel Monsters collectible card game and the Duel Arenas where tournament matches take place are developed by separate entities. While Industrial Illusions prints the cards, another company, Kaiba Corp, manufactures and operates the Duel Arenas. Although the two entities work in close partnership with one another, there is ample evidence that each company has its own confidential processes and infrastructure.

The respective owners of Kaiba Corp and Industrial Illusions meet for tense contract negotiations (Season 1, Episode 22)

Secret Cards

Occasionally, characters shake up duels by playing never-before-seen cards produced by Industrial Illusions. Despite being hitherto unknown, these cards are fully compatible with Kaiba Corp hardware, with new rules enacted correctly and monsters rendered in a way that matches the card’s printed illustration. In at least one case, it is explicitly stated that certain playable cards are novel to the entirety of the Kaiba Corp staff, including CEO Seto Kaiba.

While it is possible that these cards were secretly coded into Kaiba Corp systems by engineers under strictest NDA, we instead assume that these systems truly do not ‘know’ every card, and that some amount of card and game information lives on the Industrial Illusions side of the fence without replication on the Kaiba Corp side.

Industrial Illusions CEO Maximillian Pegasus plays Toon World, a spell deemed too powerful for general release. Even so, the Duel Arena seamlessly handles the novel card (Season 1, Episode 27)

Proposed Architecture #1

The above description suggests a frontend-backend model, with Kaiba Corp owning the display hardware and rendering logic ‘frontend’, while Industrial Illusions entirely owns the card data and gameplay logic ‘backend’.

Under this model, Industrial Illusions prints every card with a unique id and preserves a mapping from each of these UUIDs to the card it represents. When a card is played, the Duel Arena reads the card id and reports it to Kaiba Corp, which passes it to an Industrial Illusions API along with the current game state.

An Industrial Illusions ‘Game Service’ communicates with a ‘Card Service’ to look up the card by its unique id, determines what effect the card should have on the game, then responds to Kaiba Corp with an updated game state.

Software running on powerful Kaiba Corp servers considers the current and new game states and procedurally interpolates an animated transition between the two. Instructions for these animations are passed to the Duel Arena, which displays them to players and spectators as holograms.

The Silver Bow and Arrow card increases the attack points of a monster already in play and changes the way the creature is rendered and animated (Season 1, Episode 25)

Similarly, when players give non-card inputs, such as when they order a monster that is already in play to attack, these commands are passed through to the Game Service along with the current game state. The rest of the flow follows the same pattern as before, minus any need to look up card UUIDs.

The ownership boundaries of this system design suggest distrust between corporate partners. In particular, it is surprising that Industrial Illusions would want to protect its card rules from Kaiba Corp to this degree.

We might see this design in a world where Kaiba Corp has lots of proprietary tech for rendering holograms and generating animations that it hesitates to license out, while Industrial Illusions takes extreme measures to keep its complete game rules and library of available cards from leaking to the public. This dynamic actually checks out pretty well with the way the companies are depicted in the show.

Our biggest concerns here — especially in later seasons, where players with wireless Duel Disks can start a game of Duel Monsters just about anywhere — are lag and connectivity issues. Under our proposed design, you could expect that, after playing a card, competitors may sometimes stand around waiting for a few seconds before their move starts playing out in fully rendered hologrammatic majesty.

I don’t really have an answer why we never see this; maybe Battle City has 5G.

A satellite linking Duel Arenas to the Industrial Illusions mainframe is photographed moments before its final flight (Season 1, Episode 9)

There’s also room to bicker about where the game state should be stored, but given that we see Kaiba Corp analyzing Big Duel Data, it seems like at least a copy of any game state information would live on their infrastructure. Under the proposed model, a duel-in-progress can also be easily ‘transferred’ to a new Duel Arena by Kaiba Corp in case of hardware failure without having to go through Industrial Illusions, which seems like a plus.

So hey, we did it, right? There’s no way a couple of Additional Complications could blow up our design, right?

A stripey, card-playing magician prepares to ruin this whole great thing we put together (Season 2, Episode 12)

Offline Mode

In Season 2, series protagonist Yugi Muto engages in a game of Duel Monsters without connecting to Kaiba Corp’s servers. It’s a whole plot point, but the details are kind of fuzzy.

In summary, Seto Kaiba tells us that Yugi’s Duel Disk “won’t operate unless it has a connection to Kaiba Corporation’s Tournament Computer or another compatible system” and concludes that Yugi must be somewhere “that has its own internal computer dueling system.” Under the design we proposed above, that’s tricky to acheive but not unthinkable.

Kaiba Corp CEO Seto Kaiba examines a wireframe dragon displayed on his computer. The image is helpfully mirrored to several larger screens above and behind him (Season 1, Episode 10)

Someone with stolen Kaiba Corp software and credentials could be running their own instance of the ‘Game Rendering Service’ that communicates with the Industrial Illusions ‘Game Service’ as normal.

If that were the case, the natural next step would be for Kaiba to hop on the phone with someone from Industrial Illusions to rotate their credentials and/or to try to get Industrial Illusions to identify and block the rogue ‘Game Rendering Service’ instance. Instead, he searches the city for compatible computer systems (somehow >.>) without any mention of Industrial Illusions whatsoever.

Baffled but determined, Seto Kaiba stands beside his brother in a room we know is for computers because it is white and shiny (Season 2, Episode 12)

Counterfeiting

Under our proposed model, cards can be easily ‘duplicated’ by printing up a copy with the same unique id. As long as the same card id does not appear more than once in the same duel, or perhaps as long as it’s not played multiple times in concurrent duels, this technique should be pretty much foolproof.

However, we only encounter one instance of counterfeiting in the show. In a hugely popular card game with a lot of powerful, ultra-rare cards, it seems like the practice would be widespread.

Because it isn’t, we conclude that forging cards that a Duel Arena would recognize as valid is nearly impossible. Perhaps the unique card ids are printed with some kind of Proprietary Ink, a real-world innovation that sounds cool until you find out what it’s used for.

While this theory seems promising, it doesn’t explain why the process for creating a counterfeit card is depicted as not just difficult, but also iterative. In Season 2, when the primary antagonist produces a phony Egyptian God Card, we see in a flashback that many attempts were needed to get it right.

Failed counterfeits of the Winged Dragon of Ra snake away into a cloudy purple abyss (Season 2, Episode 39)

Oh My God They’re Reading The Rules Straight From The Cards

Yu-Gi-Oh devotees probably saw this coming. The series is riddled with throwaway references suggesting that the cards themselves contain all of information a Duel Arena needs to include them in a game.

With this in mind, we ditch the frontend/backend model from before and instead view Kaiba Corp as a hardware and operating system developer, while Industrial Illusions writes third-party software designed to run on Kaiba Corp machines. As real-world analogs, we can compare Kaiba Corp to Nintendo and Industrial Illusions to a company like Capcom, but instead of disks or cartridges, Industrial Illusions software is delivered on playing cards.

A young man holds three ‘Dungeon Dice’ between his fingers. Like Duel Monsters cards, these dice apparently act as read-only memory (Season 1, Episode 47)

Supposing game rule ‘code’ is being read directly from the cards and executed by the Duel Arena, the complications we explored above can be simply resolved:

Secret Cards can exist because the software backing a Duel Arena does not need to be previously aware of a card to read game rules from it.

Because characters on the show are routinely surprised by the ways their cards behave, we can further assume that the complete list of card rules and special interactions are encoded on each card in a non-human-readable format. Thus, a card in circulation can reference a Secret Card in its Encoded Rules without giving away that card’s existence in its Written Rules.

Instead of being weakened by The Time Wizard’s signature effect, The Dark Magician is transformed into The Dark Sage. This interaction may come as a surprise, since neither The Time Wizard nor The Dark Magician indicate it in their Written Rules (Season 1, Episode 34)

Offline Mode also becomes straightforward as the game state is maintained and transitioned entirely by the Duel Arena. That said, we have to bend over backward a little to make sense of the Seto Kaiba quotes cited above.

We might assume that when Kaiba says a Duel Disk needs to be connected to Kaiba Corp servers to operate, he’s suggesting the hardware won’t boot up unless it gets some kind of ‘heartbeat’ signal back from Kaiba Corp to confirm there is a good connection available. Kaiba Corp’s servers aren’t facilitating any of the gameplay logic, but they require players to be ‘always online’ for the sake of analytics collection or as DRM.

Less cynically, we can point out that characters in the show sometimes ‘watch’ duels live over the internet. Instead of a video feed, these games are presented in a format that reflects the player area as it might appear to someone standing at a Duel Arena console.

To support this feature, Duel Arenas must be sending their game state to Kaiba Corp after each move. In response, the Kaiba Corp servers are probably sending back an ‘OK’ signal to confirm each update to the game state has been received.

A website or desktop client displays the current game state of an active duel in a boiled-down format (Season 2, Episode 9)

In the aforementioned episode where Yugi duels off-the-grid, we’re shown a ‘hacked’ computer that appears to be a crummy desktop. With stolen credentials, the heartbeat and ‘OK’ signals described above could likely be simulated even on just such an underpowered machine.

The Duel Disks are duped into pinging this computer, ‘thinking’ they’re connecting to Kaiba Corp. After receiving a believable pong response, they freely proceed to execute gameplay and rendering logic locally. Every time they upload a new game state for live-streaming, the ‘hacked’ computer simply ignores that information and trivially responds with an ‘OK’.

“””Kaiba Corporation’s Tournament Computer or another compatible system””” (Season 2, Episode 11)

But, if Duel Arenas are reading and executing arbitrary code from cards, why don’t we ever see Made Up Cards? Notably, none of the villains ever try to win a duel by busting out The Instant Victory Ninja That Is Definitely Real.

Although hardware companies have historically employed all kinds of janky methods to prevent unauthorized software from running on their machines, the absence of Made Up Cards most likely indicates official Duel Monsters cards are cryptographically signed by Industrial Illusions with a private key.

Using a public key, the Duel Arena can verify any card as legitimate based on its Encoded Rules plus its Signature, which, for the sake of this exercise, let’s say is printed in our super secret Proprietary Ink from before.

A robot specifically designed to play card games fulfills its purpose with mechanical dispassion (Season 2, Episode 5)

Counterfeit Cards, then, may be devised through a Birthday Attack.

For instance, suppose a counterfeiter wishes to copy The Winged Dragon of Ra and knows the hash function used when signing cards, but does not know the Industrial Illusions private key (that key would certainly be a mega-guarded secret under this scheme). To begin, the counterfeiter assembles a list of the Hashes of all known Duel Monster cards, plus their Signatures.

From there, they generate a massive number of alternate versions of The Winged Dragon of Ra with Encoded Rules that have very minor differences. For each of these versions, they hash the Encoded Rules and check if the resulting Hash matches the Hash of a known card.

If they can find any match, the counterfeiter prints up their Fake Card, then uses glue to apply a Proprietary Ink Signature cut from a copy of the Legitimate Card With A Matching Hash to create a Fake Card that plays like an Egyptian God on Kaiba Corp hardware.

Although the genuine Egyptian God Cards are hand-painted, their sworn protector puts her thumb right on the card art when handling one (Season 2, Episode 3)

In the real world, using parts of authentic common trading cards to create fake versions of more valuable ones is not unheard of. For instance, counterfeit Magic the Gathering cards are sometimes produced by applying a fake card front to a real card backing.

At this point, the reader may wonder: “If Industrial Illusions has unfakeable Proprietary Ink, why wouldn’t they use that to print all of the Encoded Card Rules, or even the entire card?” That would obviously be a more secure design, but maybe the Proprietary Ink here is expensive to make and must be used sparingly.

Remember that per our Plot Requirements, it must be barely feasible to create inexact copies of a one-of-a-kind rare card, with a process apparently focused on R&D rather than manufacture.

It’s also notable that our counterfeiters only copy one of the Egyptian God Cards, even though their organization possesses two. This suggests that their forgery method ‘cracks’ particular cards without compromising the entire game of Duel Monsters.

A bonafide Egyptian God Card is forked over to the winner of a duel in which it was wagered. Although the previous owner has successfully created forgeries of another God Card, they either did not bother or were not able to copy this one (Season 2, Episode 18)

But, this theory has another problem. The number of Real Card Hashes known to the counterfeiters can not be greater than the total number of different cards in Duel Monsters. Even if we generously estimate that quantity to be somewhere in the ten thousands, it’s not high enough to make a Birthday Attack viable.

As an alternative, maybe the forgers have a stooge planted on Industrial Illusions’ Card Development Team, but do not have direct access to the card signing hardware or to the private signing key. When the company tasks this stooge with inventing a new common card — for our purposes let’s call this card The Charming Woodsman — the stooge generates a vast quantity of minor variations on that card by the same method used to generate variations of The Winged Dragon of Ra.

If the counterfeiters can find a match between the Hash of any version of The Charming Woodsman and any version of The Winged Dragon of Ra, they send that version of The Charming Woodsman off to be signed and printed, then privately print up the corresponding Egyptian God.

From there, legitimizing their counterfeit God Card is as simple as acquiring a real copy of The Charming Woodsman, then harvesting its printed Signature and layering it on their Fake Card as previously described.

A cloaked man hesitates to play with phony cards (Season 2, Episode 39)

Proposed Architecture #2

Factoring in all of these considerations, we devise a new system design with fewer moving parts. Tasks that were previously handled by services running on Kaiba Corp and Industrial Illusion servers have almost all been made local.

Cards now act as read-only storage devices containing their individual rules, with broader game rules stored on and enforced by the Duel Arena. The Duel Arena also keeps track of the current game state and animates all holographic monster interactions. Duel Arenas connect to Kaiba Corp only to authenticate themselves before starting a duel and to push updates to their game state for live streaming.

This system design burdens the Duel Arena with most tasks, which is surprising since they are ‘always online’. It is also odd that Kaiba Corp’s hardware exclusively runs ‘card software’ signed by an entity they don’t control.

While this new design accounts for a greater number of series plot points, it introduces some major drawbacks.

Seto Kaiba monitors analytics data collected from a duel in progress on a screen that wouldn’t need to be so big if his desk was closer (Season 2, Episode 8)

Hot Fixes

It is extremely unusual that Kaiba Corp allows Industrial Illusions to sign software designed to run on Kaiba Corp Duel Arenas. In the paradigm proposed here, Industrial Illusions must be trusted not to release cards that break hardware, are vulgar or otherwise objectionable, or which present a health hazard to players. If they do any of these things on purpose or by accident, Kaiba Corp must scramble to explicitly block the offending cards from running on their machines.

In the real world, we would expect Industrial Illusions to submit all new cards to Kaiba Corp for quality assurance ahead of their general release. Assuming they pass whatever certification process is put in place, Kaiba Corp — not Industrial Illusions — would then sign the cards and provide the Signature to Industrial Illusions for printing.

To make things more complicated, because all Encoded Rules are printed on the cards, there’s no easy way to ‘patch’ a card after release. This is actually a problem for collectible card games in the real world, where errors and misbalanced cards are typically ‘fixed’ by publishing official errata or reprints, banning overpowered cards, or introducing new cards that make underpowered ones more competitive through synergy.

Yugi Muto summons the Catapult Turtle. In the real world, this card was too strong as printed, and its rules were later updated by published errata. Players who own this monster card may not realize it has been patched unless they proactively check (Season 1, Episode 15)

Under Proposed Architecture #2, any updates to card rules must reside on Kaiba Corp’s hardware. We can imagine that when a broken card is released and needs urgent fixing, Industrial Illusions provides an amended version of the Encoded Rules to Kaiba Corp. In turn, Kaiba Corp sends a software update out to all of their machines.

Whenever a patched card is played during a game of Duel Monsters, the Encoded Rules on the card are discarded in favor of the patched rules stored on the Duel Arena.

Besides being kind of a mess, this scheme raises the question: if Kaiba Corp is storing Encoded Rules for patched cards on their Duel Arenas, why not store all card rules by the same mechanism? Why bother printing software on cards at all?

In the last decade or so, similar questions have been asked about the real-world video game industry, which has been known to sell physical disks that require massive downloaded patches even on the first day a game is released.

A video game avatar resembling Seto Kaiba traipses along a straight road (Season 1, Episode 43)

Pursuing this line of questioning we’re likely to end up re-working our system to look much more like Proposed Architecture #1. Under that scheme, Industrial Illusions can patch a card at any time by deploying changes to their ‘Game Service’.

For major changes, they will probably want to sync up with their partners at Kaiba Corp to make sure all affected animations still work, but for minor tweaks (“We’ve decided to raise Bolt Penguin’s defense power from 800 to 850 points”) this probably isn’t necessary.

An anthropomorphic penguin plays Bolt Penguin in defense mode. A 50-point buff to this card’s defense points would probably not be enough to make it viable for tournament play (Season 3, Episode 6)

Solemn Judgement
All in all, both of our proposed architectures have massive quirks, but each is only a few modifications away from becoming a believable, real-world system.

Proposed Architecture #1 starts to look more realistic if we move the Game Service to be owned by Kaiba Corp. In that scenario, Industrial Illusions recognizes that an augmented reality version of Duel Monsters is valuable, but does not have the expertise or technology to develop such a version in-house. Instead, they license the rights for digital versions of their physical strategy games out to other companies. Kaiba Corp’s ‘game logic in the cloud’ setup is ideal for deploying frequent balance updates that facilitate competitive play.

Meanwhile, Proposed Architecture #2 can be largely fixed by putting Kaiba Corp in charge of card certification and signing. In that case, Industrial Illusions should read their contracts with Kaiba Corp carefully, as it seems like the hardware company is positioning itself to support off-brand Duel Monster cards produced by Industrial Illusions competitors.

Maximillian Pegasus signals his wealth and isolation by sitting alone at a long table (Season 1, Episode 24)

Readers are encouraged to select one or the other architecture as their preferred head-canon. Personally, this author finds Proposed Architecture #1 to be the more palatable of the two in general although the details of card counterfeiting throw a major wrench in it.

As a remedy, let us suppose that this and any other inconsistencies arising from our theorized models can be attributed to the inscrutable workings of Ancient Pharaoh Magic.

— Happy Dueling!

Duelist Kingdom Champion and ‘King of Games’ Yugi Muto blinks in a frame of animation I discoved by accident but which I will love forever (Season 1, Episode 10)

--

--