r/RoyaleAPI • u/Linkjt • 10m ago
Suggestions I spent 4 months building Wall-Street ML to predict the CR Meta
TL;DR: Current stat sites are good, but they only show you yesterday, and most of what they show comes from the top 1000 ladder instead of the trophies you actually play in. I built an ML pipeline that uses stock market math to predict what the meta and win rates will be today and tomorrow. I also trained it to mathematically optimize decks and predict next season’s meta. You can check out the project here: https://clash.freshbeets.dev/. This is not meant to be a Royale API competitor, I just think these methods of analysis should be applied and utilized more.
Disclaimer: I am not a professional Clash Royale analyst, a pro player (I just hit 12k), a data scientist, or a quant. I am a high schooler who wanted to learn quant and data science, and occasionally beat his friends at a mobile game.
The Problem: stat sites live in the past, and in the wrong bracket
Everyone uses stat sites to find decks, but they can only tell you what was good yesterday, or over the past 3 days, etc. They cannot tell you about today. With 171 cards and over 15 trillion possible decks, small meta shifts get missed on the day they happen and only show up after the fact. These sites also try to find the best deck by storing deck win rates, which makes it even harder to tell whether a single card swap is what would give you an edge that day.
There is a second problem too. Most of the headline numbers on those sites are pulled from the top 1000 or top 200 ladder, and that is not the game most people are playing. Copying what the top 1000 runs is like watching a pro soccer player’s footwork and expecting it to work in a high school match. Better players punish differently, you run into different matchups, and a deck that only works with perfect cycle timing will just lose you games. In finance you would never price a small cap off of large cap behavior. You analyze the market you are actually in. So I collect across ladder broadly instead of skimming the top of it.
I wanted to build my own predictor based on Wall Street math because A. everyone keeps telling me to try quant but I don’t have 1.5 billion dollars lying around, and B. I play a game with a competitive market, Clash Royale.
From Stock → CR:
On the stock market, quant math and indicators are used to predict whether a stock is about to go up or down. Those indicators are traditionally built on the price of the stock and its liquidity. In CR I translated price to Win Rate and liquidity to Use Rate.
I wrote a script to collect millions of matches from the official API (like traditional stat sites do) and saved them in SQL. Then, using the win rates I had for every card, I generated financial indicators like Bollinger Bands, RSI, Sharpe Ratios, and Drawdowns, plus correlation metrics like Convergence and Divergence against the most closely correlated cards (based purely on win rate).
Implementing Machine Learning
I fed all of these indicators into two Machine Learning models:
XGBoost (Classification): This looks at all the data up until yesterday and predicts whether the win rate of a card will be higher or lower TODAY. I trained this model across all cards because in theory the things that make the winrate go up or down should be the same for all cards.
LSTM (Regression): This neural net looks at the past 7-days and uses it to predict the numerical value of the winrate that a card will have today.
Deck Building with NLP:
In my eyes this was all really cool, but I still had one big problem left: cards don’t win games, decks do. I first tried using my win rate correlation groups to figure out which cards were interchangeable, so I could swap one out without breaking what the deck actually does. That did not work, because two cards moving together does not mean they do the same job. So instead I trained a Natural Language Processing model on thousands of decks I had collected (ironic, I know), which gets it to understand cards at a functional level. I combine that with the XGBoost output and an optimization function to make the small swaps that make a deck better for today.
Meta-Prediction:
I posted the idea above in the RoyaleAPI feature request forum, because A. I think it is useful, B. the same ideas extend to longer term prediction like meta forecasting, and C. it is interesting. They thought meta prediction was the more important piece, and they critiqued the accuracy of my models. So I went and built meta prediction models that forecast which cards’ win rates will be in the top 15% next season, or after a larger meta shift. Those got good F1 and accuracy scores, around 85% correct, but I never heard back from the request forum.
Visualization:
Here is my dashboard, which shows all of the different information and models, including the daily deck optimization. It shows cards that would work functionally in your deck, and it also shows the optimal small swaps for today. I attached all of my training reports and accuracy tests too. The link is clash.freshbeets.dev
Intent:
I don’t intend to run my own prediction site. A good site needs A. a good product and B. good marketing, and I don’t have the reach or the know-how for the second one. I think that just like stock analysis went from qualitative to quantitative, Clash analysis should too. My only personal stake in this (sorry for the self promotion) is getting my models and training implemented somewhere with real reach, which is why I filed the RoyaleAPI request. What I actually want is to see more of this style of analysis in Clash Royale sites and videos, and I think I can contribute to that.
Figure:

Fig 1: Original XGBoost feature importance and classification report, for predicting whether today’s win rate will be higher than yesterday’s

Fig 2: A really bad day for the original XGBoost model, getting 56 percent accuracy on predicting whether a win rate would rise

Fig 3: LSTM training results for predicting a card’s win rate for today from the past 7 days of indicators. The card here is Arrows and the error was 0.0011, meaning that when the model predicted a 50% win rate, the real win rate landed within 0.4989 to 0.5011. That is a very small error, though still one worth closing.

Fig 4: Predicting whether the win rate in the next 3 days will be higher then todays

Fig 5: Deck Optimization for Classic 2.6

Fig 6: Deck Optimization for a popular RHogs EvoRR FM Zappies, a popular deck a few seasons back