Follow our Instagram!
Curious about what we're currently doing about bots? Check out the latest updates from staff in this thread.
Welcome to Smogon! Take a moment to read the Introduction to Smogon for a run-down on everything Smogon, and make sure you take some time to read the global rules.

Battle Bot Jaxcalibur: A Gen 9 Randbats bot that reached #1 on the ladder

The idea of hanging this boy over people’s heads to force change seems like a good idea imo. Most people don’t want it released but want some kind of change. And this can force that. As well this lets those who want to just look at the code, cause it is actually super cool and not just a terrifying robot, can actually look at it.
Im curious, do you think it would be possible to use a AI like this to create an evaluation bar for pokemon showdown like there is in chess? That would be super cool
Kowasabii said:
Im curious, do you think it would be possible to use a AI like this to create an evaluation bar for pokemon showdown like there is in chess? That would be super cool
Click to expand...Click to collapse...
One of the model's outputs is exactly that, the probability of winning. I'm assuming there are two problems:
  1. The model was trained from one player's point of view, with access to that player's full set. So it won't be accurate from a spectator's POV.
  2. The function is probably sensitive to mirroring, so even if it had full information (or spectator's information only), it would give different results depending on whether it's evaluated from Player 1's or Player 2's POV. This could be mitigated by calculating it from both POVs and averaging the results.
Hydrametr0nice said:
One of the model's outputs is exactly that, the probability of winning. I'm assuming there are two problems:
  1. The model was trained from one player's point of view, with access to that player's full set. So it won't be accurate from a spectator's POV.
  2. The function is probably sensitive to mirroring, so even if it had full information (or spectator's information only), it would give different results depending on whether it's evaluated from Player 1's or Player 2's POV. This could be mitigated by calculating it from both POVs and averaging the results.
Click to expand...Click to collapse...
Exactly right!
Answering Xuwu's questions:
  • Validating the JAX engine: There are hundreds of test cases covering the engine. Additionally, when playing online, Jaxcalibur logs any cases where its engine's prediction doesn't match what actually happens on Showdown. Whenever this surfaced a bug, I fixed it and added a corresponding test case. Self-play win rates were also surprisingly useful for finding problems. For example, at one point I discovered that Truant was implemented incorrectly because Slaking was performing much worse in self-play than expected. That said, there are still ~30 known inaccuracies in the engine that were either difficult to implement or would significantly slow it down. They're fairly rare, but they can absolutely cause Jaxcalibur to make mistakes.
  • How much does predicting the opponent's next move help? A lot! It improved training efficiency by around 3x: a model trained with the auxiliary predictions was roughly as strong as one without them trained for three times as long.
  • Other formats such as OU: There would be a substantial amount of work involved in implementing the many additional Pokémon, abilities, and moves. After that, I think the easiest starting point would be self-play using a large database of human-made teams.
  • How close was the final run to a plateau? I monitored training by measuring each network's win rate against an older version. Performance was still slowly improving at 100M steps, although the curve did look like it was beginning to plateau.
  • Matchup tokens: It uses the opponent's active Pokémon plus the three highest-HP revealed Pokémon on their team. Using all 36 matchup tokens does make it play a little better, but not enough to justify the slower training.
  • Number of worlds during search: There's a tradeoff here: more worlds cover more possible scenarios, but leave fewer visits per node. I tested a range of values and found 16–32 to be a good middle ground. One thing I forgot to mention in the write-up is that Jaxcalibur actually doesn't use search at all when the opponent has only one or two revealed Pokémon, since there isn't enough information yet for the search to be useful.
Dunfan said:
Do you have a next step in mind with the source code you've cooked? For example, tweaking it a bit and using that ability to get positive/negative feedback from replays for research purposes on regular tiers. (eg. to find out what makes a good team, which would make for a very desirable helper)
Click to expand...Click to collapse...
I have no plans for now to make it stronger or extend it to other formats, but I might look into making some kind of analysis tools with it.
jaxcalibur_author said:
I have no plans for now to make it stronger or extend it to other formats, but I might look into making some kind of analysis tools with it.
Click to expand...Click to collapse...
Could you do something like chess.com’s Fame Review? Reviewing games and showing blunders, good moves, decent moves, and the rest? This could help experienced and newer players to see and fix their mistakes in-game. Please don’t put it behind a paywall though. Brilliant moves could be genius sacrifices.
jaxcalibur_author said:
Answering Xuwu's questions:
  • Validating the JAX engine: There are hundreds of test cases covering the engine. Additionally, when playing online, Jaxcalibur logs any cases where its engine's prediction doesn't match what actually happens on Showdown. Whenever this surfaced a bug, I fixed it and added a corresponding test case. Self-play win rates were also surprisingly useful for finding problems. For example, at one point I discovered that Truant was implemented incorrectly because Slaking was performing much worse in self-play than expected. That said, there are still ~30 known inaccuracies in the engine that were either difficult to implement or would significantly slow it down. They're fairly rare, but they can absolutely cause Jaxcalibur to make mistakes.
  • How much does predicting the opponent's next move help? A lot! It improved training efficiency by around 3x: a model trained with the auxiliary predictions was roughly as strong as one without them trained for three times as long.
  • Other formats such as OU: There would be a substantial amount of work involved in implementing the many additional Pokémon, abilities, and moves. After that, I think the easiest starting point would be self-play using a large database of human-made teams.
  • How close was the final run to a plateau? I monitored training by measuring each network's win rate against an older version. Performance was still slowly improving at 100M steps, although the curve did look like it was beginning to plateau.
  • Matchup tokens: It uses the opponent's active Pokémon plus the three highest-HP revealed Pokémon on their team. Using all 36 matchup tokens does make it play a little better, but not enough to justify the slower training.
  • Number of worlds during search: There's a tradeoff here: more worlds cover more possible scenarios, but leave fewer visits per node. I tested a range of values and found 16–32 to be a good middle ground. One thing I forgot to mention in the write-up is that Jaxcalibur actually doesn't use search at all when the opponent has only one or two revealed Pokémon, since there isn't enough information yet for the search to be useful.
Click to expand...Click to collapse...
Thanks a lot for the detailed answers — this cleared up several things I was wondering about. The Slaking/Truant example was especially interesting, and the ~3x training-efficiency gain from opponent-action prediction was much larger than I expected.

I had two follow-up questions if you don't mind.

First, given that the ~100M run was still improving but beginning to plateau, do you have an intuition for where additional compute would be better spent at this point? Would substantially more training on the same 8.5M model still be worthwhile, or do you think increasing model capacity and then training the larger model for long enough would now be the more promising direction?

Second, on OU: using a large database of human-made teams for self-play makes a lot of sense. Do you think the current hidden-information architecture would transfer fairly directly once the additional mechanics are implemented?

In Randbats, much of the uncertainty comes from unrevealed Pokémon as well as their sets, while in OU Team Preview reveals all six species but the space of plausible moves, items, EV spreads, Tera types, and team-correlated sets is much broader. Would you expect the existing auxiliary predictions / possible-world approach to handle that reasonably well, or do you think an OU version would benefit from modeling the opponent's team jointly rather than mostly predicting each Pokémon's hidden set independently?

Thanks again for taking the time to explain all of this!
Uranium233 said:
Can we run Deep Blue vs Kasparov but it's Jaxcalibur vs MichaelderBeste2
Click to expand...Click to collapse...
PokeChess said:
I'd love to see that happen! A best-of-nine series.

What you think? jaxcalibur_author.
Click to expand...Click to collapse...
This would actually be really cool, especially to see how exploitable the bot is against the best human players over the course of several games. Make it happen! jaxcalibur_author
PokeChess said:
I'd love to see that happen! A best-of-nine series.

What you think? jaxcalibur_author.

For analysis purposes, it would be great if both "players" (best bot vs. best human) ran `!showteam` at the end of each battle.
Click to expand...Click to collapse...
Hydrametr0nice said:
This would actually be really cool, especially to see how exploitable the bot is against the best human players over the course of several games. Make it happen! jaxcalibur_author
Click to expand...Click to collapse...
Considering the bot is freely challengable I think it makes much more sense to reach out to Michaelderbeste, I think he just got back from VGC worlds so he probably needs a break lol (hence why I didn't ping him)
jaxcalibur_author said:
Jaxcalibur

Hi everyone! I am excited to share a new Pokémon bot named Jaxcalibur. It only plays Gen 9 Random Battles, but it plays them extremely well. Over the past three weeks, it has spent time at #1 on the ladder and reached a peak Elo of 2557 and peak GXE of 95.3. As far as I know, it is the first AI to reach the level of top human players at Pokémon battling, albeit in a narrow format. For comparison, the strongest previous bot I'm aware of, FoulPlay, peaked around 2341 Elo and 88 GXE, which is roughly top-50 rather than top-1.

pMJt7ppexJhi7RFr6Vwa0Q.png
The ladder on August 10. This was Jaxcalibur's peak Elo (but not GXE)

That said, I can't say Jaxcalibur is the world's best random battler because one human outperformed it over this time period! MichaelderBeste2 held #1 on the ladder about 50% of the time compared to Jaxcalibur's 20%, and reached a slightly higher GXE of 95.5. I am really impressed that anyone can play better than a bot trained over millions of games and simulating thousands of possibilities each turn; that is an incredible feat!

How it works
Jaxcalibur uses a neural net trained with self-play reinforcement learning combined with pUCT search, similar to AlphaGo Zero. It is built on poke-env and Jax (which is where the name comes from). There is much more on how it works in the technical write-up here.

Some observations on how it plays: it is fairly conservative, preferring safe lines over hard reads. It is especially good at endgames because it can calculate several turns ahead. I think its clearest weaknesses are an imperfect understanding of PP stalling and a tendency to become predictable in some situations.

Current status
As of August 28, Jaxcalibur has stopped searching for ladder games and will let its rating decay. However, it will still accept randbats challenges if you'd like to play against it. It can only play one battle at a time, so it might not accept your challenge right away. Jaxcalibur currently plays random battles only, but I think it could be extended to other singles formats and, with more work, to doubles battles. It can't build teams itself, but you could use self-play with different teams to evaluate which ones are strongest

The open-sourcing question
When I started this project, I was intending to fully open-source Jaxcalibur, but it's strong enough I'm now a bit worried about how this could affect the community.

The case for releasing it: for me, the biggest benefit is that others could learn from it and build on it. Strong bots could also make single-player Pokémon more challenging, serve as practice partners, and be powerful tools for team building or balancing formats.

The case against: cheating is the big one. Someone could use Jaxcalibur to climb the ladder, obtain suspect reqs, or potentially even win tournaments in a way that's hard to detect. This feels especially relevant given the recent discussion about bots and suspect reqs. I also wonder whether easily accessible information about which teams, leads, and openings perform best would make team building less interesting.

One possible middle ground would be to release the code but not the model weights. However, for now I am holding off releasing either. I'd love to hear what people here think: should Jaxcalibur be open-sourced? If so, what would be a responsible way to release it? Strong, widely available Pokémon bots are probably coming sooner or later. This may be a useful chance to establish some norms around how they should be released and used.

Links
Click to expand...Click to collapse...
This is incredibly impressive, but I don't really think the conclusion should be "suspect reqs are cooked now" — at least not for something like OU.

Randbats is almost the perfect environment for a bot like this. The amount of hidden information is much more constrained: the possible sets, moves, items, abilities, EV structures, etc. come from a relatively defined distribution. Once you reveal a move/item/ability, the space of possible sets can shrink very quickly.

We already see a basic version of this with tools like Showdex. It might not know your exact set immediately, but after seeing one or two pieces of information it can narrow down what you're likely to be and calc around the dangerous possibilities. A sufficiently good bot can do the same thing probabilistically and play conservatively around the scary possibilities until it has enough information.

OU is a completely different problem.

Yes, you see all 6 Pokemon at preview, but you don't know the actual sets. You don't know the EVs, nature, item, Tera, fourth move, random tech, speed creep, defensive benchmark, lure, etc. And one deviation can matter enormously.

If the bot thinks a mon is the standard set and searches its lines based on that assumption, then suddenly finding out it's faster than expected, lives a hit it wasn't supposed to live, has an unexpected coverage move, or is some weird Tera can invalidate an entire line.

And unlike randbats, there isn't even a permanently fixed distribution to learn.

You would need a huge amount of current metagame information/replays to build sensible priors for what sets people are actually using. Then a ban happens, or a new Pokemon drops, or the meta shifts, and those priors can change dramatically. Usage changes, EV benchmarks change, common Teras change, movesets change, and people specifically start adapting to whatever is popular.

Tournament play makes that problem even worse because people intentionally bring stuff that is NOT standard specifically to punish what the opponent expects.

Obviously none of this means an OU bot is impossible. You could train one on massive amounts of OU data, teach it distributions over sets, make it infer sets from revealed information/damage/speed, and make it account for uncertainty rather than assuming one exact set.

But that's a substantially harder problem than what Jaxcalibur is solving here.

So to me the scary takeaway isn't "a randbats bot got #1, therefore it can just get OU reqs."

The impressive takeaway is that you built a bot capable of playing Pokemon at an extremely high level in a format where the hidden-state distribution is constrained enough for this approach to work incredibly well.

Whether you can make the same thing robust enough for an open-team-building format like OU — where creativity, meta shifts and even a single unexpected move/EV benchmark can completely alter a line — is a very different question.

I'd need to actually see that demonstrated before treating OU suspect reqs as solved.

Once again, props to you for creating jaxcalibur.
Typical_bastard said:
This is incredibly impressive, but I don't really think the conclusion should be "suspect reqs are cooked now" — at least not for something like OU.

Randbats is almost the perfect environment for a bot like this. The amount of hidden information is much more constrained: the possible sets, moves, items, abilities, EV structures, etc. come from a relatively defined distribution. Once you reveal a move/item/ability, the space of possible sets can shrink very quickly.

We already see a basic version of this with tools like Showdex. It might not know your exact set immediately, but after seeing one or two pieces of information it can narrow down what you're likely to be and calc around the dangerous possibilities. A sufficiently good bot can do the same thing probabilistically and play conservatively around the scary possibilities until it has enough information.

OU is a completely different problem.

Yes, you see all 6 Pokemon at preview, but you don't know the actual sets. You don't know the EVs, nature, item, Tera, fourth move, random tech, speed creep, defensive benchmark, lure, etc. And one deviation can matter enormously.

If the bot thinks a mon is the standard set and searches its lines based on that assumption, then suddenly finding out it's faster than expected, lives a hit it wasn't supposed to live, has an unexpected coverage move, or is some weird Tera can invalidate an entire line.

And unlike randbats, there isn't even a permanently fixed distribution to learn.

You would need a huge amount of current metagame information/replays to build sensible priors for what sets people are actually using. Then a ban happens, or a new Pokemon drops, or the meta shifts, and those priors can change dramatically. Usage changes, EV benchmarks change, common Teras change, movesets change, and people specifically start adapting to whatever is popular.

Tournament play makes that problem even worse because people intentionally bring stuff that is NOT standard specifically to punish what the opponent expects.

Obviously none of this means an OU bot is impossible. You could train one on massive amounts of OU data, teach it distributions over sets, make it infer sets from revealed information/damage/speed, and make it account for uncertainty rather than assuming one exact set.

But that's a substantially harder problem than what Jaxcalibur is solving here.

So to me the scary takeaway isn't "a randbats bot got #1, therefore it can just get OU reqs."

The impressive takeaway is that you built a bot capable of playing Pokemon at an extremely high level in a format where the hidden-state distribution is constrained enough for this approach to work incredibly well.

Whether you can make the same thing robust enough for an open-team-building format like OU — where creativity, meta shifts and even a single unexpected move/EV benchmark can completely alter a line — is a very different question.

I'd need to actually see that demonstrated before treating OU suspect reqs as solved.

Once again, props to you for creating jaxcalibur.
Click to expand...Click to collapse...
Unfortunately, I cross-post from a related thread in Policy Review that the Foul Play bot got close to getting OU suspect reqs over a year ago:
Brigtel said:
I want to make something clear for people who share this sentiment. It’s understandable but it comes from a lack of information.
The accomplishment shared by freezai in the first post is actually fairly unimpressive, though it asks legitimate questions.

I would like to inform you that foul play is already good enough to get reqs in the OU ladder, and in fact managed to get reqs for the Roaring Moon suspect test a few hours after the deadline. The reqs were 1750 ladder and 80% GXE. So bots have been good enough to get suspect reqs for over a year now.

The fact that it had many failed runs and only succeeded after the test had ended should be taken into account, but we should think with this information in mind. Make of it what you will
Click to expand...Click to collapse...
It apparently did so in the style of a mediocre(-ish) but hard-working OU player who wants reqs and will make any number of alts to do so.

The thread itself mainly covers attempts at website change given that bots can hit suspect reqs for at least one, and likely many, lower-scale ladders like Little Cup. And those bots aren't Jaxcalibur and pre-date Jaxcalibur.
Lectrys said:
Unfortunately, I cross-post from a related thread in Policy Review that the Foul Play bot got close to getting OU suspect reqs over a year ago:
Click to expand...Click to collapse...
Apologies, I may have been misunderstood. What I meant was the level of success and accuracy that Jaxcalibur achieves—specifically, how precise its decisions can be because of the amount of knowledge, information, and tools available to it.

Obviously, tools already exist that can achieve a certain level of success. What I was referring to, however, was dominance: being able to make highly accurate decisions consistently, rather than simply being capable of reaching a particular benchmark.

A comparison I would make is with chess engines. Chess bots have continuously improved as their models and methods have improved, but chess is still a game in which every possible future position—regardless of whether the number of possibilities reaches into the quadrillions or far beyond—is ultimately determined by a fixed set of rules and completely observable information.

The same cannot necessarily be said for a competitive Pokémon tier, where there is variance, incomplete information, and information that can be hidden or altered throughout a game. This is quite different from something like chess, where all relevant information is visible, or even Random Battles, where a bot can work from a much more clearly defined pool of possibilities.

So my point was not that bots are incapable of reaching suspect-test requirements or playing at a reasonably high level. Rather, I was questioning whether they could achieve Jaxcalibur-like dominance and consistency in a format where decision-making has to account for significantly more uncertainty and imperfect information.
Typical_bastard said:
Apologies, I may have been misunderstood. What I meant was the level of success and accuracy that Jaxcalibur achieves—specifically, how precise its decisions can be because of the amount of knowledge, information, and tools available to it.

Obviously, tools already exist that can achieve a certain level of success. What I was referring to, however, was dominance: being able to make highly accurate decisions consistently, rather than simply being capable of reaching a particular benchmark.

A comparison I would make is with chess engines. Chess bots have continuously improved as their models and methods have improved, but chess is still a game in which every possible future position—regardless of whether the number of possibilities reaches into the quadrillions or far beyond—is ultimately determined by a fixed set of rules and completely observable information.

The same cannot necessarily be said for a competitive Pokémon tier, where there is variance, incomplete information, and information that can be hidden or altered throughout a game. This is quite different from something like chess, where all relevant information is visible, or even Random Battles, where a bot can work from a much more clearly defined pool of possibilities.

So my point was not that bots are incapable of reaching suspect-test requirements or playing at a reasonably high level. Rather, I was questioning whether they could achieve Jaxcalibur-like dominance and consistency in a format where decision-making has to account for significantly more uncertainty and imperfect information.
Click to expand...Click to collapse...
Cross-posting again from the same Policy Review thread, bots have already gotten first place in at least one intermediate ladder with an actual teambuilder and no fixed sets:
fiish said:
Just for the record, Metamon's Tauros engine has already topped RBY's ladder.
Click to expand...Click to collapse...
RBY admittedly has no equivalent of EVs and no held items, which makes teambuilding easier, but bots do have to navigate the shifting metagame of "what's the 4th move on Jynx" and much more. The Tauros bot has already been dominant and consistent in RBY.
Xuwu said:
I had two follow-up questions if you don't mind.
Click to expand...Click to collapse...
Spending additional compute: I'm pretty sure Jaxcalibur would benefit more from a larger network than from simply training the current network longer. The size I chose was my best guess at the optimum for roughly a week of training, but with more compute I would expect the optimal network size to increase.

OU Uncertainty: I think the high-level setup would transfer pretty well. Jaxcalibur already predicts opponents' moves, items, and Tera types; EV spreads would need to be added as well. These predictions would be substantially harder in OU, which would make search more difficult, but I think the network itself would cope reasonably well.

One bigger issue is that Jaxcalibur currently predicts all of this opponent information independently. That's already a weakness in randbats and would become even more of a problem in OU. For example, there is nothing stopping it from predicting Choice Band + Swords Dance if the opponent might plausibly have either, and this definitely makes search a bit worse. Switching to joint predictions, at least at the level of individual Pokémon and potentially across the whole team, would definitely be an improvement.
Hi, I come from a youtube video but been playing in the ladder for many years and felt compelled to create an account for this special situation.

This is an incredibly cool project you have done but you should speak with the smogon stuff itself to see how they could prepare for it and in some way detect or separate it from real players, maybe making it work only when invited and not actively participating in the ladder. If you make it open source instead of releasing a closed source binary, people will remove all the limitations and soon we will all be fighting bots instead of real players all the time which would remove much of the point of playing competitive (at least for me) so even while being a strong advocator of open source stuff this would easily fuck up competitive pokemon super fast I would recommend not releasing it open sourced but closed sourced and limited in its capabilities to not participate in the ladder.
jaxcalibur_author said:
This is definitely a bug! I will look into fixing it.
Click to expand...Click to collapse...
Nice! As DragonPhoenix333 also said: "the bot does have bugs sometimes, as previously posted it spammed court change, and against me it clicked volt switch twice in a row into volt absorb". So, it would be a good idea to take a look at those reported situations. The bot might be glitching on certain choices in specific scenarios.

jaxcalibur_author said:
I'm up for helping set this up if MichaelderBeste is interested!
Click to expand...Click to collapse...
MichaelderBeste2 said:
I am, it sounds really cool
Click to expand...Click to collapse...
Let's goooooo! :boi: :sphearical:

It would be cool if it were scheduled (with a specific day and time) so the community could watch it live. Just a suggestion.
I am excited at the prospect of an indisputably top player vs a ladder topper. I strongly suspect that the bots are not quite superhuman in this regard. I think Michael will find ways to exploit to bot in a focused match setting and I don't think the search will mitigate the exploitable tendencies of the network/JAX simulator shortcomings. I think half the success of bots on ladder is due to the fact that they can't resign.
Also please for the love of god do more than 9 games as someone suggested. In bot v bot contexts it actually takes hundreds/thousands of games to tease out the differences between similar agents. This game is so high variance you would not believe the swings we observe in testing. Obviously thousands of games is absurd but there is a middle ground. That being said, in accordance with my prediction I don't think it will be that hard for MDB2 to generate a convincing margin
Back Top