Resource Questions about how Random Battles formats work? Read here!

Status
Not open for further replies.

A Cake Wearing A Hat

moist and crusty
is a Community Leaderis a Top Community Contributoris a Metagame Resource Contributoris a Top Contributoris a Smogon Media Contributoris a Dedicated Tournament Hostis a Battle Simulator Moderatoris a Site Content Manager Alumnusis a Top Social Media Contributor Alumnus
Random Battle Lead
Post Index:
#2: Gen 9 Random Battle/Gen 9 Random Doubles Battle - How does Random Battles work exactly? Code explanation post
#2: Gen 9 Random Battle/Gen 9 Random Doubles Battle - Roles and what they do
#3: Other Random Battles formats - System differences
#4: Set Development Policy, Principles, Process, and Guidelines

Random Battles Changelog
How does Level Balancing work? How are levels decided in Random Battles?
Gen 9 Random Battles Set Suggestions

If you have any questions on any of the information in this thread, feel free to ask in the Simple Questions, Simple Answers thread, or ask me personally!

This thread is intended to help understand the systems and mechanisms that make the Random Battles teams you use on PS!.


How does Random Battles work, exactly?
Good question. One that will take a lot of text to answer. This post will contain technical information that may be difficult to understand; however, I will do my best to explain it in terms anyone can get. If you can get through this post and fully understand it, you will be able to truly understand what changes are and are not possible in Gen 9 Random Battle and the consequences of the changes that can be made. Singles and Doubles use the same generator. You can tell in the code what's for Doubles or not when you see "isDoubles"! Keep in mind, though, you DO NOT need to know this, or any of the other posts' info, to enjoy Random Battles, it's just supplemental information if you're curious.

teams.ts - location of the process itself
random-sets.json - location of movepools, ability pools, roles, levels, and Tera types

! means "Not", take the inverse of what the thing following it is saying.
".includes" means "does this pokemon have the ability to obtain this?"
".has" means "does this pokemon so far already have this thing in this specific random battle set?"
"===" means "is"
"counter.get" means we're keeping track of whether this Pokemon has this thing or not, and in what quantity.
"&&" means "and"
"||" means "or"
"isDoubles" means the code is specific to Gen 9 Random Doubles generation. "!isDoubles" means it's specific to singles. Otherwise, it's shared between both.

Overview: The Flow Of Set Generation
Random Battles set generation follows a very specific series of steps. Each step informs the decisions of the steps afterwards, but the later steps have no say in the earlier steps' decisions. These steps cannot go out of order or in reverse at all whatsoever. Any suggestion that would require these steps to go in any direction other than forwards is not possible. Each step listed below will be expanded upon in a hide-box later in this post. The steps are:

Generate First Pokemon Species -> Choose Role -> Choose Tera Type -> Choose Moves -> Choose Ability -> Choose Item -> Adjust EVs/IVs if needed -> Generate Pokemon 2's Species -> etc.

This step chooses a number of random team members (from existing tiers and Unreleased) equal to the current maxTeamSize (default: 6). Pokemon with a number of formes, such as Rotom or Zamazenta, have the chance for that Pokemon to generate split between the formes. So, for example, you are half as likely to see a Zamazenta-Crowned as you are to see a Toedscruel. Levels are applied to the Pokemon as they are generated, using level data from sets.json.

While this step occurs, it is possible for the slot being chosen to be rejected and other random Pokemon to be rolled instead if the original Pokemon does not meet certain conditions. Team generation currently uses this feature to prevent teams from having more than 3 Pokemon weak to any given typing, more than 2 Pokemon of any given type, or more than 1 Pokemon that shares a 4x weakness.

Additionally, Zoroark formes cannot generate in Slot 6, and Intrepid Sword and Dauntless Shield users cannot generate in Slot 1.

The Role-choosing step is relatively simple; each Pokemon has one to three "Roles" to choose from in sets.json (please see Post #2 for details on what each role means!). Roles are largely decided completely randomly, although if there is already a Pokemon with the role of Tera Blast user (or Ogerpon or Terapagos) on the team, any future Tera Blast user roles (as well as Ogerpon or Terapagos, entirely) will be excluded from the running. This step informs many future steps, but most importantly chooses which movepool to pick moves from in sets.json. Please brush up on all of the roles in Post #1 for details!

The Tera Type step is even more simple. sets.json contains a list of potential Tera types for each Pokemon, separated by role. A random Tera Type is then chosen from the Tera Type pool for the selected set.

This is a big one.

First, please understand the difference between the "movepool" and the "moveset". The movepool is the set of move options for a given set, as visible in sets.json as "movePool". The "moveset" is the set of four moves that you see in battle.

Moves are, one by one, moved from the movepool to the moveset. Initially, this is done less randomly: there are many conditions for move enforcement. Once all move enforcement conditions are fulfilled, then moves are selected randomly from the remaining movepool until the user reaches a set of four moves. Additionally, after each move added to the moveset, the remaining movepool is checked for move incompatibilities. Anything incompatible with the selected move is removed from the movepool and can no longer be generated on the set.

Move Enforcement: (Visible on lines ~200-250 and ~700-1000 of teams.ts)
A list of move enforcement conditions exists; if any of these conditions for "enforcement" are met, an applicable move is added to the moveset. Pokemon are at minimum forced to have at least one STAB move not found on the "NO_STAB" list around line 103 of teams.ts. Most typings also have specific rules for enforcement, visible on lines 200-250. Certain roles force certain sets of moves; "bulky" roles typically force recovery moves when available, "setup" roles force a setup move, "bulky attacker" forces STAB priority when possible, roles not called "support" force the set to contain at least two attacks minimum, and most roles also force an attack matching the Pokemon's Tera Type. Additionally, Facade is forced if the user's potential abilities include Guts, and a small list of Pokemon have forced priority moves instead of forced non-priority STAB moves. Certain moves (WishTect, LeechTect, Screens) are paired together; the other must be forced if one is generated. Once no more "enforcement" conditions are applicable, moves are selected randomly.


Move Incompatibilities: (Visible on lines ~490-640 of random-teams.ts)
After each move is added to the moveset, a short list of move incompatibilities is run through and anything deemed incompatible will be removed from the broader movepool. Most of the incompatibilities in teams.ts are easily readable by people who do not know Typescript. For example, one cannot have both setup and hazards in the same moveset, so if a setup move is rolled, all hazards will be removed from the movepool, and vice versa. In addition, there are some team-based move rejections: there cannot be more than one Stealth Rock user, more than one Sticky Web user, or more than one hazard remover under most circumstances. If rejecting a move from the movepool would cause there to not be enough moves remaining to create a set of four, this step is waived. This means that Pokemon with only four moves in their movepool can still get Stealth Rock if another team member already has Stealth Rock, for example.

In Gen 8, the Moves section is significantly messier; moves are brought from the movepool to the moveset, and then moves are rejected based on rejection conditions and rerolled until all rejection conditions are satisfied. Enforcement was just fancy rejection, rejecting random moves until the Pokemon gets what it's forced to. This could often result in heavy weighting towards specific moves compared to others, and could also regularly result in erroneous, unintended sets. Gen 8 is the only format left that uses this system, and a decent portion of the playerbase prefers it that way, so we aren't planning to change it soon.

NEW! as of 7/12/2024. We've completely revamped how Abilities get generated!

Each role has a list of possible abilities the set can generate (dubbed an "ability pool"). Under most conditions, once moves are set in stone, the ability is rolled randomly between the available options on the role. For example, (Kanto) Electrode rolls randomly between Soundproof, Static, and Aftermath, all with an equal chance of appearing. Not all abilities the Pokemon has are in each role's ability pool! Often, undesired abilities are excluded from any given set.

Abilities cannot be weighted within a role such that one is more common than the other at all times. If multiple abilities are able to generate on a given role, it will roll evenly between all of the options.

However, some abilities are conditional, which means they only appear under certain conditions. These conditions fit into two categories:
Ability Rejections:
Abilities with uses conditional on the moves rolled or the rest of the team, such as Swift Swim, Chlorophyll, Overgrow, Defiant, and Iron Fist, get rejected and removed from the ability pool if the criteria for them to appear aren't met. If the criteria are met, though, these abilities will still roll randomly with other abilities the role can have. For example, when Infernape gets Mach Punch on its moveset, it still has a 50/50 roll between Blaze and Iron Fist. The list of the rejection criteria can be found around line ~1050 of teams.ts. This might not be perfect, though, which is why we need the second category too!

Ability Enforcement:
Some abilities simply MUST appear over all the others if the conditions for their appearance are there. For example, Toucannon doesn't always get Bullet Seed, but when it does, we code Skill Link to be enforced on it. The list of enforcement conditions (typically made of hard-coded cases for specific species) can be found on around line ~1110 of teams.ts.

Item selection is a relatively simple, but long process. A descending list of "if" conditions begins on line ~1160 of teams.ts and ends around line 1420. The first condition in this list to be met gives the Pokemon its item. The higher-priority conditions, listed first, are often Pokemon-specific; Pikachu gets Light Ball, Ditto gets Choice scarf, and so on. As the list goes on, the conditions become more generalized. For example, a condition exists where "If you have no status moves and are neither a Fast Attacker nor a Wallbreaker, you get an Assault Vest". This condition would give everything with no status moves an AV in a vacuum; however, it is prioritized below Choice items and several other relevant item possibilities, so in practice it primarily appears on mixed attackers. If no conditions are met at all, we give the Pokemon Leftovers and call it a day. There is not enough space on this post to give every item condition a thorough explanation; i recommend reading it yourself and using some common sense!

EVs will always be 85 and IVs will always be 31 with a neutral nature in the vast majority of situations. However, a few conditions can change that. If the Pokemon has no physical attacks, its Attack EVs and IVs are set to 0, but everything else remains the same. If the Pokemon has Trick Room or Gyro Ball, its Speed EVs and IVs are set to 0, but everything else remains the same. In past gens, EVs for certain stats were lowered slightly to give Nihilego and Celesteela better use of Beast Boost. Such a feature is possible in Gen 9 as well, but it is not currently in use.

If you got through all that, good for you, you're now an expert in Random Battles set generation! Put that on your resume, you've earned it. If you have any questions, feel free to ask me personally! Just be sure you've read everything carefully.
 
Last edited:
What are roles?
In Gen 9 Random Battle and Gen 9 Random Doubles Battle, each Pokemon has between one and three roles that it can fulfill; each role comes with its own movepool, which means that Pokemon in both formats can have multiple separate movepools! Outside of being a handy way to keep conflicting sets on a single Pokemon apart from each other, roles also determine which kinds of moves always generate (or which moves are forced, in other words) on the Pokemon and which items the Pokemon will get. That's almost everything they do! Functionally, you don't need to worry about it unless you're trying to deduce what your opponent's set is from what they've revealed so far.

What do the different roles do?
There are ten roles in total in each format, each with their own rules. Keep in mind, the roles are not always accurate to what the Pokemon actually does, it's just what fits best for the generator. We try, on average, to keep it as accurate as we can, though. Also, if a Pokemon can't possibly fulfill a certain condition, that condition is just ignored. (for example, if the role forces a recovery move, but it doesn't have one in its pool, it's not a problem!)

  • Fast Attacker: This is the most common role. Essentially, these Pokemon are on the offensive; they get a Life Orb as their default item if they don't have anything better (like Boots or a Choice item), they always have a move matching their Tera type if one exists, and they'll always have two attacking moves at minimum.
  • Setup Sweeper: Pokemon with this role will always come with a setup move of some sort, on every set that generates! They also get a Life Orb as their default item, have a Tera-typed attack when possible, and have a minimum of two attacking moves.
  • Wallbreaker: Mostly identical to Fast Attackers in function, Wallbreakers stand out in one particular fashion: They cannot get a Choice Scarf. If they're Choiced, it'll always be Band or Specs. Many Wallbreakers will typically also be on the slower side, and can't really be described as "fast" in good faith. Also, newly, Wallbreaker role forces a STAB Priority move if available on the set.
  • Tera Blast user: This role is unique—there can only be one Tera Blast user on a team maximum. You aren't guaranteed one, and Pokemon that can be Tera Blast users don't always have to be Tera Blast users (tera blast users will always have another, non tera blast option). These Pokemon always come with setup if it exists in their movepool, have two attacks at minimum, have Life Orb by default, and always run Tera Blast. Again, it's important to note: Some Pokemon, like Regieleki, are Tera Blast users but do not run setup moves. This is on purpose.
  • Bulky Attacker: This role forgoes Life Orb in favor of having Leftovers as the default item. They also always run any recovery or STAB priority moves they have. Not all of them have those as options, though. Other than that, they have the usual: two attacks minimum and a Tera-typed attack. Assault Vest can appear on this role with four mixed attacks.
  • Bulky Setup: The bulky counterpart to Setup Sweeper, it is identical to Bulky Attacker but with setup moves forced on it. The definition of "setup" for these Pokemon can be relatively lax—some Bulky Setup users will opt for Iron Defense + Body Press, some will have more standard setup options, and there's also Oinkologne with Stuff Cheeks Salac Berry.
  • Fast Bulky Setup: Surprisingly a distinction that needs to be made, Fast Bulky Setup is the kind of thing CM + Stored Power Espathra or Substitute + Bulk Up Annihilape would be described as. Fast Bulky Setup Pokemon have setup forced, have Life Orb by default with three attacks, have Leftovers by default with two attacks, and have the usual Tera-attack and two minimum attacks.
  • Bulky Support: The fat role. These Pokemon do not have a minimum number of attacks to be valid, don't need a Tera-typed attack, and have Leftovers by default. They also require recovery, if it exists. Assault Vest can appear on this role with four mixed attacks, although this is pretty rare. This role also enforces Defog and Rapid Spin if the team doesn't have it yet and the move can be rolled.
  • Fast Support: Fast Support Pokemon have probably the most conditions. To start, they require a Tera attack, but NOT a two-attack minimum. They get Life Orb by default with three attacks, Leftovers by default with two or fewer attacks, Heavy-Duty Boots by default with hazard removal or a pivoting move (unless they're ungrounded), and Focus Sash by default in the lead slot (unless Focus Sash is objectively bad on it). Assault Vest can appear on this role with four mixed attacks. Yes, this means you'll occasionally see AV Electrode. Enjoy!
  • AV Pivot: Pokemon with this role always get Assault Vest, and always have a Tera-attack when possible. Also, this role enforces Volt Switch and U-turn if the move can be rolled on the Pokemon

    So, to put it into other terms:
    Two-attack minimum, if two attacks exist: Every role except Fast Support and Bulky Support
    Always have an attack of the Pokemon's Tera Type, if it exists: Every role except Bulky Support
    Always have setup, if it exists: Setup Sweeper, Bulky Setup, Fast Bulky Setup, Tera Blast user
    Always have recovery, if it exists: Bulky Attacker, Bulky Setup, Bulky Support
    Always have hazard removal, if it exists and the team doesn't already have it: Bulky Support
    Always have Volt Switch or U-turn, if it exists: AV Pivot
    Life Orb by default unconditionally: Fast Attacker, Setup Sweeper, Wallbreaker, Tera Blast user
    Leftovers by default unconditionally: Bulky Attacker, Bulky Setup, Bulky Support
    Life Orb/Leftovers depending on # of attacks: Fast Support, Fast Bulky Setup
    Can generate Assault Vest: Bulky Attacker, Bulky Support, AV Pivot (always)
    Can generate Focus Sash: Fast Support, and ONLY Fast Support

  • Doubles Fast Attacker: Essentially, these Pokemon are on the offensive; they get a Life Orb as their default item if they don't have anything better, they always have a move matching their Tera type if one exists, and they'll always have two attacking moves at minimum. Note that in Doubles, most Pokemon do not get Choice items with 4 attacks; the only ways this role can get a Choice item are with Trick/Switcheroo/U-turn/Volt Switch.
  • Doubles Setup Sweeper: Pokemon with this role will always come with a setup move of some sort, on every set that generates! They also get a Life Orb as their default item, have a Tera-typed attack when possible, and have a minimum of two attacking moves.
  • Doubles Wallbreaker: This role is drastically different from in Singles. These Pokemon have Life Orb as their default item; however, they are able to get Choice items with 4 Physical or 4 Special attacks. If they're Choiced, it'll always be Band or Specs. These Pokemon also always have Trick Room and STAB Priority attacks if their movepool contains them. Additionally, they can uniquely get a Life Orb with Fake Out.
  • Doubles Bulky Attacker: This role forgoes Life Orb in favor of having Sitrus Berry as the default item. Other than that, they have the usual: two attacks minimum and a Tera-typed attack. Assault Vest can appear on this role with four attacks.
  • Doubles Bulky Setup: The bulky counterpart to Setup Sweeper, it is identical to Bulky Attacker but with setup moves forced on it. The definition of "setup" for these Pokemon can be relatively lax—some Bulky Setup users will opt for Iron Defense + Body Press, and some will have more standard setup options.
  • Tera Blast user: This role is unique—there can only be one Tera Blast user on a team maximum. You aren't guaranteed one, and Pokemon that can be Tera Blast users don't always have to be Tera Blast users (tera blast users will always have another, non tera blast option). These Pokemon always come with setup if it exists in their movepool, have two attacks at minimum, and always run Tera Blast. Items for this work strangely. If the Pokemon is at or above 80 base Speed or has Trick Room, it gets Life Orb as their default item, similar to Fast Attacker. If they are slower than 80 base Speed, they can get Sitrus Berry or Assault Vest. Again, it's important to note: Some Pokemon, like Regieleki and Dragonite, are Tera Blast users but do not run setup moves. This is on purpose.
  • Offensive Protect: These Pokemon are Fast Attackers with Protect enforced. To review, they have a Tera-typed attack when possible, have two attacks at minimum, and have Life Orb as their default item.
  • Bulky Protect: These Pokemon similarly have Protect enforced. They also always have a Tera-typed attack when possible. However, they can run one attack and be fine. These Pokemon get Leftovers if they are running a setup move, and Sitrus Berry otherwise.
  • Doubles Support: The passive role. These Pokemon can run only one attack and be valid, don't need a Tera-typed attack, and have Sitrus Berry by default. They also require Fake Out, speed control moves, and redirect moves, if they exist. Assault Vest can appear on this role with four attacks, although this is pretty rare.
  • Choice Item user: Pokemon with this role always get a Choice item, and always have a Tera-attack when possible. Really, that's it.
So, to put it into other terms:
Two-attack minimum, if two attacks exist: Every role except Bulky Protect and Doubles Support
Always have an attack of the Pokemon's Tera Type, if it exists: Every role except Doubles Support
Always have setup, if it exists: Doubles Setup Sweeper, Doubles Bulky Setup, and Tera Blast user
Always have recovery, if it exists: Nothing.
Always have Protect, if it exists: Offensive Protect, Bulky Protect
Always have Fake Out or redirect moves, if they exist: Doubles Support
Always have a speed control move, if they exist (such as thunder wave, icy wind, etc.): Doubles Support
Always have STAB priority or Trick Room, if they exist: Doubles Wallbreaker
Generate Life Orb by default: Doubles Fast Attacker, Doubles Setup Sweeper, Doubles Wallbreaker, Offensive Protect; Tera Blast users at or above base 80 Speed or with Trick Room
Generate Sitrus Berry by default: Doubles Bulky Attacker, Doubles Bulky Setup, Bulky Protect, Doubles Support; Tera Blast users below base 80 Speed without Trick Room
Generate Life Orb, even with Fake Out: Doubles Wallbreaker
Can generate Assault Vest: Doubles Bulky Attacker, Doubles Support; Tera Blast users below base 80 Speed without Trick Room
Can generate Choice items with U-turn, Trick, Switcheroo, and Volt Switch: Anything except the Protect roles
Can generate Choice items with 4 attacks and none of the above: Choice Item user, Doubles Wallbreaker


And that's a crash course on the role system! Again, unless you're into predicting your opponent's sets with partial information or wish to get invested in helping with sets yourself, this really isn't going to be more than a curiosity piece for you.
 
Last edited:
What's different about the other formats that use this system?
Gens 2, 3, 4, 5, 6, and 7 of Random Battles also now run under the same system you can learn about above, with a couple changes! I'll run these changes down for you here. There aren't many. Gen 8 runs an older, harder to explain system instead of this one, and we aren't planning to revamp it to the new system.

Preferred Type has all the technical specifications of Tera Type but without the actual functionality of Tera. In other words, if a Pokemon has a Preferred Type listed when you type the /randbats command, or if you see a Preferred Type in /data/random-battles/gen7/sets.json, that means the Pokemon will always get a move of that type. Not all Pokemon have a Preferred Type; it's mainly for things like Nidoking, which always want a specific move but don't have it enforced in any other way.

Preferred Type is also used to select the Z-Crystal chosen for Z-Move users. Unless the Pokemon has a species-specific Z-Crystal, the Z-Crystal will match the Preferred Type of the Pokemon. For example, Z-Conversion Porygon-Z is Preferred Type Normal, and gets Normalium Z.

If there are multiple Preferred Types listed on a Pokemon's set, it rolls randomly between them and picks one preferred type for the set in question. For example, Z-Move user Cobalion has both Steel and Fighting preferred types, so it will get Steelium Z or Fightinium Z at random.

The Z-Move user role replaces the Tera Blast user role in a lot of ways. There can only be one Z-Move user on the team. However, it differs from Tera Blast user in one major way: Z-Move user will always be chosen over the "Setup Sweeper" and "Bulky Setup" roles of the same Pokemon, unless there is already another Z-Move user. For example, if you roll a Gyarados and the team does not yet have a Z-Move user, that Gyarados will always be its Z-Move user set, because its only other set is Setup Sweeper.

Also, certain Pokemon (looking at you, Spinda and Castform), only have a Z-Move user set. If the team already has a Z-Move user, these Pokemon will not generate at all. We don't like doing this, but it's necessary.

Because of the sheer amount of Toxic in Gen 7, we needed a new role to fit it. Gen 7, therefore, completely removes the "Fast Bulky Setup" role, and instead adds Staller. Pokemon with the Staller role have the following things enforced, if they are available in the movepool:
-Recovery moves
-Protect moves
-Toxic
-one STAB move, minimum.

Stallers will ALWAYS get Leftovers, unless they have an ability like Harvest that would require something different.

The Wallbreaker role does not force STAB Priority when available, in older generations. Also, the AV Pivot role does not enforce pivoting moves in older generations.

This one's kind of technical. Basically, teams generate in reverse, from Slot 6 to Slot 1, instead of front-to-back like Gen 9. This happens because Mega Pokemon will always generate over the regular species if available, and we don't want your Mega to be leading half the time. That's pretty much the only reason. It also helps not reveal Z-Move users as often, coincidentally.

The Spinner role is exclusive to pre-Defog-removing-hazards gens of Random Battle, especially Gen 5. It's functionally identical to Bulky Support, in that Rapid Spin and recovery moves are forced on it and it gets Leftovers by default. However, the Spinner role will always be given over other roles a Pokemon has in its pool, unless the team has hazard removal. Yes, this means you'll never get Bulky Attacker Armaldo, the one with Swords Dance, unless you have hazard removal already. It's unfortunate, but we need to do whatever we can in these generations.

https://github.com/smogon/pokemon-showdown/blob/master/data/random-battles/gen7/sets.json - All of the sets for Gen 7 Rands

https://github.com/smogon/pokemon-showdown/blob/master/data/random-battles/gen7/teams.ts - All of the code for the actual set generator for Gen 7 Rands

You may also view the same for other old generations by changing the number in the hyperlink.

Gen 3 has a lot of differences due to not having Assault Vest, Life Orb, or various other tools. As such, the default item is always Leftovers, and a couple roles are changed:

Generalist has absolutely no effect on the Pokemon and merely generates the Pokemon normally.

Berry Sweeper is a new role that forces Substitute/Endure and grants Salac/Petaya type pinch berries.

-Gen 2 has a Thief User (Hamburglar) role, which enforces Thief and no item.
-Roles that enforce recovery now also force Rest, Sleep Talk, and Pain Split.
-Bulky roles generate Leftovers instead of Mint Berry when the Pokemon has Rest, but not Sleep Talk.

-The default item is Eviolite.
-Fast Bulky Setup and AV Pivot do not exist.
-The Fast Attacker role is the only role that allows Choice Scarf to generate. Other choice items do not exist, largely.
-Setup Sweeper and Wallbreaker can generate Life Orb. Other roles don't. Tera Blast user also doesn't give Life Orb.
 
Last edited:
Set Development - Policy, Principles, Process, and Guidelines

If you've read the above posts, you may now know how the technical side of Random Battles works. But how do the sets get decided, and what standards do we have? First, let's start with our principles:

Random Battles Development Principles
These rules are subject to change. If you have any questions or concerns, please check out the Simple Questions, Simple Answers thread, or ask me personally!
1. Pokemon will have 85 EVs in every stat with a neutral nature. The main exceptions to this are special attackers (who have 0 attack EVs, 0 attack IVs, and still a neutral nature), and Gyro Ball/Trick Room users (who have 0 Speed EVs, 0 Speed IVs, and still a neutral nature). Being above 85 EVs in any given stat, or having a non-neutral nature, will never be considered in Random Battles development. Beast Boost users may also have their stats adjusted minorly to support better boosts, but this currently only applies to Nihilego. In cases where EVs are reduced, they are not redistributed among the other stats. They're just left blank.

2. Pikachu and every fully evolved Pokemon in the game's data must be included in Random Battles. I'm sorry. We can't remove Unown. It's gotta stay, we're under orders from administration. This includes unreleased Pokemon that have movepools in the games' code like Eternal Floette in Gen 6. Some NFE Pokemon may also be included in Random Battles if they are both unique enough from their evolution and functional in a Random Battles setting. These are included on a case-by-case basis; if a NFE pokemon is bad enough, it can be removed from the format.
3. Every Pokemon will have their optimal set(s). This is determined by the staff, suggestions in the Set Discussion threads, and comments in the PS! room. We will never intentionally make a set worse than it could be in a Random Battles setting. Note that this does not mean that we copypaste sets from OU; sometimes, sets that work in tiers don't work as well in Random Battles, and vice versa.

3a. Sometimes, elements of a Pokemon will be removed by council vote, like Moody and Last Respects. Elements are only removed in order to make Pokemon more consistently able to put in work in a game; often, the removal of these elements comes with a hefty level buff that helps the Pokemon leverage their stats better to consistently do something in battle, rather than just winning half the time and doing nothing the other half. In other words, we don't remove things for being too good, we remove them for being too inconsistent.

4. Pokemon will, when possible, have a variety of viable sets. We try to avoid having Pokemon fixed at only one set of four moves when possible. This isn't always feasible, but if a Pokemon has other options aside from the Set Everyone Talks About, these additional sets will be included when possible. An example of this is Lumina Crash Espathra. Keep in mind, though, that these sets need to at least be close in power level so that they can function at the same level as the other sets; Shift Gear Cyclizar would be horrible at its current level, for example. And that leads us to...

5. Every month, levels are balanced for each Pokemon via objective win rate statistics. This currently applies to gens 3-9 of Random Battles. You can view objective win rates via the "/rwr [format]" command on PS! Pokemon still only have one level for all of their sets combined, so all of their sets must be of relatively (but not exactly) equal power level. Because we aim for all Pokemon to have roughly equal win rate, the relative tiers of Pokemon do not matter. Ubers are generally not inherently more powerful than other Pokemon in Random Battles, because they are often significantly lower level.
You can check this post about the statistical principles behind level balancing.

6. We will not give Pokemon moves they don't learn or bypass level/EV limits, but we can be otherwise loose on legality issues. For example, Gen 6 Clefable can have Soft-Boiled with Unaware, but we won't give a Zamazenta Body Press in Gen 8. The reason for this is due to ease of coding. We will not give Toxic to Pokemon that do not currently learn it in Gen 9, for example. We also will not bring Pokemon like Unown and Luvdisc past level 100. Team Preview doesn't exist in Random Battles to give players another avenue of skill expression: knowing when to withhold information from the opponent to gain an advantage in an otherwise disadvantageous situation! Because of the lack of Team Preview, we also modify Illusion slightly to compensate by letting it visually copy levels.

7. We try to keep the code concise when possible. Even if it may theoretically make a Pokemon better to give it complicated rules to its set generation, like specifically making Unaware variants of Clefable run Heavy-Duty Boots, doing so would not be feasible from a code standpoint while maintaining readability. Such things are called "hardcodes", as they are individual, inflexible pieces of code tacked onto the algorithm that only interact with one thing and do nothing else. Often, instead of these "hardcodes", we keep with simple solutions, or try to install new generalized rules instead, like our Roles system in Gen 9. More of these "hardcodes" also artificially raises the skill level required to play Random Battles optimally, because you need to memorize countless Pokemon-specific rules instead of a smaller set of general rules. This point may be difficult to understand, but that's okay! Essentially, it just means that not every suggestion is feasible from a technical standpoint, even if it would be helpful.

Why are hardcodes bad?

-Each and every hardcode makes it more difficult for outside viewers, and even our own code team, to read the code, understand the code, and change the code without making mistakes.

-Each and every hardcode adds another distinct, specific piece of information that players would need to memorize that can't just be found by using /randbats, and makes the code both more necessary as a resource to learn the format and more difficult to read as a resource to learn the format.

-Piling up too many hardcodes negates the worth of the base framework, which brings into question its viability as a framework. For example, we used to generate abilities algorithmically with Pokemon Showdown's built in ability rating system, but the sheer number of ability hardcodes became so much that we questioned its viability as a framework and revamped it to something completely different instead.

-Adding too many hardcodes, especially with vague documentation or obfuscation that they are hardcodes (e.g. trying to say that "Pokemon with over 100 speed should not get Regenerator with High Jump Kick" instead of "Mienshao should not get Regenerator with High Jump Kick"), makes the code almost impossible to break into as a newcomer into coding the file, and every hardcode acts as a barrier to new potential members of our Code Team. This has happened multiple times in the history of Random Battle; A former format head had to rewrite the code from scratch without understanding what any of it meant because the format head before that added too many hardcodes by the time they left.

-Adding too many hardcodes results in the review process (wherein coders both on and off of our code team look over code changes and determine if they are good to go) becoming significantly more difficult and drawn out. It will become harder to get willing reviewers to a file that is notoriously full of hardcodes. We have enough difficulty getting willing reviewers already without that.

-Adding too many hardcodes, in extreme cases, can result in major scrutiny and/or action from the Pokemon Showdown core development team in order to prevent it from happening again, which is undesirable.

-Adding too many hardcodes increases the likelihood of unforeseen and difficult-to-fix bugs that will then need to be band-aid patched with other hardcodes. It can also increase the likelihood of crashes, and in extreme cases, slow down Pokemon Showdown.

-Sets should not be tailored to only be good if the Pokemon Teras, outside of Pokemon with Tera Blast and the Tera Blast user role, in order to not interfere with the generation and function of Pokemon with that role, as well as to account for situations where your Tera is better used elsewhere. This means that Pokemon with Tera Ghost will not have Shadow Claw over a stronger coverage move, for instance. This is also why Tera Stellar Enamorus must still run Play Rough. The same rules apply for Dynamax in Gen 8.

-Sometimes certain sets will have to be removed or added for reasons of metagame health, such as Defog Kleavor's existence or Choice item Annihilape's removal, to keep a good balance of the ratios of relevant set types in the larger set-pool. Our long-term goals (see below) take priority over the principle of set variety.

-Tera Blast Users should not be added frivolously because they impact the frequency of all other Tera Blast users, as well as directly affecting the appearance rate of Terapagos and Ogerpon. It is best to keep Tera Blast users at around the frequency they're currently at. The same applies for Z-Move users in Gen 7 and Ultra Necrozma.

In addition to our principles, we also have two long-term goals currently in place that direct our set development:
-There are too many teams with 3 or more Choice item users. As such, we should not add more Choice item sets on Pokemon, or increase the rate of Choice items on Pokemon, without reducing the rate of Choice items on other Pokemon to compensate. Additionally, we try to seek out ways to reduce the rate of Choice items on Pokemon when we can. We are unable to make a broad rule to prevent getting 3 Choice item users entirely, so manipulating individual Pokemon's Choice item rates is the best we can do.
-We get many complaints about the state of hazards vs. hazard removal. We have a goal in place to maintain our current rate of hazard removal (at time of writing, over 1/3 teams get hazard removal), and not purposefully reduce the rate of hazard removal unless extremely necessary.
-Setup is too powerful in Gen 9. As a result, we have a goal to increase the rate of anti-setup moves like taunt, encore, roar, dragon tail, and haze as much as is feasible, even if doing so results in a slight winrate drop for the Pokemon.



Set Development - How do we do it?

Set development works through a consensus-based technocratic system, to be short. In longer terms: set development contributors (currently Random Battles room auth plus a few consultants) participate in Discord channels for each Random Battles format. In these channels, suggestions from other sources like the Random Battle Sets thread are discussed, and new suggestions are brought up by the contributors themselves. The Format Heads then implement or reject the suggestions based on a combination of how good the suggestion is for a Random Battles setting, consensus among the contributors, our Random Battles principles and goals above, and technical feasibility. A large number of suggestions get denied due to at least one of these reasons, and often a combination thereof. However, a large number of set suggestions and adjustments also pass each update. I make an effort to bring every genuine and feasible suggestion brought to me to the contributors for discussion.

In cases where a consensus cannot be reached among the contributors, either the Format Heads make a call, or the development council votes on it, depending on how severe the disagreement is.

In Gen 9 Random Battles, we have the luxury of having a very high sample size for our win rates; this lets us test our set suggestions and changes with a relatively high degree of accuracy. As such, we often make large sets of changes in the middle of the month in order to compare the change in win rate between the first and second halves of the month. We will revert changes that turn out significantly negative during this process.

Updates do not occur at a scheduled rate, but we try to keep them on the weekends whenever reasonable, and often at least update the current generation of Random Battles twice a month.
 
Last edited:
Status
Not open for further replies.
Back
Top