124 20 11MB
English Pages 196 [167] Year 2021
Probability and Programming to excel at Yu-Gi-Oh! Asiel Corpus Copyright © 2021 Asiel Corpus All rights reserved No part of this book may be reproduced, distributed or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without express written permission of the publisher, except in the case of brief quotations or references for non-commercial uses. Disclaimer Yu-Gi-Oh!, Yu-Gi-Oh! Trading Card Game, characters, names, cards and content related are trademarks owned by Kazuki Takahashi and Konami Holdings Corporation. Any trademarks, images of cards, names of cards, and names of sealed products are property of their respective companies and owners. This book is not authorized, endorsed, licensed, or sponsored in any way by Kazuki Takahashi or Konami Holdings Corporation. The content of this book is educational and informational. Although the content of this book is written to improve the performance of Yu-Gi-Oh! players at tournaments, there is no guarantee of this happening.
Table of contents Welcome duelist! What you WILL NOT find in this book
What you WILL find in this book Requirements to follow this book It’s time to duel! 1. Basic probabilities at the Dawn of Duel 1.1 Definition of probability 1.2 Basic probabilities in R 2. Follow the rules of probability 2.1 The intersection and union of events 2.2 Probability of a simple combo 2.3 Shuffling and drawing cards in R 3. Hypergeometric combos 3.1 Permutations 3.2 Combinations 3.3 Multivariate hypergeometric distribution 3.4 Permutations and combinations in R 4. Accelerate with the law of the large numbers 4.1 The law of the large numbers 4.2 Probabilities via simulations in R 5. Binomial eXperYmentZ 5.1 The binomial and cumulative probability 5.2 Binomial and cumulative probability in R 6. Swing pendulum! Draw the network diagram 6.1 Network diagrams 6.2 Network diagrams in R 7. Link your skills to the top of the duel 7.1 A complete and final code to test your strategy in R 8. The end of a journey and the beginning of another Bonus chapter. The big battle of the monsters
Appendix Installing R and RStudio Getting used to RStudio Customize RStudio Input your first command in the console Write your first script Data types Data structures Load, shuffle, and draw some cards The If – Else statement The For loop Custom functions Simple plots Install new packages and load libraries Acknowledgments About the author
Welcome duelist! To a journey into the use of Probability and Programming to excel at Yu-GiOh! It is a pleasure for me to share these pages with you. What you have at your service is not only a book, but also the result of a passion I have developed through more than 18 years as a Yu-Gi-Oh! duelist plus some scientific and technical knowledge acquired during my professional life. But no, this is not a book about the interesting, or rather, not so interesting details of my dueling story. Instead, this book is a carefully selected blend of probability theory and programming examples applied through the history of Yu-Gi-Oh! to advance your dueling skills to the next level. However, I warn you that you need a good amount of dedication to complete this book and to obtain its maximum benefit. This is because most of the chapters here presented require you to follow multiple calculations that involve the use of basic algebra. Also, you will need some time to implement
and understand the even greater amount of programming examples included. This may sound somewhat scary depending on your math and programming skills. But fear not! I bet that most Yu-Gi-Oh! duelists are naturally attracted to logical and thought provoking activities, and that they are already good enough to follow the math in this book. Also, Yu-Gi-Oh! duelists are unconsciously trained into programming logic. This training happens as they conduct their turn in an ordered way from Draw Phase to End Phase, when they methodically resolve a chain with multiple links, and when they carefully read the text of a new card. Therefore, I ask you, are you a duelist? Are you willing to make the effort? If both answers are positive, the successful completion of this book will earn you an amazing weapon to accelerate the testing process and evaluation of any Yu-Gi-Oh! strategy. This way, you will see a huge improvement in your deck building skills that will allow you to reach the top tables more consistently. Now that your mind is set, let me give you more details about this book.
What you WILL NOT find in this book ● A detailed guide about how to play Yu-Gi-Oh! You surely know that already, have an instruction manual with you, or can easily find a free tutorial online. ● Lists of “the top cards of all time” which will get outdated a few months later. ● Comments on specific cards to play or what decks to play. You are the one who decides. Instead, you will develop skills and tools to take smarter decisions the next time you build a deck. ● Nonsense recommendations such as, “trust your gut” or “follow your instincts”.
What you WILL find in this book Most chapters in this book follow a triple approach which includes: 1. An introduction that describes the state of the competitive game over a certain period of time. These sections include multiple mentions to outstanding cards, archetypes and strategies. The totality of the book covers the history of Yu-Gi-Oh! from year 2002 until the end of 2019. This helps the younger readers to understand the evolution of the game through time. 2. A math section with probability theory applied to situations described in each introductory section. As a result, the theory explained gets more
detailed as the history of the game develops from chapter to chapter. All theory is immediately applied to Yu-Gi-Oh! 3. A programming section ready to implement the probability theory in the R programming language and RStudio development environment. Every example is complete and fully detailed. Here is more information about what you can expect in every single chapter. Here is more information about what you can expect in every single chapter. Chapter 1: Basic probabilities at the Dawn of Duel The first chapter describes the early stage of the game on 2002. This is convenient to explain the most basic concepts of probability as well as the most basic commands in R. Chapter 2: Follow the rules of probability This chapter describes the popular Magical Scientist + Catapult Turtle combo used on 2003 to win a duel in the first turn. Then, it introduces the rules of probability to evaluate how likely you are to get a combo. Chapter 3: Hypergeometric combos The history of Yu-Gi-Oh! continues from 2004 until the end of 2006. This includes the reign of Chaos, the popular Goat Format, and the increased use of One Turn Kill combos. Here, you will learn the multivariate hypergeometric distribution to calculate the probability of getting more complex combos. I guarantee you that this chapter alone is already good enough to give you an edge over most duelists. Chapter 4: Accelerate with the law of the large numbers There is no better moment to accelerate your programming skills than with the introduction of Synchro Monsters! This chapter will teach you to simulate thousands of sample hands within a matter of seconds. Then, you will use the concept of experimental probability to find out how likely you are to get a popular Blackwing combo. Chapter 5: Binomial eXperYmentZ Chapter 5 continues with the introduction of Xyz Monsters and the binomial probability to find out how reliable is your strategy over the course of a tournament. Here, you will use the Tempest Dragunity strategy to test for not 1, but 63 combos at the same time. At this point, you will be far ahead from other duelists. Chapter 6: Swing pendulum! Draw the network diagram As Pendulum Monsters, this chapter does things its own way. Here, you
will expand the default capabilities of R to create wonderful visualizations of the interactions available in a Zefra Yang Zing deck. Furthermore, this chapter could as well guide you to develop a new way to build a deck. Chapter 7: Link your skills to the top of the duel This is where your technical training in the use of Probability and Programming to excel at Yu-Gi-Oh! comes to an end. In this chapter, you will use all your acquired skills to test the Crusadia Guardragon strategy against possible disruptions hidden in the hand of your opponent. Chapter 8: The end of a journey and the beginning of another Our journey together concludes in this chapter. Then, you will start your own. This time, however, you will be armed with more dueling skills. Bonus chapter! The big battle of the monsters Just for fun, what do you think would happen if all the monsters of the game join in a massive battle? Appendix This section is a quick guide to get you familiar with the R programming language and RStudio. The appendix also includes short descriptions of the most common functions used in this book. You can consult it at any time as you read this book.
Requirements to follow this book Just your commitment to work, basic algebra to follow the math, and a computer to program in R. I have put a great effort to provide you with complete and clear examples so you can understand and implement code even if you have 0 experience with R or any other programming language. There is also a good amount of illustrations and tables to facilitate your reading experience. Finally, there are code snippets that show you the input command on top and its respective output at the bottom as shown below.
Optionally, you can use the official Yu-Gi-Oh! Trading Card Game – Card Database available at https://www.db.yugioh-card.com/yugiohdb/ to consult all the details about every single card mentioned in this book.
It’s time to duel! All I am left to say now is, good luck and have fun! I hope you enjoy
Probability and Programming to excel at Yu-Gi-Oh! as much as I did writing it.
1. Basic probabilities at the Dawn of Duel Long time ago, when the pyramids were still young, the Egyptian Kings used to play a game of great and terrible power… Get excited because this is where our quest begins! The simplicity of the rules of Yu-Gi-Oh! in its early days is the best place to learn and apply the basic concepts of probability as well as the basic use of R.
March 2002, a legendary dragon took flight across North America. O nImmediately, it was recognized as a powerful engine of destruction. Virtually invincible, the awesome creature faced a multitude of challengers and very few of them lived to tell the tale. Well, that is probably not the way things happened, but it is a nice way to say that the release of Legend of Blue Eyes White Dragon marked the beginning of the Yu-Gi-Oh! Trading Card Game (TCG). I like to refer to this moment in the history of Yu-Gi-Oh! as the Dawn of Duel. This, due to the simple game mechanics and small card pool available back then. In fact, young players would be surprised to find that Skull Red Bird, a Level 4 Normal Monster with 1550 ATK, used to be the most powerful being a duelist could summon without paying a Tribute. Anyway, I bet most players don’t remember Skull Red Bird, but they probably remember a mightier Level 4 monster released just a few weeks later in Starter Deck Kaiba. This is, of course, La Jinn the Mystical Genie of the Lamp, whose presence on the field was overwhelming with 1800 ATK. At the same time, Starter Deck Yugi introduced the impressive Summoned Skull, a Level 6 Fiend who set the benchmark of 1 – Tribute monsters due to its exceptional 2500 ATK. Only few 2 – Tribute monsters were capable to defeat the fiend in battle, therefore, some duelists accepted Summoned Skull as the game – defining monster. However, most duelists during the Dawn of Duel used to play with the cards at their disposal rather than with a strategy carefully selected to increase their chance to win. This was probably a consequence of the novelty of the game, the young community of players, the lack of official tournaments, and the absence of a convenient communication channel such as YouTube or social media. Sure, nobody denied the advantage of cards such as Monster Reborn, Change of Heart, Dark Hole, Fissure, Trap Hole, and few others, but there was hardly any discussion about the optimal cards or the ideal Monster – Magic – Trap ratio to use. Now, you may be surprised to read about Magic cards. Believe it or not, that was the original name of Spell cards. The change in the term occurred about one year later to avoid potential confusion and legal trouble with Magic: The Gathering, another popular card game. Anyway, going back to deck building during the Dawn of Duel, no one really applied mathematics to develop game strategies. There was probably no need to do it. Cards had close to none interaction between them. Also, the most powerful cards were powerful enough by themselves, therefore, duelists had no hesitation to include them in their deck. There was not much deck
building involved to be honest. This situation became more notorious with the release of cards such as Delinquent Duo, Confiscation, The Forceful Sentry, Snatch Steal, and the overwhelming Jinzo. Fortunately, we can take advantage of the simplicity of the early game to introduce and learn the basic concepts of probability needed to understand more advanced stuff later in this book. So, grab a deck of Yu-Gi-Oh! cards and follow me in the next examples.
1.1 Definition of probability Given the random nature of the game, we cannot expect to get the right cards to win all of the time. Instead, we rely on probability, which is, a numerical value that represents the chance or possibility of an event happening. And, what is an event? you may ask. Well, that is up to you to define. It could be getting your single Pot of Greed when you draw 1 random card from your 40 – card deck, it could be Time Wizard flipping a coin in your favor, or it could be rolling a 5 or 6 with Skull Dice. In any case, the probability of the event happening is denoted as P(E), and it is expressed with a number between 0 and 1, or in terms of percentage from 0 to 100 %. This is calculated as the quotient of the number of outcomes for the event and the total number of outcomes, as shown in Eq. 1.1.
It is also possible to calculate the probability of the complementary event, P(E’), as shown in Eq. 1.2. This represents the probability of the event E not happening.
As an example, Figure 1.1 shows a visualization of the different outcomes related to the three events previously mentioned. In event a), you draw 1 random card from a 40 – card deck that includes a single Pot of Greed. This means that there is only 1 outcome among a total of 40 to draw Pot of Greed. Therefore, P(E) = 1/40 = 0.025, or 2.5%. In practical terms, you may expect to draw the card 2 or 3 times for every 100 times you repeat
the experiment. In event b), you have the mythical Time Wizard, which allows you to flip a coin once per turn. If you call it right, your opponent is in trouble, but if you call it wrong, then you are in deep trouble. Thus, there are a total of 2 outcomes, which are, right or wrong. However, only 1 of them is in your favor, therefore, P(E) = 1/2 = 0.5 or 50%. Do you think you would accept the risk of flipping the coin? Finally, in event c), Skull Dice allows you to roll a six-sided die and make the opponent monsters lose ATK and DEF equal to 100 times the result rolled. If for some reason you need the monsters to lose at least 500 ATK and DEF, then you can have 2 possible outcomes in your favor from a total of 6. As a result, P(E) = 2/6 ≈ 0.333.
Figure 1.1 Calculation of P(E) and P(E’) for 3 different events.
For all cases, the probability of the complementary event can be calculated as P(E’) = 1 - P(E). These values are 0.975, 0.5, and 0.667 for the 3 events respectively. Alternatively, you can also calculate P(E’) with the number of outcomes that do not fulfill the event as 39/40 = 0.975, 1/2 = 0.5, and 4/6 ≈ 0.667.
1.2 Basic probabilities in R Maybe the calculation of basic probabilities is… well, too basic for you, however, I guarantee you that things will get more advanced soon. For this reason, it is convenient to learn to use new tools in order to facilitate our calculations. The tool I like is R, an open source programming language popular for its use in statistical analysis, data cleaning, data visualization, and machine learning, but in this book, we are going to use it for Yu-gi-oh! Do not worry if you are not experienced in programming, all you need is covered in this book. Alternatively, if you are experienced in programming, you can try to replicate the examples shown here in your favorite programming language. So, start your trip by downloading and installing R from https://www.r-project.org/ as well as RStudio from https://rstudio.com/. Then, follow me in the next examples. Also, make sure to check the Appendix at the end of this book to get more familiar with R and RStudio. First, let us start with the console panel at the bottom-left corner of RStudio. Just type 1/40 and press the Enter key to do a simple division. Immediately after, you will see 0.025 as the answer. Then, make sure to try some basic operations with the symbols you are already familiar (+, -, *, /). You can also try exponentiation and square root, for example, 3^2 = 9, and sqrt(9)= 3, respectively.
Now, try the factorial of a positive integer, n. This is the product of all positive integers less than and equal to n, as expressed in Eq. 1.3. For example, type factorial(5) to evaluate 5! = (5)(4)(3)(2)(1) = 120.
Then, assign numeric values to variables. In the example below, the
number 2 is saved in the variable, Numerator, with Numerator