Taking on a Difficult Challenge
- Elijah Moore
- Feb 14, 2020
- 5 min read
When I first went to college I got an Associate's Degree in Computer Science, but after transferring as a Math major those skills were seldom used. I like counting really complicated things and I have been trying to build up my programming skills by incorporating intricate counting into project ideas. I have found a lot of inspiration from video games I play. The first time I really attempted to build up my coding skills since graduating I was inspired by a game called Auto Chess.
Auto chess is a video game where every round you draft game pieces and are randomly matched up against the other players. The pieces attack and move on their own the player is more of a team manager deciding which pieces to pick and where to place them. There is a large pool of pieces that all players are drafting from so if you want to know the likelihood of drafting a particular piece you need to look at everyone's pieces. It gets a fair bit more complicated as different pieces have different likelihood of appearing in your draft selection and this changes over the course of the game. I after a lot of time I came up with an explicit formula to calculate the likely hood of finding any given piece at any given time depending on the game state. The problem was that there is so much data to track.
Even though I had the formula I couldn't calculate it in real time to help me in the game. That's when I first thought of some sort of program that reads the game screen for the relevant data throws it all into the calculator and spits it out in real time. That project never really progressed beyond finding the explicit formula but it did get me to dip my toes back into coding. Learning bit by bit is incredibly important. There were a few coding project between this one and the next one that were never fully realized but I learnt plenty along the way.
The next game that really inspired me to do some sort of complicated counting was Legends of Runeterra. Legends of Runeterra is collectible card game like Magic the Gathering or Yu-Gi-Oh but set in the League of Legends universe. Card games naturally lend themselves to probabilistic calculations because they have decks of cards that are shuffled. Let's just look at a basic deck of 52 playing cards. Counting the number of unique shuffles of a deck of playing cards seems pretty simple and really its just a bunch of multiplication but the numbers get really big really quick. Lets just start from the top card down. There are 52 options for the first card. That leaves us with 51 other cards for the second then 50 choices for the third and so on until there is only 1 choice for the bottom card. When calculating consecutive decisions like this you just multiple the number of options for each choice so we get 52x51x50x...x3x2x1 a short hand way of writing this in math is 52! (read as : "52 factorial"). That does seem too difficult but the number we get is 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000 or about 80 unvigintillion(there are a few naming systems this may not be the only one) or 80 million quadrillion quadrillion quadrillion quadrillion. Here is a wonderful breakdown of just how big of a number that is.
Now let think of a game where you get to build your own deck with varying number of copies of cards. Then make that game a digital game so you can implement randomized systems for even more crazy complicated counting. There was a particular mechanic in Legends of Runeterra that I wanted to track and calculate. In Legends of Runeterra you win when your oppontent's health reaches zero. You and use cards to summon units to attack your opponent or uses spells to and abilities of units to damage them directly. Some cards have the ability to place poison mushrooms into your opponent's deck that attaches itself to a card and when said card is drawn they take 1 damage for each mushroom on it. Naturally I started to think well whats the likelihood that the opponent's next draw is card with enough mushrooms on it for their health to fall to zero. I then expanded the question question to the next 2 draws and 3 draws and so on. In math we call expanding a question like this generalizing. We take a specific detail like the opponent drawing 1 card and alter it to find a pattern that fits any number we choose. We take a specific detail and turn it to a more general quality.
I initially created this calculator in MatLab. But while the calculations were functional, I could not run my calculator in the background so It was useless to use in game. I did some research and it seemed easier to just remake the program in a new language. I had never used Python before but I decided to use this project to learn it. After successfully creating the calculator I tried using some software to read the screen and push the relevant data to the calculator. I had mixed success with this. The software wasn't reading the game's font correctly and I haven't found a solution for this problem yet. I know that if I really want to solve this problem I can learn about machine learning and build my own text reading software to recognize the game's font. That is a too big a project for me to take on right now, so I am taking a step back from the live reading of the data.
Going forward I am expanding the functionality of my calculator to tackle a more generic problem. I will be calculating the likelihood of drawing into a multi-piece combo in some number of turns. This has been a doozy of a combinatorics problem to solve. I think I have an explicit formula figured out but I don't have a rigorous proof so I'm not sure. There are two main tasks I have ahead for this project. I need to code up the calculator and I want to learn how to load deck codes into my calculator for ease of use.
Its been roughly 15 months since I first tried getting back into coding. It took a lot of time and a lot of unfulfilling projects before I really felt like I had succeeded. I look back and I have definitely learned a ton from each attempt I made. I really enjoy playing Legends of Runeterra and I am excited to see how far this coding project gets.
コメント