Spaces:
Running
Running
{ | |
"version": 3, | |
"sources": ["../../../../data/random-battles/gen9/teams.ts"], | |
"sourcesContent": ["import { Dex, toID } from '../../../sim/dex';\nimport { Utils } from '../../../lib';\nimport { PRNG, type PRNGSeed } from '../../../sim/prng';\nimport { type RuleTable } from '../../../sim/dex-formats';\nimport { Tags } from './../../tags';\nimport { Teams } from '../../../sim/teams';\n\nexport interface TeamData {\n\ttypeCount: { [k: string]: number };\n\ttypeComboCount: { [k: string]: number };\n\tbaseFormes: { [k: string]: number };\n\tmegaCount?: number;\n\tzCount?: number;\n\twantsTeraCount?: number;\n\thas: { [k: string]: number };\n\tforceResult: boolean;\n\tweaknesses: { [k: string]: number };\n\tresistances: { [k: string]: number };\n\tweather?: string;\n\teeveeLimCount?: number;\n\tgigantamax?: boolean;\n}\nexport interface BattleFactorySpecies {\n\tsets: BattleFactorySet[];\n\tweight: number;\n}\ninterface BattleFactorySet {\n\tspecies: string;\n\tweight: number;\n\titem: string[];\n\tability: string[];\n\tnature: string[];\n\tmoves: string[][];\n\tteraType: string[];\n\tgender?: string;\n\twantsTera?: boolean;\n\tevs?: Partial<StatsTable>;\n\tivs?: Partial<StatsTable>;\n\tshiny?: boolean;\n}\ninterface BSSFactorySet {\n\tspecies: string;\n\tweight: number;\n\titem: string[];\n\tability: string;\n\tnature: string;\n\tmoves: string[][];\n\tteraType: string[];\n\tgender?: string;\n\twantsTera?: boolean;\n\tevs: number[];\n\tivs?: number[];\n}\nexport class MoveCounter extends Utils.Multiset<string> {\n\tdamagingMoves: Set<Move>;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.damagingMoves = new Set();\n\t}\n}\n\ntype MoveEnforcementChecker = (\n\tmovePool: string[], moves: Set<string>, abilities: string[], types: string[],\n\tcounter: MoveCounter, species: Species, teamDetails: RandomTeamsTypes.TeamDetails,\n\tisLead: boolean, isDoubles: boolean, teraType: string, role: RandomTeamsTypes.Role,\n) => boolean;\n\n// Moves that restore HP:\nconst RECOVERY_MOVES = [\n\t'healorder', 'milkdrink', 'moonlight', 'morningsun', 'recover', 'roost', 'shoreup', 'slackoff', 'softboiled', 'strengthsap', 'synthesis',\n];\n// Moves that drop stats:\nconst CONTRARY_MOVES = [\n\t'armorcannon', 'closecombat', 'leafstorm', 'makeitrain', 'overheat', 'spinout', 'superpower', 'vcreate',\n];\n// Moves that boost Attack:\nconst PHYSICAL_SETUP = [\n\t'bellydrum', 'bulkup', 'coil', 'curse', 'dragondance', 'honeclaws', 'howl', 'meditate', 'poweruppunch', 'swordsdance', 'tidyup', 'victorydance',\n];\n// Moves which boost Special Attack:\nconst SPECIAL_SETUP = [\n\t'calmmind', 'chargebeam', 'geomancy', 'nastyplot', 'quiverdance', 'tailglow', 'takeheart', 'torchsong',\n];\n// Moves that boost Attack AND Special Attack:\nconst MIXED_SETUP = [\n\t'clangoroussoul', 'growth', 'happyhour', 'holdhands', 'noretreat', 'shellsmash', 'workup',\n];\n// Some moves that only boost Speed:\nconst SPEED_SETUP = [\n\t'agility', 'autotomize', 'flamecharge', 'rockpolish', 'snowscape', 'trailblaze',\n];\n// Conglomerate for ease of access\nconst SETUP = [\n\t'acidarmor', 'agility', 'autotomize', 'bellydrum', 'bulkup', 'calmmind', 'clangoroussoul', 'coil', 'cosmicpower', 'curse', 'dragondance',\n\t'flamecharge', 'growth', 'honeclaws', 'howl', 'irondefense', 'meditate', 'nastyplot', 'noretreat', 'poweruppunch', 'quiverdance',\n\t'rockpolish', 'shellsmash', 'shiftgear', 'swordsdance', 'tailglow', 'takeheart', 'tidyup', 'trailblaze', 'workup', 'victorydance',\n];\nconst SPEED_CONTROL = [\n\t'electroweb', 'glare', 'icywind', 'lowsweep', 'nuzzle', 'quash', 'tailwind', 'thunderwave', 'trickroom',\n];\n// Moves that shouldn't be the only STAB moves:\nconst NO_STAB = [\n\t'accelerock', 'aquajet', 'bounce', 'breakingswipe', 'bulletpunch', 'chatter', 'chloroblast', 'circlethrow', 'clearsmog', 'covet',\n\t'dragontail', 'doomdesire', 'electroweb', 'eruption', 'explosion', 'fakeout', 'feint', 'flamecharge', 'flipturn', 'futuresight',\n\t'grassyglide', 'iceshard', 'icywind', 'incinerate', 'infestation', 'machpunch', 'meteorbeam', 'mortalspin', 'nuzzle', 'pluck', 'pursuit',\n\t'quickattack', 'rapidspin', 'reversal', 'selfdestruct', 'shadowsneak', 'skydrop', 'snarl', 'strugglebug', 'suckerpunch', 'uturn',\n\t'vacuumwave', 'voltswitch', 'watershuriken', 'waterspout',\n];\n// Hazard-setting moves\nconst HAZARDS = [\n\t'spikes', 'stealthrock', 'stickyweb', 'toxicspikes',\n];\n// Protect and its variants\nconst PROTECT_MOVES = [\n\t'banefulbunker', 'burningbulwark', 'protect', 'silktrap', 'spikyshield',\n];\n// Moves that switch the user out\nconst PIVOT_MOVES = [\n\t'chillyreception', 'flipturn', 'partingshot', 'shedtail', 'teleport', 'uturn', 'voltswitch',\n];\n\n// Moves that should be paired together when possible\nconst MOVE_PAIRS = [\n\t['lightscreen', 'reflect'],\n\t['sleeptalk', 'rest'],\n\t['protect', 'wish'],\n\t['leechseed', 'protect'],\n\t['leechseed', 'substitute'],\n];\n\n/** Pokemon who always want priority STAB, and are fine with it as its only STAB move of that type */\nconst PRIORITY_POKEMON = [\n\t'breloom', 'brutebonnet', 'cacturne', 'honchkrow', 'mimikyu', 'ragingbolt', 'scizor',\n];\n\n/** Pokemon who should never be in the lead slot */\nconst NO_LEAD_POKEMON = [\n\t'Zacian', 'Zamazenta',\n];\nconst DOUBLES_NO_LEAD_POKEMON = [\n\t'Basculegion', 'Houndstone', 'Iron Bundle', 'Roaring Moon', 'Zacian', 'Zamazenta',\n];\n\nconst DEFENSIVE_TERA_BLAST_USERS = [\n\t'alcremie', 'bellossom', 'comfey', 'fezandipiti', 'florges', 'raikou',\n];\n\nfunction sereneGraceBenefits(move: Move) {\n\treturn move.secondary?.chance && move.secondary.chance > 20 && move.secondary.chance < 100;\n}\n\nexport class RandomTeams {\n\treadonly dex: ModdedDex;\n\tgen: number;\n\tfactoryTier: string;\n\tformat: Format;\n\tprng: PRNG;\n\tnoStab: string[];\n\treadonly maxTeamSize: number;\n\treadonly adjustLevel: number | null;\n\treadonly maxMoveCount: number;\n\treadonly forceMonotype: string | undefined;\n\treadonly forceTeraType: string | undefined;\n\n\t/**\n\t * Checkers for move enforcement based on types or other factors\n\t *\n\t * returns true to try to force the move type, false otherwise.\n\t */\n\tmoveEnforcementCheckers: { [k: string]: MoveEnforcementChecker };\n\n\t/** Used by .getPools() */\n\tprivate poolsCacheKey: [string | undefined, number | undefined, RuleTable | undefined, boolean] | undefined;\n\tprivate cachedPool: number[] | undefined;\n\tprivate cachedSpeciesPool: Species[] | undefined;\n\tprotected cachedStatusMoves: ID[];\n\n\tconstructor(format: Format | string, prng: PRNG | PRNGSeed | null) {\n\t\tformat = Dex.formats.get(format);\n\t\tthis.dex = Dex.forFormat(format);\n\t\tthis.gen = this.dex.gen;\n\t\tthis.noStab = NO_STAB;\n\n\t\tconst ruleTable = Dex.formats.getRuleTable(format);\n\t\tthis.maxTeamSize = ruleTable.maxTeamSize;\n\t\tthis.adjustLevel = ruleTable.adjustLevel;\n\t\tthis.maxMoveCount = ruleTable.maxMoveCount;\n\t\tconst forceMonotype = ruleTable.valueRules.get('forcemonotype');\n\t\tthis.forceMonotype = forceMonotype && this.dex.types.get(forceMonotype).exists ?\n\t\t\tthis.dex.types.get(forceMonotype).name : undefined;\n\t\tconst forceTeraType = ruleTable.valueRules.get('forceteratype');\n\t\tthis.forceTeraType = forceTeraType && this.dex.types.get(forceTeraType).exists ?\n\t\t\tthis.dex.types.get(forceTeraType).name : undefined;\n\n\t\tthis.factoryTier = '';\n\t\tthis.format = format;\n\t\tthis.prng = PRNG.get(prng);\n\n\t\tthis.moveEnforcementCheckers = {\n\t\t\tBug: (movePool, moves, abilities, types, counter) => (\n\t\t\t\tmovePool.includes('megahorn') || movePool.includes('xscissor') ||\n\t\t\t\t(!counter.get('Bug') && (types.includes('Electric') || types.includes('Psychic')))\n\t\t\t),\n\t\t\tDark: (\n\t\t\t\tmovePool, moves, abilities, types, counter, species, teamDetails, isLead, isDoubles, teraType, role\n\t\t\t) => {\n\t\t\t\tif (\n\t\t\t\t\tcounter.get('Dark') < 2 && PRIORITY_POKEMON.includes(species.id) && role === 'Wallbreaker'\n\t\t\t\t) return true;\n\t\t\t\treturn !counter.get('Dark');\n\t\t\t},\n\t\t\tDragon: (movePool, moves, abilities, types, counter) => !counter.get('Dragon'),\n\t\t\tElectric: (movePool, moves, abilities, types, counter) => !counter.get('Electric'),\n\t\t\tFairy: (movePool, moves, abilities, types, counter) => !counter.get('Fairy'),\n\t\t\tFighting: (movePool, moves, abilities, types, counter) => !counter.get('Fighting'),\n\t\t\tFire: (movePool, moves, abilities, types, counter, species) => !counter.get('Fire'),\n\t\t\tFlying: (movePool, moves, abilities, types, counter) => !counter.get('Flying'),\n\t\t\tGhost: (movePool, moves, abilities, types, counter) => !counter.get('Ghost'),\n\t\t\tGrass: (movePool, moves, abilities, types, counter, species) => (\n\t\t\t\t!counter.get('Grass') && (\n\t\t\t\t\tmovePool.includes('leafstorm') || species.baseStats.atk >= 100 ||\n\t\t\t\t\ttypes.includes('Electric') || abilities.includes('Seed Sower')\n\t\t\t\t)\n\t\t\t),\n\t\t\tGround: (movePool, moves, abilities, types, counter) => !counter.get('Ground'),\n\t\t\tIce: (movePool, moves, abilities, types, counter) => (\n\t\t\t\tmovePool.includes('freezedry') || movePool.includes('blizzard') || !counter.get('Ice')\n\t\t\t),\n\t\t\tNormal: (movePool, moves, types, counter) => (movePool.includes('boomburst') || movePool.includes('hypervoice')),\n\t\t\tPoison: (movePool, moves, abilities, types, counter) => {\n\t\t\t\tif (types.includes('Ground')) return false;\n\t\t\t\treturn !counter.get('Poison');\n\t\t\t},\n\t\t\tPsychic: (movePool, moves, abilities, types, counter, species, teamDetails, isLead, isDoubles) => {\n\t\t\t\tif ((isDoubles || species.id === 'bruxish') && movePool.includes('psychicfangs')) return true;\n\t\t\t\tif (species.id === 'hoopaunbound' && movePool.includes('psychic')) return true;\n\t\t\t\tif (['Dark', 'Steel', 'Water'].some(m => types.includes(m))) return false;\n\t\t\t\treturn !counter.get('Psychic');\n\t\t\t},\n\t\t\tRock: (movePool, moves, abilities, types, counter, species) => !counter.get('Rock') && species.baseStats.atk >= 80,\n\t\t\tSteel: (movePool, moves, abilities, types, counter, species, teamDetails, isLead, isDoubles) => (\n\t\t\t\t!counter.get('Steel') &&\n\t\t\t\t(isDoubles || species.baseStats.atk >= 90 || movePool.includes('gigatonhammer') || movePool.includes('makeitrain'))\n\t\t\t),\n\t\t\tWater: (movePool, moves, abilities, types, counter) => (!counter.get('Water') && !types.includes('Ground')),\n\t\t};\n\t\tthis.poolsCacheKey = undefined;\n\t\tthis.cachedPool = undefined;\n\t\tthis.cachedSpeciesPool = undefined;\n\t\tthis.cachedStatusMoves = this.dex.moves.all().filter(move => move.category === 'Status').map(move => move.id);\n\t}\n\n\tsetSeed(prng?: PRNG | PRNGSeed) {\n\t\tthis.prng = PRNG.get(prng);\n\t}\n\n\tgetTeam(options: PlayerOptions | null = null): PokemonSet[] {\n\t\tconst generatorName = (\n\t\t\ttypeof this.format.team === 'string' && this.format.team.startsWith('random')\n\t\t) ? this.format.team + 'Team' : '';\n\t\t// @ts-expect-error property access\n\t\treturn this[generatorName || 'randomTeam'](options);\n\t}\n\n\trandomChance(numerator: number, denominator: number) {\n\t\treturn this.prng.randomChance(numerator, denominator);\n\t}\n\n\tsample<T>(items: readonly T[]): T {\n\t\treturn this.prng.sample(items);\n\t}\n\n\tsampleIfArray<T>(item: T | T[]): T {\n\t\tif (Array.isArray(item)) {\n\t\t\treturn this.sample(item);\n\t\t}\n\t\treturn item;\n\t}\n\n\trandom(m?: number, n?: number) {\n\t\treturn this.prng.random(m, n);\n\t}\n\n\t/**\n\t * Remove an element from an unsorted array significantly faster\n\t * than .splice\n\t */\n\tfastPop(list: any[], index: number) {\n\t\t// If an array doesn't need to be in order, replacing the\n\t\t// element at the given index with the removed element\n\t\t// is much, much faster than using list.splice(index, 1).\n\t\tconst length = list.length;\n\t\tif (index < 0 || index >= list.length) {\n\t\t\t// sanity check\n\t\t\tthrow new Error(`Index ${index} out of bounds for given array`);\n\t\t}\n\n\t\tconst element = list[index];\n\t\tlist[index] = list[length - 1];\n\t\tlist.pop();\n\t\treturn element;\n\t}\n\n\t/**\n\t * Remove a random element from an unsorted array and return it.\n\t * Uses the battle's RNG if in a battle.\n\t */\n\tsampleNoReplace(list: any[]) {\n\t\tconst length = list.length;\n\t\tif (length === 0) return null;\n\t\tconst index = this.random(length);\n\t\treturn this.fastPop(list, index);\n\t}\n\n\t/**\n\t * Removes n random elements from an unsorted array and returns them.\n\t * If n is less than the array's length, randomly removes and returns all the elements\n\t * in the array (so the returned array could have length < n).\n\t */\n\tmultipleSamplesNoReplace<T>(list: T[], n: number): T[] {\n\t\tconst samples = [];\n\t\twhile (samples.length < n && list.length) {\n\t\t\tsamples.push(this.sampleNoReplace(list));\n\t\t}\n\n\t\treturn samples;\n\t}\n\n\t/**\n\t * Check if user has directly tried to ban/unban/restrict things in a custom battle.\n\t * Doesn't count bans nested inside other formats/rules.\n\t */\n\tprivate hasDirectCustomBanlistChanges() {\n\t\tif (this.format.ruleTable?.has('+pokemontag:cap')) return false;\n\t\tif (this.format.banlist.length || this.format.restricted.length || this.format.unbanlist.length) return true;\n\t\tif (!this.format.customRules) return false;\n\t\tfor (const rule of this.format.customRules) {\n\t\t\tfor (const banlistOperator of ['-', '+', '*']) {\n\t\t\t\tif (rule.startsWith(banlistOperator)) return true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Inform user when custom bans are unsupported in a team generator.\n\t */\n\tprotected enforceNoDirectCustomBanlistChanges() {\n\t\tif (this.hasDirectCustomBanlistChanges()) {\n\t\t\tthrow new Error(`Custom bans are not currently supported in ${this.format.name}.`);\n\t\t}\n\t}\n\n\t/**\n\t * Inform user when complex bans are unsupported in a team generator.\n\t */\n\tprotected enforceNoDirectComplexBans() {\n\t\tif (!this.format.customRules) return false;\n\t\tfor (const rule of this.format.customRules) {\n\t\t\tif (rule.includes('+') && !rule.startsWith('+')) {\n\t\t\t\tthrow new Error(`Complex bans are not currently supported in ${this.format.name}.`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Validate set element pool size is sufficient to support size requirements after simple bans.\n\t */\n\tprivate enforceCustomPoolSizeNoComplexBans(\n\t\teffectTypeName: string,\n\t\tbasicEffectPool: BasicEffect[],\n\t\trequiredCount: number,\n\t\trequiredCountExplanation: string\n\t) {\n\t\tif (basicEffectPool.length >= requiredCount) return;\n\t\tthrow new Error(`Legal ${effectTypeName} count is insufficient to support ${requiredCountExplanation} (${basicEffectPool.length} / ${requiredCount}).`);\n\t}\n\n\tqueryMoves(\n\t\tmoves: Set<string> | null,\n\t\tspecies: Species,\n\t\tteraType: string,\n\t\tabilities: string[],\n\t): MoveCounter {\n\t\t// This is primarily a helper function for random setbuilder functions.\n\t\tconst counter = new MoveCounter();\n\t\tconst types = species.types;\n\t\tif (!moves?.size) return counter;\n\n\t\tconst categories = { Physical: 0, Special: 0, Status: 0 };\n\n\t\t// Iterate through all moves we've chosen so far and keep track of what they do:\n\t\tfor (const moveid of moves) {\n\t\t\tconst move = this.dex.moves.get(moveid);\n\n\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\n\t\t\tif (move.damage || move.damageCallback) {\n\t\t\t\t// Moves that do a set amount of damage:\n\t\t\t\tcounter.add('damage');\n\t\t\t\tcounter.damagingMoves.add(move);\n\t\t\t} else {\n\t\t\t\t// Are Physical/Special/Status moves:\n\t\t\t\tcategories[move.category]++;\n\t\t\t}\n\t\t\t// Moves that have a low base power:\n\t\t\tif (moveid === 'lowkick' || (move.basePower && move.basePower <= 60 && moveid !== 'rapidspin')) {\n\t\t\t\tcounter.add('technician');\n\t\t\t}\n\t\t\t// Moves that hit up to 5 times:\n\t\t\tif (move.multihit && Array.isArray(move.multihit) && move.multihit[1] === 5) counter.add('skilllink');\n\t\t\tif (move.recoil || move.hasCrashDamage) counter.add('recoil');\n\t\t\tif (move.drain) counter.add('drain');\n\t\t\t// Moves which have a base power:\n\t\t\tif (move.basePower || move.basePowerCallback) {\n\t\t\t\tif (!this.noStab.includes(moveid) || PRIORITY_POKEMON.includes(species.id) && move.priority > 0) {\n\t\t\t\t\tcounter.add(moveType);\n\t\t\t\t\tif (types.includes(moveType)) counter.add('stab');\n\t\t\t\t\tif (teraType === moveType) counter.add('stabtera');\n\t\t\t\t\tcounter.damagingMoves.add(move);\n\t\t\t\t}\n\t\t\t\tif (move.flags['bite']) counter.add('strongjaw');\n\t\t\t\tif (move.flags['punch']) counter.add('ironfist');\n\t\t\t\tif (move.flags['sound']) counter.add('sound');\n\t\t\t\tif (move.priority > 0 || (moveid === 'grassyglide' && abilities.includes('Grassy Surge'))) {\n\t\t\t\t\tcounter.add('priority');\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Moves with secondary effects:\n\t\t\tif (move.secondary || move.hasSheerForce) {\n\t\t\t\tcounter.add('sheerforce');\n\t\t\t\tif (sereneGraceBenefits(move)) {\n\t\t\t\t\tcounter.add('serenegrace');\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Moves with low accuracy:\n\t\t\tif (move.accuracy && move.accuracy !== true && move.accuracy < 90) counter.add('inaccurate');\n\n\t\t\t// Moves that change stats:\n\t\t\tif (RECOVERY_MOVES.includes(moveid)) counter.add('recovery');\n\t\t\tif (CONTRARY_MOVES.includes(moveid)) counter.add('contrary');\n\t\t\tif (PHYSICAL_SETUP.includes(moveid)) counter.add('physicalsetup');\n\t\t\tif (SPECIAL_SETUP.includes(moveid)) counter.add('specialsetup');\n\t\t\tif (MIXED_SETUP.includes(moveid)) counter.add('mixedsetup');\n\t\t\tif (SPEED_SETUP.includes(moveid)) counter.add('speedsetup');\n\t\t\tif (SETUP.includes(moveid)) counter.add('setup');\n\t\t\tif (HAZARDS.includes(moveid)) counter.add('hazards');\n\t\t}\n\n\t\tcounter.set('Physical', Math.floor(categories['Physical']));\n\t\tcounter.set('Special', Math.floor(categories['Special']));\n\t\tcounter.set('Status', categories['Status']);\n\t\treturn counter;\n\t}\n\n\tcullMovePool(\n\t\ttypes: string[],\n\t\tmoves: Set<string>,\n\t\tabilities: string[],\n\t\tcounter: MoveCounter,\n\t\tmovePool: string[],\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tisDoubles: boolean,\n\t\tteraType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): void {\n\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t// If we have two unfilled moves and only one unpaired move, cull the unpaired move.\n\t\tif (moves.size === this.maxMoveCount - 2) {\n\t\t\tconst unpairedMoves = [...movePool];\n\t\t\tfor (const pair of MOVE_PAIRS) {\n\t\t\t\tif (movePool.includes(pair[0]) && movePool.includes(pair[1])) {\n\t\t\t\t\tthis.fastPop(unpairedMoves, unpairedMoves.indexOf(pair[0]));\n\t\t\t\t\tthis.fastPop(unpairedMoves, unpairedMoves.indexOf(pair[1]));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (unpairedMoves.length === 1) {\n\t\t\t\tthis.fastPop(movePool, movePool.indexOf(unpairedMoves[0]));\n\t\t\t}\n\t\t}\n\n\t\t// These moves are paired, and shouldn't appear if there is not room for them both.\n\t\tif (moves.size === this.maxMoveCount - 1) {\n\t\t\tfor (const pair of MOVE_PAIRS) {\n\t\t\t\tif (movePool.includes(pair[0]) && movePool.includes(pair[1])) {\n\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(pair[0]));\n\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(pair[1]));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Develop additional move lists\n\t\tconst statusMoves = this.cachedStatusMoves;\n\n\t\t// Team-based move culls\n\t\tif (teamDetails.screens) {\n\t\t\tif (movePool.includes('auroraveil')) this.fastPop(movePool, movePool.indexOf('auroraveil'));\n\t\t\tif (movePool.length >= this.maxMoveCount + 2) {\n\t\t\t\tif (movePool.includes('reflect')) this.fastPop(movePool, movePool.indexOf('reflect'));\n\t\t\t\tif (movePool.includes('lightscreen')) this.fastPop(movePool, movePool.indexOf('lightscreen'));\n\t\t\t}\n\t\t}\n\t\tif (teamDetails.stickyWeb) {\n\t\t\tif (movePool.includes('stickyweb')) this.fastPop(movePool, movePool.indexOf('stickyweb'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.stealthRock) {\n\t\t\tif (movePool.includes('stealthrock')) this.fastPop(movePool, movePool.indexOf('stealthrock'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.defog || teamDetails.rapidSpin) {\n\t\t\tif (movePool.includes('defog')) this.fastPop(movePool, movePool.indexOf('defog'));\n\t\t\tif (movePool.includes('rapidspin')) this.fastPop(movePool, movePool.indexOf('rapidspin'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.toxicSpikes) {\n\t\t\tif (movePool.includes('toxicspikes')) this.fastPop(movePool, movePool.indexOf('toxicspikes'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.spikes && teamDetails.spikes >= 2) {\n\t\t\tif (movePool.includes('spikes')) this.fastPop(movePool, movePool.indexOf('spikes'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\t\tif (teamDetails.statusCure) {\n\t\t\tif (movePool.includes('healbell')) this.fastPop(movePool, movePool.indexOf('healbell'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t}\n\n\t\tif (isDoubles) {\n\t\t\tconst doublesIncompatiblePairs = [\n\t\t\t\t// In order of decreasing generalizability\n\t\t\t\t[SPEED_CONTROL, SPEED_CONTROL],\n\t\t\t\t[HAZARDS, HAZARDS],\n\t\t\t\t['rockslide', 'stoneedge'],\n\t\t\t\t[SETUP, ['fakeout', 'helpinghand']],\n\t\t\t\t[PROTECT_MOVES, 'wideguard'],\n\t\t\t\t[['fierydance', 'fireblast'], 'heatwave'],\n\t\t\t\t['dazzlinggleam', ['fleurcannon', 'moonblast']],\n\t\t\t\t['poisongas', ['toxicspikes', 'willowisp']],\n\t\t\t\t[RECOVERY_MOVES, 'healpulse'],\n\t\t\t\t['lifedew', 'healpulse'],\n\t\t\t\t['haze', 'icywind'],\n\t\t\t\t[['hydropump', 'muddywater'], ['muddywater', 'scald']],\n\t\t\t\t['disable', 'encore'],\n\t\t\t\t['freezedry', 'icebeam'],\n\t\t\t\t['energyball', 'leafstorm'],\n\t\t\t\t['wildcharge', 'thunderbolt'],\n\t\t\t\t['earthpower', 'sandsearstorm'],\n\t\t\t\t['coaching', ['helpinghand', 'howl']],\n\t\t\t];\n\n\t\t\tfor (const pair of doublesIncompatiblePairs) this.incompatibleMoves(moves, movePool, pair[0], pair[1]);\n\n\t\t\tif (role !== 'Offensive Protect') this.incompatibleMoves(moves, movePool, PROTECT_MOVES, ['flipturn', 'uturn']);\n\t\t}\n\n\t\t// General incompatibilities\n\t\tconst incompatiblePairs = [\n\t\t\t// These moves don't mesh well with other aspects of the set\n\t\t\t[statusMoves, ['healingwish', 'switcheroo', 'trick']],\n\t\t\t[SETUP, PIVOT_MOVES],\n\t\t\t[SETUP, HAZARDS],\n\t\t\t[SETUP, ['defog', 'nuzzle', 'toxic', 'yawn', 'haze']],\n\t\t\t[PHYSICAL_SETUP, PHYSICAL_SETUP],\n\t\t\t[SPECIAL_SETUP, 'thunderwave'],\n\t\t\t['substitute', PIVOT_MOVES],\n\t\t\t[SPEED_SETUP, ['aquajet', 'rest', 'trickroom']],\n\t\t\t['curse', ['irondefense', 'rapidspin']],\n\t\t\t['dragondance', 'dracometeor'],\n\t\t\t['yawn', 'roar'],\n\n\t\t\t// These attacks are redundant with each other\n\t\t\t[['psychic', 'psychicnoise'], ['psyshock', 'psychicnoise']],\n\t\t\t['surf', 'hydropump'],\n\t\t\t['liquidation', 'wavecrash'],\n\t\t\t['aquajet', 'flipturn'],\n\t\t\t['gigadrain', 'leafstorm'],\n\t\t\t['powerwhip', 'hornleech'],\n\t\t\t[['airslash', 'bravebird', 'hurricane'], ['airslash', 'bravebird', 'hurricane']],\n\t\t\t['knockoff', 'foulplay'],\n\t\t\t['throatchop', ['crunch', 'lashout']],\n\t\t\t['doubleedge', ['bodyslam', 'headbutt']],\n\t\t\t['fireblast', ['fierydance', 'flamethrower']],\n\t\t\t['lavaplume', 'magmastorm'],\n\t\t\t['thunderpunch', 'wildcharge'],\n\t\t\t['thunderbolt', 'discharge'],\n\t\t\t['gunkshot', ['direclaw', 'poisonjab', 'sludgebomb']],\n\t\t\t['aurasphere', 'focusblast'],\n\t\t\t['closecombat', 'drainpunch'],\n\t\t\t['bugbite', 'pounce'],\n\t\t\t[['dragonpulse', 'spacialrend'], 'dracometeor'],\n\t\t\t['heavyslam', 'flashcannon'],\n\t\t\t['alluringvoice', 'dazzlinggleam'],\n\n\t\t\t// These status moves are redundant with each other\n\t\t\t['taunt', 'disable'],\n\t\t\t[['thunderwave', 'toxic'], ['thunderwave', 'willowisp']],\n\t\t\t[['thunderwave', 'toxic', 'willowisp'], 'toxicspikes'],\n\n\t\t\t// This space reserved for assorted hardcodes that otherwise make little sense out of context\n\t\t\t// Landorus and Thundurus\n\t\t\t['nastyplot', ['rockslide', 'knockoff']],\n\t\t\t// Persian\n\t\t\t['switcheroo', 'fakeout'],\n\t\t\t// Amoonguss, though this can work well as a general rule later\n\t\t\t['toxic', 'clearsmog'],\n\t\t\t// Chansey and Blissey\n\t\t\t['healbell', 'stealthrock'],\n\t\t\t// Azelf and Zoroarks\n\t\t\t['trick', 'uturn'],\n\t\t\t// Araquanid\n\t\t\t['mirrorcoat', 'hydropump'],\n\t\t];\n\n\t\tfor (const pair of incompatiblePairs) this.incompatibleMoves(moves, movePool, pair[0], pair[1]);\n\n\t\tif (!types.includes('Ice')) this.incompatibleMoves(moves, movePool, 'icebeam', 'icywind');\n\n\t\tif (!isDoubles) this.incompatibleMoves(moves, movePool, 'taunt', 'encore');\n\n\t\tif (!types.includes('Dark') && teraType !== 'Dark') this.incompatibleMoves(moves, movePool, 'knockoff', 'suckerpunch');\n\n\t\tif (!abilities.includes('Prankster')) this.incompatibleMoves(moves, movePool, 'thunderwave', 'yawn');\n\n\t\t// This space reserved for assorted hardcodes that otherwise make little sense out of context\n\t\tif (species.id === 'barraskewda') {\n\t\t\tthis.incompatibleMoves(moves, movePool, ['psychicfangs', 'throatchop'], ['poisonjab', 'throatchop']);\n\t\t}\n\t\tif (species.id === 'cyclizar') this.incompatibleMoves(moves, movePool, 'taunt', 'knockoff');\n\t\tif (species.id === 'camerupt') this.incompatibleMoves(moves, movePool, 'roar', 'willowisp');\n\t\tif (species.id === 'coalossal') this.incompatibleMoves(moves, movePool, 'flamethrower', 'overheat');\n\t}\n\n\t// Checks for and removes incompatible moves, starting with the first move in movesA.\n\tincompatibleMoves(\n\t\tmoves: Set<string>,\n\t\tmovePool: string[],\n\t\tmovesA: string | string[],\n\t\tmovesB: string | string[],\n\t): void {\n\t\tconst moveArrayA = (Array.isArray(movesA)) ? movesA : [movesA];\n\t\tconst moveArrayB = (Array.isArray(movesB)) ? movesB : [movesB];\n\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\tfor (const moveid1 of moves) {\n\t\t\tif (moveArrayB.includes(moveid1)) {\n\t\t\t\tfor (const moveid2 of moveArrayA) {\n\t\t\t\t\tif (moveid1 !== moveid2 && movePool.includes(moveid2)) {\n\t\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(moveid2));\n\t\t\t\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (moveArrayA.includes(moveid1)) {\n\t\t\t\tfor (const moveid2 of moveArrayB) {\n\t\t\t\t\tif (moveid1 !== moveid2 && movePool.includes(moveid2)) {\n\t\t\t\t\t\tthis.fastPop(movePool, movePool.indexOf(moveid2));\n\t\t\t\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Adds a move to the moveset, returns the MoveCounter\n\taddMove(\n\t\tmove: string,\n\t\tmoves: Set<string>,\n\t\ttypes: string[],\n\t\tabilities: string[],\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tisDoubles: boolean,\n\t\tmovePool: string[],\n\t\tteraType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): MoveCounter {\n\t\tmoves.add(move);\n\t\tthis.fastPop(movePool, movePool.indexOf(move));\n\t\tconst counter = this.queryMoves(moves, species, teraType, abilities);\n\t\tthis.cullMovePool(types, moves, abilities, counter, movePool, teamDetails, species, isLead, isDoubles, teraType, role);\n\t\treturn counter;\n\t}\n\n\t// Returns the type of a given move for STAB/coverage enforcement purposes\n\tgetMoveType(move: Move, species: Species, abilities: string[], teraType: string): string {\n\t\tif (move.id === 'terablast') return teraType;\n\t\tif (['judgment', 'revelationdance'].includes(move.id)) return species.types[0];\n\n\t\tif (move.name === \"Raging Bull\" && species.name.startsWith(\"Tauros-Paldea\")) {\n\t\t\tif (species.name.endsWith(\"Combat\")) return \"Fighting\";\n\t\t\tif (species.name.endsWith(\"Blaze\")) return \"Fire\";\n\t\t\tif (species.name.endsWith(\"Aqua\")) return \"Water\";\n\t\t}\n\n\t\tif (move.name === \"Ivy Cudgel\" && species.name.startsWith(\"Ogerpon\")) {\n\t\t\tif (species.name.endsWith(\"Wellspring\")) return \"Water\";\n\t\t\tif (species.name.endsWith(\"Hearthflame\")) return \"Fire\";\n\t\t\tif (species.name.endsWith(\"Cornerstone\")) return \"Rock\";\n\t\t}\n\n\t\tconst moveType = move.type;\n\t\tif (moveType === 'Normal') {\n\t\t\tif (abilities.includes('Aerilate')) return 'Flying';\n\t\t\tif (abilities.includes('Galvanize')) return 'Electric';\n\t\t\tif (abilities.includes('Pixilate')) return 'Fairy';\n\t\t\tif (abilities.includes('Refrigerate')) return 'Ice';\n\t\t}\n\t\treturn moveType;\n\t}\n\n\t// Generate random moveset for a given species, role, tera type.\n\trandomMoveset(\n\t\ttypes: string[],\n\t\tabilities: string[],\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tisDoubles: boolean,\n\t\tmovePool: string[],\n\t\tteraType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): Set<string> {\n\t\tconst moves = new Set<string>();\n\t\tlet counter = this.queryMoves(moves, species, teraType, abilities);\n\t\tthis.cullMovePool(types, moves, abilities, counter, movePool, teamDetails, species, isLead, isDoubles, teraType, role);\n\n\t\t// If there are only four moves, add all moves and return early\n\t\tif (movePool.length <= this.maxMoveCount) {\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tmoves.add(moveid);\n\t\t\t}\n\t\t\treturn moves;\n\t\t}\n\n\t\tconst runEnforcementChecker = (checkerName: string) => {\n\t\t\tif (!this.moveEnforcementCheckers[checkerName]) return false;\n\t\t\treturn this.moveEnforcementCheckers[checkerName](\n\t\t\t\tmovePool, moves, abilities, types, counter, species, teamDetails, isLead, isDoubles, teraType, role\n\t\t\t);\n\t\t};\n\n\t\tif (role === 'Tera Blast user') {\n\t\t\tcounter = this.addMove('terablast', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\tmovePool, teraType, role);\n\t\t}\n\t\t// Add required move (e.g. Relic Song for Meloetta-P)\n\t\tif (species.requiredMove) {\n\t\t\tconst move = this.dex.moves.get(species.requiredMove).id;\n\t\t\tcounter = this.addMove(move, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\tmovePool, teraType, role);\n\t\t}\n\n\t\t// Add other moves you really want to have, e.g. STAB, recovery, setup.\n\n\t\t// Enforce Facade if Guts is a possible ability\n\t\tif (movePool.includes('facade') && abilities.includes('Guts')) {\n\t\t\tcounter = this.addMove('facade', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\tmovePool, teraType, role);\n\t\t}\n\n\t\t// Enforce Night Shade, Revelation Dance, Revival Blessing, and Sticky Web\n\t\tfor (const moveid of ['nightshade', 'revelationdance', 'revivalblessing', 'stickyweb']) {\n\t\t\tif (movePool.includes(moveid)) {\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce Trick Room on Doubles Wallbreaker\n\t\tif (movePool.includes('trickroom') && role === 'Doubles Wallbreaker') {\n\t\t\tcounter = this.addMove('trickroom', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\tmovePool, teraType, role);\n\t\t}\n\n\t\t// Enforce hazard removal on Bulky Support if the team doesn't already have it\n\t\tif (role === 'Bulky Support' && !teamDetails.defog && !teamDetails.rapidSpin) {\n\t\t\tif (movePool.includes('rapidspin')) {\n\t\t\t\tcounter = this.addMove('rapidspin', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t\tif (movePool.includes('defog')) {\n\t\t\t\tcounter = this.addMove('defog', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce Aurora Veil if the team doesn't already have screens\n\t\tif (!teamDetails.screens && movePool.includes('auroraveil')) {\n\t\t\tcounter = this.addMove('auroraveil', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\tmovePool, teraType, role);\n\t\t}\n\n\t\t// Enforce Knock Off on pure Normal- and Fighting-types in singles\n\t\tif (!isDoubles && types.length === 1 && (types.includes('Normal') || types.includes('Fighting'))) {\n\t\t\tif (movePool.includes('knockoff')) {\n\t\t\t\tcounter = this.addMove('knockoff', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce Spore on Smeargle\n\t\tif (species.id === 'smeargle') {\n\t\t\tif (movePool.includes('spore')) {\n\t\t\t\tcounter = this.addMove('spore', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce moves in doubles\n\t\tif (isDoubles) {\n\t\t\tconst doublesEnforcedMoves = ['mortalspin', 'spore'];\n\t\t\tfor (const moveid of doublesEnforcedMoves) {\n\t\t\t\tif (movePool.includes(moveid)) {\n\t\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\t\tmovePool, teraType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Enforce Fake Out on slow Pokemon\n\t\t\tif (movePool.includes('fakeout') && species.baseStats.spe <= 50) {\n\t\t\t\tcounter = this.addMove('fakeout', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t\t// Enforce Tailwind on Prankster and Gale Wings users\n\t\t\tif (movePool.includes('tailwind') && (abilities.includes('Prankster') || abilities.includes('Gale Wings'))) {\n\t\t\t\tcounter = this.addMove('tailwind', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t\t// Enforce Thunder Wave on Prankster users as well\n\t\t\tif (movePool.includes('thunderwave') && abilities.includes('Prankster')) {\n\t\t\t\tcounter = this.addMove('thunderwave', moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce STAB priority\n\t\tif (\n\t\t\t['Bulky Attacker', 'Bulky Setup', 'Wallbreaker', 'Doubles Wallbreaker'].includes(role) ||\n\t\t\tPRIORITY_POKEMON.includes(species.id)\n\t\t) {\n\t\t\tconst priorityMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\n\t\t\t\tif (\n\t\t\t\t\ttypes.includes(moveType) && (move.priority > 0 || (moveid === 'grassyglide' && abilities.includes('Grassy Surge'))) &&\n\t\t\t\t\t(move.basePower || move.basePowerCallback)\n\t\t\t\t) {\n\t\t\t\t\tpriorityMoves.push(moveid);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (priorityMoves.length) {\n\t\t\t\tconst moveid = this.sample(priorityMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce STAB\n\t\tfor (const type of types) {\n\t\t\t// Check if a STAB move of that type should be required\n\t\t\tconst stabMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower || move.basePowerCallback) && type === moveType) {\n\t\t\t\t\tstabMoves.push(moveid);\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (runEnforcementChecker(type)) {\n\t\t\t\tif (!stabMoves.length) break;\n\t\t\t\tconst moveid = this.sampleNoReplace(stabMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce Tera STAB\n\t\tif (!counter.get('stabtera') && !['Bulky Support', 'Doubles Support'].includes(role)) {\n\t\t\tconst stabMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower || move.basePowerCallback) && teraType === moveType) {\n\t\t\t\t\tstabMoves.push(moveid);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (stabMoves.length) {\n\t\t\t\tconst moveid = this.sample(stabMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// If no STAB move was added, add a STAB move\n\t\tif (!counter.get('stab')) {\n\t\t\tconst stabMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower || move.basePowerCallback) && types.includes(moveType)) {\n\t\t\t\t\tstabMoves.push(moveid);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (stabMoves.length) {\n\t\t\t\tconst moveid = this.sample(stabMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce recovery\n\t\tif (['Bulky Support', 'Bulky Attacker', 'Bulky Setup'].includes(role)) {\n\t\t\tconst recoveryMoves = movePool.filter(moveid => RECOVERY_MOVES.includes(moveid));\n\t\t\tif (recoveryMoves.length) {\n\t\t\t\tconst moveid = this.sample(recoveryMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce pivoting moves on AV Pivot\n\t\tif (role === 'AV Pivot') {\n\t\t\tconst pivotMoves = movePool.filter(moveid => ['uturn', 'voltswitch'].includes(moveid));\n\t\t\tif (pivotMoves.length) {\n\t\t\t\tconst moveid = this.sample(pivotMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce setup\n\t\tif (role.includes('Setup') || role === 'Tera Blast user') {\n\t\t\t// First, try to add a non-Speed setup move\n\t\t\tconst nonSpeedSetupMoves = movePool.filter(moveid => SETUP.includes(moveid) && !SPEED_SETUP.includes(moveid));\n\t\t\tif (nonSpeedSetupMoves.length) {\n\t\t\t\tconst moveid = this.sample(nonSpeedSetupMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t} else {\n\t\t\t\t// No non-Speed setup moves, so add any (Speed) setup move\n\t\t\t\tconst setupMoves = movePool.filter(moveid => SETUP.includes(moveid));\n\t\t\t\tif (setupMoves.length) {\n\t\t\t\t\tconst moveid = this.sample(setupMoves);\n\t\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\t\tmovePool, teraType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Enforce redirecting moves and Fake Out on Doubles Support\n\t\tif (role === 'Doubles Support') {\n\t\t\tfor (const moveid of ['fakeout', 'followme', 'ragepowder']) {\n\t\t\t\tif (movePool.includes(moveid)) {\n\t\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\t\tmovePool, teraType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst speedControl = movePool.filter(moveid => SPEED_CONTROL.includes(moveid));\n\t\t\tif (speedControl.length) {\n\t\t\t\tconst moveid = this.sample(speedControl);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce Protect\n\t\tif (role.includes('Protect')) {\n\t\t\tconst protectMoves = movePool.filter(moveid => PROTECT_MOVES.includes(moveid));\n\t\t\tif (protectMoves.length) {\n\t\t\t\tconst moveid = this.sample(protectMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce a move not on the noSTAB list\n\t\tif (!counter.damagingMoves.size) {\n\t\t\t// Choose an attacking move\n\t\t\tconst attackingMoves = [];\n\t\t\tfor (const moveid of movePool) {\n\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\tif (!this.noStab.includes(moveid) && (move.category !== 'Status')) attackingMoves.push(moveid);\n\t\t\t}\n\t\t\tif (attackingMoves.length) {\n\t\t\t\tconst moveid = this.sample(attackingMoves);\n\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\tmovePool, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Enforce coverage move\n\t\tif (!['AV Pivot', 'Fast Support', 'Bulky Support', 'Bulky Protect', 'Doubles Support'].includes(role)) {\n\t\t\tif (counter.damagingMoves.size === 1) {\n\t\t\t\t// Find the type of the current attacking move\n\t\t\t\tconst currentAttackType = counter.damagingMoves.values().next().value!.type;\n\t\t\t\t// Choose an attacking move that is of different type to the current single attack\n\t\t\t\tconst coverageMoves = [];\n\t\t\t\tfor (const moveid of movePool) {\n\t\t\t\t\tconst move = this.dex.moves.get(moveid);\n\t\t\t\t\tconst moveType = this.getMoveType(move, species, abilities, teraType);\n\t\t\t\t\tif (!this.noStab.includes(moveid) && (move.basePower || move.basePowerCallback)) {\n\t\t\t\t\t\tif (currentAttackType !== moveType) coverageMoves.push(moveid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (coverageMoves.length) {\n\t\t\t\t\tconst moveid = this.sample(coverageMoves);\n\t\t\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\t\tmovePool, teraType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add (moves.size < this.maxMoveCount) as a condition if moves is getting larger than 4 moves.\n\t\t// If you want moves to be favored but not required, add something like && this.randomChance(1, 2) to your condition.\n\n\t\t// Choose remaining moves randomly from movepool and add them to moves list:\n\t\twhile (moves.size < this.maxMoveCount && movePool.length) {\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) {\n\t\t\t\tfor (const moveid of movePool) {\n\t\t\t\t\tmoves.add(moveid);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst moveid = this.sample(movePool);\n\t\t\tcounter = this.addMove(moveid, moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\tmovePool, teraType, role);\n\t\t\tfor (const pair of MOVE_PAIRS) {\n\t\t\t\tif (moveid === pair[0] && movePool.includes(pair[1])) {\n\t\t\t\t\tcounter = this.addMove(pair[1], moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\t\tmovePool, teraType, role);\n\t\t\t\t}\n\t\t\t\tif (moveid === pair[1] && movePool.includes(pair[0])) {\n\t\t\t\t\tcounter = this.addMove(pair[0], moves, types, abilities, teamDetails, species, isLead, isDoubles,\n\t\t\t\t\t\tmovePool, teraType, role);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn moves;\n\t}\n\n\tshouldCullAbility(\n\t\tability: string,\n\t\ttypes: string[],\n\t\tmoves: Set<string>,\n\t\tabilities: string[],\n\t\tcounter: MoveCounter,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tisDoubles: boolean,\n\t\tteraType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): boolean {\n\t\tswitch (ability) {\n\t\t// Abilities which are primarily useful for certain moves or with team support\n\t\tcase 'Chlorophyll': case 'Solar Power':\n\t\t\treturn !teamDetails.sun;\n\t\tcase 'Defiant':\n\t\t\treturn (species.id === 'thundurus' && !!counter.get('Status'));\n\t\tcase 'Hydration': case 'Swift Swim':\n\t\t\treturn !teamDetails.rain;\n\t\tcase 'Iron Fist': case 'Skill Link':\n\t\t\treturn !counter.get(toID(ability));\n\t\tcase 'Overgrow':\n\t\t\treturn !counter.get('Grass');\n\t\tcase 'Prankster':\n\t\t\treturn !counter.get('Status');\n\t\tcase 'Sand Force': case 'Sand Rush':\n\t\t\treturn !teamDetails.sand;\n\t\tcase 'Slush Rush':\n\t\t\treturn !teamDetails.snow;\n\t\tcase 'Swarm':\n\t\t\treturn !counter.get('Bug');\n\t\tcase 'Torrent':\n\t\t\treturn (!counter.get('Water') && !moves.has('flipturn'));\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tgetAbility(\n\t\ttypes: string[],\n\t\tmoves: Set<string>,\n\t\tabilities: string[],\n\t\tcounter: MoveCounter,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tisDoubles: boolean,\n\t\tteraType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): string {\n\t\t// ffa abilities that differ from doubles\n\t\tif (this.format.gameType === 'freeforall') {\n\t\t\tif (species.id === 'bellossom') return 'Chlorophyll';\n\t\t\tif (species.id === 'sinistcha') return 'Heatproof';\n\t\t\tif (abilities.length === 1 && abilities[0] === 'Telepathy') {\n\t\t\t\treturn species.id === 'oranguru' ? 'Inner Focus' : 'Pressure';\n\t\t\t}\n\t\t\tif (species.id === 'duraludon') return 'Light Metal';\n\t\t\tif (species.id === 'clefairy') return 'Magic Guard';\n\t\t\tif (species.id === 'blissey') return 'Natural Cure';\n\t\t\tif (species.id === 'barraskewda') return 'Swift Swim';\n\t\t}\n\n\t\tif (abilities.length <= 1) return abilities[0];\n\n\t\t// Hard-code abilities here\n\t\tif (species.id === 'drifblim') return moves.has('defog') ? 'Aftermath' : 'Unburden';\n\t\tif (abilities.includes('Flash Fire') && this.dex.getEffectiveness('Fire', teraType) >= 1) return 'Flash Fire';\n\t\tif (species.id === 'hitmonchan' && counter.get('ironfist')) return 'Iron Fist';\n\t\tif ((species.id === 'thundurus' || species.id === 'tornadus') && !counter.get('Physical')) return 'Prankster';\n\t\tif (species.id === 'swampert' && (counter.get('Water') || moves.has('flipturn'))) return 'Torrent';\n\t\tif (species.id === 'toucannon' && counter.get('skilllink')) return 'Skill Link';\n\t\tif (abilities.includes('Slush Rush') && moves.has('snowscape')) return 'Slush Rush';\n\t\tif (species.id === 'golduck' && teamDetails.rain) return 'Swift Swim';\n\n\t\tconst abilityAllowed: string[] = [];\n\t\t// Obtain a list of abilities that are allowed (not culled)\n\t\tfor (const ability of abilities) {\n\t\t\tif (!this.shouldCullAbility(\n\t\t\t\tability, types, moves, abilities, counter, teamDetails, species, isLead, isDoubles, teraType, role\n\t\t\t)) {\n\t\t\t\tabilityAllowed.push(ability);\n\t\t\t}\n\t\t}\n\n\t\t// Pick a random allowed ability\n\t\tif (abilityAllowed.length >= 1) return this.sample(abilityAllowed);\n\n\t\t// If all abilities are rejected, prioritize weather abilities over non-weather abilities\n\t\tif (!abilityAllowed.length) {\n\t\t\tconst weatherAbilities = abilities.filter(\n\t\t\t\ta => ['Chlorophyll', 'Hydration', 'Sand Force', 'Sand Rush', 'Slush Rush', 'Solar Power', 'Swift Swim'].includes(a)\n\t\t\t);\n\t\t\tif (weatherAbilities.length) return this.sample(weatherAbilities);\n\t\t}\n\n\t\t// Pick a random ability\n\t\treturn this.sample(abilities);\n\t}\n\n\tgetPriorityItem(\n\t\tability: string,\n\t\ttypes: string[],\n\t\tmoves: Set<string>,\n\t\tcounter: MoveCounter,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tisDoubles: boolean,\n\t\tteraType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t) {\n\t\tif (!isDoubles) {\n\t\t\tif (role === 'Fast Bulky Setup' && (ability === 'Quark Drive' || ability === 'Protosynthesis')) {\n\t\t\t\treturn 'Booster Energy';\n\t\t\t}\n\t\t\tif (species.id === 'lokix') {\n\t\t\t\treturn (role === 'Fast Attacker') ? 'Silver Powder' : 'Life Orb';\n\t\t\t}\n\t\t}\n\t\tif (species.requiredItems) {\n\t\t\t// Z-Crystals aren't available in Gen 9, so require Plates\n\t\t\tif (species.baseSpecies === 'Arceus') {\n\t\t\t\treturn species.requiredItems[0];\n\t\t\t}\n\t\t\treturn this.sample(species.requiredItems);\n\t\t}\n\t\tif (role === 'AV Pivot') return 'Assault Vest';\n\t\tif (species.id === 'pikachu') return 'Light Ball';\n\t\tif (species.id === 'regieleki') return 'Magnet';\n\t\tif (types.includes('Normal') && moves.has('doubleedge') && moves.has('fakeout')) return 'Silk Scarf';\n\t\tif (\n\t\t\tspecies.id === 'froslass' || moves.has('populationbomb') ||\n\t\t\t(ability === 'Hustle' && counter.get('setup') && !isDoubles && this.randomChance(1, 2))\n\t\t) return 'Wide Lens';\n\t\tif (species.id === 'smeargle' && !isDoubles) return 'Focus Sash';\n\t\tif (moves.has('clangoroussoul') || (species.id === 'toxtricity' && moves.has('shiftgear'))) return 'Throat Spray';\n\t\tif (\n\t\t\t(species.baseSpecies === 'Magearna' && role === 'Tera Blast user') ||\n\t\t\tspecies.id === 'necrozmaduskmane' || (species.id === 'calyrexice' && isDoubles)\n\t\t) return 'Weakness Policy';\n\t\tif (['dragonenergy', 'lastrespects', 'waterspout'].some(m => moves.has(m))) return 'Choice Scarf';\n\t\tif (\n\t\t\t!isDoubles && (ability === 'Imposter' || (species.id === 'magnezone' && role === 'Fast Attacker'))\n\t\t) return 'Choice Scarf';\n\t\tif (species.id === 'rampardos' && (role === 'Fast Attacker' || isDoubles)) return 'Choice Scarf';\n\t\tif (species.id === 'palkia' && counter.get('Special') < 4) return 'Lustrous Orb';\n\t\tif (\n\t\t\tmoves.has('courtchange') ||\n\t\t\t!isDoubles && (species.id === 'luvdisc' || (species.id === 'terapagos' && !moves.has('rest')))\n\t\t) return 'Heavy-Duty Boots';\n\t\tif (moves.has('bellydrum') && moves.has('substitute')) return 'Salac Berry';\n\t\tif (\n\t\t\t['Cheek Pouch', 'Cud Chew', 'Harvest', 'Ripen'].some(m => ability === m) ||\n\t\t\tmoves.has('bellydrum') || moves.has('filletaway')\n\t\t) {\n\t\t\treturn 'Sitrus Berry';\n\t\t}\n\t\tif (['healingwish', 'switcheroo', 'trick'].some(m => moves.has(m))) {\n\t\t\tif (\n\t\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 108 &&\n\t\t\t\trole !== 'Wallbreaker' && role !== 'Doubles Wallbreaker' && !counter.get('priority')\n\t\t\t) {\n\t\t\t\treturn 'Choice Scarf';\n\t\t\t} else {\n\t\t\t\treturn (counter.get('Physical') > counter.get('Special')) ? 'Choice Band' : 'Choice Specs';\n\t\t\t}\n\t\t}\n\t\tif (counter.get('Status') && (species.name === 'Latias' || species.name === 'Latios')) return 'Soul Dew';\n\t\tif (species.id === 'scyther' && !isDoubles) return (isLead && !moves.has('uturn')) ? 'Eviolite' : 'Heavy-Duty Boots';\n\t\tif (ability === 'Poison Heal' || ability === 'Quick Feet') return 'Toxic Orb';\n\t\tif (species.nfe) return 'Eviolite';\n\t\tif ((ability === 'Guts' || moves.has('facade')) && !moves.has('sleeptalk')) {\n\t\t\treturn (types.includes('Fire') || ability === 'Toxic Boost') ? 'Toxic Orb' : 'Flame Orb';\n\t\t}\n\t\tif (ability === 'Magic Guard' || (ability === 'Sheer Force' && counter.get('sheerforce'))) return 'Life Orb';\n\t\tif (ability === 'Anger Shell') return this.sample(['Rindo Berry', 'Passho Berry', 'Scope Lens', 'Sitrus Berry']);\n\t\tif (moves.has('dragondance') && isDoubles) return 'Clear Amulet';\n\t\tif (counter.get('skilllink') && ability !== 'Skill Link' && species.id !== 'breloom') return 'Loaded Dice';\n\t\tif (ability === 'Unburden') {\n\t\t\treturn (moves.has('closecombat') || moves.has('leafstorm')) ? 'White Herb' : 'Sitrus Berry';\n\t\t}\n\t\tif (moves.has('shellsmash') && ability !== 'Weak Armor') return 'White Herb';\n\t\tif (moves.has('meteorbeam') || (moves.has('electroshot') && !teamDetails.rain)) return 'Power Herb';\n\t\tif (moves.has('acrobatics') && ability !== 'Protosynthesis') return '';\n\t\tif (moves.has('auroraveil') || moves.has('lightscreen') && moves.has('reflect')) return 'Light Clay';\n\t\tif (ability === 'Gluttony') return `${this.sample(['Aguav', 'Figy', 'Iapapa', 'Mago', 'Wiki'])} Berry`;\n\t\tif (\n\t\t\tmoves.has('rest') && !moves.has('sleeptalk') &&\n\t\t\tability !== 'Natural Cure' && ability !== 'Shed Skin'\n\t\t) {\n\t\t\treturn 'Chesto Berry';\n\t\t}\n\t\tif (\n\t\t\tspecies.id !== 'yanmega' &&\n\t\t\tthis.dex.getEffectiveness('Rock', species) >= 2 && (!types.includes('Flying') || !isDoubles)\n\t\t) return 'Heavy-Duty Boots';\n\t}\n\n\t/** Item generation specific to Random Doubles */\n\tgetDoublesItem(\n\t\tability: string,\n\t\ttypes: string[],\n\t\tmoves: Set<string>,\n\t\tcounter: MoveCounter,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tteraType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): string {\n\t\tconst scarfReqs = (\n\t\t\t!counter.get('priority') && ability !== 'Speed Boost' && role !== 'Doubles Wallbreaker' &&\n\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 108 &&\n\t\t\tthis.randomChance(1, 2)\n\t\t);\n\t\tconst offensiveRole = (\n\t\t\t['Doubles Fast Attacker', 'Doubles Wallbreaker', 'Doubles Setup Sweeper', 'Offensive Protect'].some(m => role === m)\n\t\t);\n\t\tconst doublesLeftoversHardcodes = (\n\t\t\tmoves.has('acidarmor') || species.id === 'eternatus' || species.id === 'regigigas' || moves.has('wish')\n\t\t);\n\n\t\tif (species.id === 'ursalunabloodmoon' && moves.has('protect')) return 'Silk Scarf';\n\t\tif (\n\t\t\tmoves.has('flipturn') && moves.has('protect') && (moves.has('aquajet') || (moves.has('jetpunch')))\n\t\t) return 'Mystic Water';\n\t\tif (counter.get('speedsetup') && role === 'Doubles Bulky Setup') return 'Weakness Policy';\n\t\tif (species.id === 'toxapex') return 'Binding Band';\n\t\tif (moves.has('blizzard') && ability !== 'Snow Warning' && !teamDetails.snow) return 'Blunder Policy';\n\n\t\tif (role === 'Choice Item user') {\n\t\t\tif (scarfReqs || (counter.get('Physical') < 4 && counter.get('Special') < 3 && !moves.has('memento'))) {\n\t\t\t\treturn 'Choice Scarf';\n\t\t\t}\n\t\t\treturn (counter.get('Physical') >= 3) ? 'Choice Band' : 'Choice Specs';\n\t\t}\n\t\tif (counter.get('Physical') >= 4 &&\n\t\t\t['fakeout', 'feint', 'firstimpression', 'rapidspin', 'suckerpunch'].every(m => !moves.has(m)) &&\n\t\t\t(moves.has('flipturn') || moves.has('uturn') || role === 'Doubles Wallbreaker')\n\t\t) {\n\t\t\treturn (scarfReqs) ? 'Choice Scarf' : 'Choice Band';\n\t\t}\n\t\tif (\n\t\t\t((counter.get('Special') >= 4 && (moves.has('voltswitch') || role === 'Doubles Wallbreaker')) || (\n\t\t\t\tcounter.get('Special') >= 3 && (moves.has('uturn') || moves.has('flipturn'))\n\t\t\t)) && !moves.has('electroweb')\n\t\t) {\n\t\t\treturn (scarfReqs) ? 'Choice Scarf' : 'Choice Specs';\n\t\t}\n\t\tif (\n\t\t\t(role === 'Bulky Protect' && counter.get('setup')) || moves.has('substitute') || moves.has('irondefense') ||\n\t\t\tmoves.has('coil') || doublesLeftoversHardcodes\n\t\t) return 'Leftovers';\n\t\tif (species.id === 'sylveon') return 'Pixie Plate';\n\t\tif (ability === 'Intimidate' && this.dex.getEffectiveness('Rock', species) >= 1) return 'Heavy-Duty Boots';\n\t\tif (\n\t\t\t(offensiveRole || (role === 'Tera Blast user' && (species.baseStats.spe >= 80 || moves.has('trickroom')))) &&\n\t\t\t(!moves.has('fakeout') || species.id === 'ambipom') && !moves.has('incinerate') &&\n\t\t\t(!moves.has('uturn') || types.includes('Bug') || ability === 'Libero') &&\n\t\t\t((!moves.has('icywind') && !moves.has('electroweb')) || species.id === 'ironbundle')\n\t\t) {\n\t\t\treturn (\n\t\t\t\t(ability === 'Quark Drive' || ability === 'Protosynthesis') && !isLead && species.id !== 'ironvaliant' &&\n\t\t\t\t['dracometeor', 'firstimpression', 'uturn', 'voltswitch'].every(m => !moves.has(m))\n\t\t\t) ? 'Booster Energy' : 'Life Orb';\n\t\t}\n\t\tif (isLead && (species.id === 'glimmora' ||\n\t\t\t(['Doubles Fast Attacker', 'Doubles Wallbreaker', 'Offensive Protect'].includes(role) &&\n\t\t\t\tspecies.baseStats.hp + species.baseStats.def + species.baseStats.spd <= 230))\n\t\t) return 'Focus Sash';\n\t\tif (\n\t\t\t['Doubles Fast Attacker', 'Doubles Wallbreaker', 'Offensive Protect'].includes(role) &&\n\t\t\tmoves.has('fakeout') || moves.has('incinerate')\n\t\t) {\n\t\t\treturn (this.dex.getEffectiveness('Rock', species) >= 1) ? 'Heavy-Duty Boots' : 'Clear Amulet';\n\t\t}\n\t\tif (!counter.get('Status')) return 'Assault Vest';\n\t\treturn 'Sitrus Berry';\n\t}\n\n\tgetItem(\n\t\tability: string,\n\t\ttypes: string[],\n\t\tmoves: Set<string>,\n\t\tcounter: MoveCounter,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails,\n\t\tspecies: Species,\n\t\tisLead: boolean,\n\t\tteraType: string,\n\t\trole: RandomTeamsTypes.Role,\n\t): string {\n\t\tif (\n\t\t\tspecies.id !== 'jirachi' && (counter.get('Physical') >= 4) &&\n\t\t\t['dragontail', 'fakeout', 'firstimpression', 'flamecharge', 'rapidspin'].every(m => !moves.has(m))\n\t\t) {\n\t\t\tconst scarfReqs = (\n\t\t\t\trole !== 'Wallbreaker' &&\n\t\t\t\t(species.baseStats.atk >= 100 || ability === 'Huge Power' || ability === 'Pure Power') &&\n\t\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 108 &&\n\t\t\t\tability !== 'Speed Boost' && !counter.get('priority') && !moves.has('aquastep')\n\t\t\t);\n\t\t\treturn (scarfReqs && this.randomChance(1, 2)) ? 'Choice Scarf' : 'Choice Band';\n\t\t}\n\t\tif (\n\t\t\t(counter.get('Special') >= 4) ||\n\t\t\t(counter.get('Special') >= 3 && ['flipturn', 'uturn'].some(m => moves.has(m)))\n\t\t) {\n\t\t\tconst scarfReqs = (\n\t\t\t\trole !== 'Wallbreaker' &&\n\t\t\t\tspecies.baseStats.spa >= 100 &&\n\t\t\t\tspecies.baseStats.spe >= 60 && species.baseStats.spe <= 108 &&\n\t\t\t\tability !== 'Speed Boost' && ability !== 'Tinted Lens' && !moves.has('uturn') && !counter.get('priority')\n\t\t\t);\n\t\t\treturn (scarfReqs && this.randomChance(1, 2)) ? 'Choice Scarf' : 'Choice Specs';\n\t\t}\n\t\tif (counter.get('speedsetup') && role === 'Bulky Setup') return 'Weakness Policy';\n\t\tif (\n\t\t\t!counter.get('Status') &&\n\t\t\t!['Fast Attacker', 'Wallbreaker', 'Tera Blast user'].includes(role)\n\t\t) {\n\t\t\treturn 'Assault Vest';\n\t\t}\n\t\tif (species.id === 'golem') return (counter.get('speedsetup')) ? 'Weakness Policy' : 'Custap Berry';\n\t\tif (moves.has('substitute')) return 'Leftovers';\n\t\tif (\n\t\t\tmoves.has('stickyweb') && isLead &&\n\t\t\t(species.baseStats.hp + species.baseStats.def + species.baseStats.spd) <= 235\n\t\t) return 'Focus Sash';\n\t\tif (this.dex.getEffectiveness('Rock', species) >= 1) return 'Heavy-Duty Boots';\n\t\tif (\n\t\t\t(moves.has('chillyreception') || (\n\t\t\t\trole === 'Fast Support' &&\n\t\t\t\t[...PIVOT_MOVES, 'defog', 'mortalspin', 'rapidspin'].some(m => moves.has(m)) &&\n\t\t\t\t!types.includes('Flying') && ability !== 'Levitate'\n\t\t\t))\n\t\t) return 'Heavy-Duty Boots';\n\n\t\t// Low Priority\n\t\tif (\n\t\t\tability === 'Rough Skin' || (\n\t\t\t\tability === 'Regenerator' && (role === 'Bulky Support' || role === 'Bulky Attacker') &&\n\t\t\t\t(species.baseStats.hp + species.baseStats.def) >= 180 && this.randomChance(1, 2)\n\t\t\t) || (\n\t\t\t\tability !== 'Regenerator' && !counter.get('setup') && counter.get('recovery') &&\n\t\t\t\tthis.dex.getEffectiveness('Fighting', species) < 1 &&\n\t\t\t\t(species.baseStats.hp + species.baseStats.def) > 200 && this.randomChance(1, 2)\n\t\t\t)\n\t\t) return 'Rocky Helmet';\n\t\tif (moves.has('outrage') && counter.get('setup')) return 'Lum Berry';\n\t\tif (moves.has('protect') && ability !== 'Speed Boost') return 'Leftovers';\n\t\tif (\n\t\t\trole === 'Fast Support' && isLead && !counter.get('recovery') && !counter.get('recoil') &&\n\t\t\t(counter.get('hazards') || counter.get('setup')) &&\n\t\t\t(species.baseStats.hp + species.baseStats.def + species.baseStats.spd) < 258\n\t\t) return 'Focus Sash';\n\t\tif (\n\t\t\t!counter.get('setup') && ability !== 'Levitate' && this.dex.getEffectiveness('Ground', species) >= 2\n\t\t) return 'Air Balloon';\n\t\tif (['Bulky Attacker', 'Bulky Support', 'Bulky Setup'].some(m => role === (m))) return 'Leftovers';\n\t\tif (species.id === 'pawmot' && moves.has('nuzzle')) return 'Leppa Berry';\n\t\tif (role === 'Fast Support' || role === 'Fast Bulky Setup') {\n\t\t\treturn (counter.get('Physical') + counter.get('Special') >= 3 && !moves.has('nuzzle')) ? 'Life Orb' : 'Leftovers';\n\t\t}\n\t\tif (role === 'Tera Blast user' && DEFENSIVE_TERA_BLAST_USERS.includes(species.id)) return 'Leftovers';\n\t\tif (\n\t\t\t['flamecharge', 'rapidspin', 'trailblaze'].every(m => !moves.has(m)) &&\n\t\t\t['Fast Attacker', 'Setup Sweeper', 'Tera Blast user', 'Wallbreaker'].some(m => role === (m))\n\t\t) return 'Life Orb';\n\t\treturn 'Leftovers';\n\t}\n\n\tgetLevel(\n\t\tspecies: Species,\n\t\tisDoubles: boolean,\n\t): number {\n\t\tif (this.adjustLevel) return this.adjustLevel;\n\t\t// doubles levelling\n\t\tif (isDoubles && this.randomDoublesSets[species.id][\"level\"]) return this.randomDoublesSets[species.id][\"level\"]!;\n\t\tif (!isDoubles && this.randomSets[species.id][\"level\"]) return this.randomSets[species.id][\"level\"]!;\n\t\t// Default to tier-based levelling\n\t\tconst tier = species.tier;\n\t\tconst tierScale: Partial<Record<Species['tier'], number>> = {\n\t\t\tUber: 76,\n\t\t\tOU: 80,\n\t\t\tUUBL: 81,\n\t\t\tUU: 82,\n\t\t\tRUBL: 83,\n\t\t\tRU: 84,\n\t\t\tNUBL: 85,\n\t\t\tNU: 86,\n\t\t\tPUBL: 87,\n\t\t\tPU: 88, \"(PU)\": 88, NFE: 88,\n\t\t};\n\t\treturn tierScale[tier] || 80;\n\t}\n\n\tgetForme(species: Species): string {\n\t\tif (typeof species.battleOnly === 'string') {\n\t\t\t// Only change the forme. The species has custom moves, and may have different typing and requirements.\n\t\t\treturn species.battleOnly;\n\t\t}\n\t\tif (species.cosmeticFormes) return this.sample([species.name].concat(species.cosmeticFormes));\n\n\t\t// Consolidate mostly-cosmetic formes, at least for the purposes of Random Battles\n\t\tif (['Dudunsparce', 'Magearna', 'Maushold', 'Polteageist', 'Sinistcha', 'Zarude'].includes(species.baseSpecies)) {\n\t\t\treturn this.sample([species.name].concat(species.otherFormes!));\n\t\t}\n\t\tif (species.baseSpecies === 'Basculin') return 'Basculin' + this.sample(['', '-Blue-Striped']);\n\t\tif (species.baseSpecies === 'Pikachu') {\n\t\t\treturn 'Pikachu' + this.sample(\n\t\t\t\t['', '-Original', '-Hoenn', '-Sinnoh', '-Unova', '-Kalos', '-Alola', '-Partner', '-World']\n\t\t\t);\n\t\t}\n\t\treturn species.name;\n\t}\n\n\trandomSet(\n\t\ts: string | Species,\n\t\tteamDetails: RandomTeamsTypes.TeamDetails = {},\n\t\tisLead = false,\n\t\tisDoubles = false\n\t): RandomTeamsTypes.RandomSet {\n\t\tconst species = this.dex.species.get(s);\n\t\tconst forme = this.getForme(species);\n\t\tconst sets = this[`random${isDoubles ? 'Doubles' : ''}Sets`][species.id][\"sets\"];\n\t\tconst possibleSets: RandomTeamsTypes.RandomSetData[] = [];\n\n\t\tconst ruleTable = this.dex.formats.getRuleTable(this.format);\n\n\t\tfor (const set of sets) {\n\t\t\t// Prevent Fast Bulky Setup on lead Paradox Pokemon, since it generates Booster Energy.\n\t\t\tconst abilities = set.abilities!;\n\t\t\tif (\n\t\t\t\tisLead && (abilities.includes('Protosynthesis') || abilities.includes('Quark Drive')) &&\n\t\t\t\tset.role === 'Fast Bulky Setup'\n\t\t\t) continue;\n\t\t\t// Prevent Tera Blast user if the team already has one, or if Terastallizion is prevented.\n\t\t\tif ((teamDetails.teraBlast || ruleTable.has('terastalclause')) && set.role === 'Tera Blast user') {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tpossibleSets.push(set);\n\t\t}\n\t\tconst set = this.sampleIfArray(possibleSets);\n\t\tconst role = set.role;\n\t\tconst movePool: string[] = [];\n\t\tfor (const movename of set.movepool) {\n\t\t\tmovePool.push(this.dex.moves.get(movename).id);\n\t\t}\n\t\tconst teraTypes = set.teraTypes!;\n\t\tlet teraType = this.sampleIfArray(teraTypes);\n\n\t\tlet ability = '';\n\t\tlet item = undefined;\n\n\t\tconst evs = { hp: 85, atk: 85, def: 85, spa: 85, spd: 85, spe: 85 };\n\t\tconst ivs = { hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31 };\n\n\t\tconst types = species.types;\n\t\tconst abilities = set.abilities!;\n\n\t\t// Get moves\n\t\tconst moves = this.randomMoveset(types, abilities, teamDetails, species, isLead, isDoubles, movePool, teraType, role);\n\t\tconst counter = this.queryMoves(moves, species, teraType, abilities);\n\n\t\t// Get ability\n\t\tability = this.getAbility(types, moves, abilities, counter, teamDetails, species, isLead, isDoubles, teraType, role);\n\n\t\t// Get items\n\t\t// First, the priority items\n\t\titem = this.getPriorityItem(ability, types, moves, counter, teamDetails, species, isLead, isDoubles, teraType, role);\n\t\tif (item === undefined) {\n\t\t\tif (isDoubles) {\n\t\t\t\titem = this.getDoublesItem(ability, types, moves, counter, teamDetails, species, isLead, teraType, role);\n\t\t\t} else {\n\t\t\t\titem = this.getItem(ability, types, moves, counter, teamDetails, species, isLead, teraType, role);\n\t\t\t}\n\t\t}\n\n\t\t// Get level\n\t\tconst level = this.getLevel(species, isDoubles);\n\n\t\t// Prepare optimal HP\n\t\tconst srImmunity = ability === 'Magic Guard' || item === 'Heavy-Duty Boots';\n\t\tlet srWeakness = srImmunity ? 0 : this.dex.getEffectiveness('Rock', species);\n\t\t// Crash damage move users want an odd HP to survive two misses\n\t\tif (['axekick', 'highjumpkick', 'jumpkick', 'supercellslam'].some(m => moves.has(m))) srWeakness = 2;\n\t\twhile (evs.hp > 1) {\n\t\t\tconst hp = Math.floor(Math.floor(2 * species.baseStats.hp + ivs.hp + Math.floor(evs.hp / 4) + 100) * level / 100 + 10);\n\t\t\tif ((moves.has('substitute') && ['Sitrus Berry', 'Salac Berry'].includes(item)) || species.id === 'minior') {\n\t\t\t\t// Two Substitutes should activate Sitrus Berry. Two switch-ins to Stealth Rock should activate Shields Down on Minior.\n\t\t\t\tif (hp % 4 === 0) break;\n\t\t\t} else if (\n\t\t\t\t(moves.has('bellydrum') || moves.has('filletaway') || moves.has('shedtail')) &&\n\t\t\t\t(item === 'Sitrus Berry' || ability === 'Gluttony')\n\t\t\t) {\n\t\t\t\t// Belly Drum should activate Sitrus Berry\n\t\t\t\tif (hp % 2 === 0) break;\n\t\t\t} else if (moves.has('substitute') && moves.has('endeavor')) {\n\t\t\t\t// Luvdisc should be able to Substitute down to very low HP\n\t\t\t\tif (hp % 4 > 0) break;\n\t\t\t} else {\n\t\t\t\t// Maximize number of Stealth Rock switch-ins in singles\n\t\t\t\tif (isDoubles) break;\n\t\t\t\tif (srWeakness <= 0 || ability === 'Regenerator' || ['Leftovers', 'Life Orb'].includes(item)) break;\n\t\t\t\tif (item !== 'Sitrus Berry' && hp % (4 / srWeakness) > 0) break;\n\t\t\t\t// Minimise number of Stealth Rock switch-ins to activate Sitrus Berry\n\t\t\t\tif (item === 'Sitrus Berry' && hp % (4 / srWeakness) === 0) break;\n\t\t\t}\n\t\t\tevs.hp -= 4;\n\t\t}\n\n\t\t// Minimize confusion damage\n\t\tconst noAttackStatMoves = [...moves].every(m => {\n\t\t\tconst move = this.dex.moves.get(m);\n\t\t\tif (move.damageCallback || move.damage) return true;\n\t\t\tif (move.id === 'shellsidearm') return false;\n\t\t\t// Physical Tera Blast\n\t\t\tif (\n\t\t\t\tmove.id === 'terablast' && (species.id === 'porygon2' || ['Contrary', 'Defiant'].includes(ability) ||\n\t\t\t\t\tmoves.has('shiftgear') || species.baseStats.atk > species.baseStats.spa)\n\t\t\t) return false;\n\t\t\treturn move.category !== 'Physical' || move.id === 'bodypress' || move.id === 'foulplay';\n\t\t});\n\t\tif (noAttackStatMoves && !moves.has('transform') && this.format.mod !== 'partnersincrime') {\n\t\t\tevs.atk = 0;\n\t\t\tivs.atk = 0;\n\t\t}\n\n\t\tif (moves.has('gyroball') || moves.has('trickroom')) {\n\t\t\tevs.spe = 0;\n\t\t\tivs.spe = 0;\n\t\t}\n\n\t\t// Enforce Tera Type after all set generation is done to prevent infinite generation\n\t\tif (this.forceTeraType) teraType = this.forceTeraType;\n\n\t\t// shuffle moves to add more randomness to camomons\n\t\tconst shuffledMoves = Array.from(moves);\n\t\tthis.prng.shuffle(shuffledMoves);\n\t\treturn {\n\t\t\tname: species.baseSpecies,\n\t\t\tspecies: forme,\n\t\t\tgender: species.baseSpecies === 'Greninja' ? 'M' : species.gender,\n\t\t\tshiny: this.randomChance(1, 1024),\n\t\t\tlevel,\n\t\t\tmoves: shuffledMoves,\n\t\t\tability,\n\t\t\tevs,\n\t\t\tivs,\n\t\t\titem,\n\t\t\tteraType,\n\t\t\trole,\n\t\t};\n\t}\n\n\tgetPokemonPool(\n\t\ttype: string,\n\t\tpokemonToExclude: RandomTeamsTypes.RandomSet[] = [],\n\t\tisMonotype = false,\n\t\tpokemonList: string[]\n\t): [{ [k: string]: string[] }, string[]] {\n\t\tconst exclude = pokemonToExclude.map(p => toID(p.species));\n\t\tconst pokemonPool: { [k: string]: string[] } = {};\n\t\tconst baseSpeciesPool = [];\n\t\tfor (const pokemon of pokemonList) {\n\t\t\tlet species = this.dex.species.get(pokemon);\n\t\t\tif (exclude.includes(species.id)) continue;\n\t\t\tif (isMonotype) {\n\t\t\t\tif (!species.types.includes(type)) continue;\n\t\t\t\tif (typeof species.battleOnly === 'string') {\n\t\t\t\t\tspecies = this.dex.species.get(species.battleOnly);\n\t\t\t\t\tif (!species.types.includes(type)) continue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (species.baseSpecies in pokemonPool) {\n\t\t\t\tpokemonPool[species.baseSpecies].push(pokemon);\n\t\t\t} else {\n\t\t\t\tpokemonPool[species.baseSpecies] = [pokemon];\n\t\t\t}\n\t\t}\n\t\t// Include base species 1x if 1-3 formes, 2x if 4-6 formes, 3x if 7+ formes\n\t\tfor (const baseSpecies of Object.keys(pokemonPool)) {\n\t\t\t// Squawkabilly has 4 formes, but only 2 functionally different formes, so only include it 1x\n\t\t\tconst weight = (baseSpecies === 'Squawkabilly') ? 1 : Math.min(Math.ceil(pokemonPool[baseSpecies].length / 3), 3);\n\t\t\tfor (let i = 0; i < weight; i++) baseSpeciesPool.push(baseSpecies);\n\t\t}\n\t\treturn [pokemonPool, baseSpeciesPool];\n\t}\n\n\trandomSets: { [species: string]: RandomTeamsTypes.RandomSpeciesData } = require('./sets.json');\n\trandomDoublesSets: { [species: string]: RandomTeamsTypes.RandomSpeciesData } = require('./doubles-sets.json');\n\n\trandomTeam() {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tconst seed = this.prng.getSeed();\n\t\tconst ruleTable = this.dex.formats.getRuleTable(this.format);\n\t\tconst pokemon: RandomTeamsTypes.RandomSet[] = [];\n\n\t\t// For Monotype\n\t\tconst isMonotype = !!this.forceMonotype || ruleTable.has('sametypeclause');\n\t\tconst isDoubles = this.format.gameType !== 'singles';\n\t\tconst typePool = this.dex.types.names().filter(name => name !== \"Stellar\");\n\t\tconst type = this.forceMonotype || this.sample(typePool);\n\n\t\t// PotD stuff\n\t\tconst usePotD = global.Config && Config.potd && ruleTable.has('potd');\n\t\tconst potd = usePotD ? this.dex.species.get(Config.potd) : null;\n\n\t\tconst baseFormes: { [k: string]: number } = {};\n\n\t\tconst typeCount: { [k: string]: number } = {};\n\t\tconst typeComboCount: { [k: string]: number } = {};\n\t\tconst typeWeaknesses: { [k: string]: number } = {};\n\t\tconst typeDoubleWeaknesses: { [k: string]: number } = {};\n\t\tconst teamDetails: RandomTeamsTypes.TeamDetails = {};\n\t\tlet numMaxLevelPokemon = 0;\n\n\t\tconst pokemonList = isDoubles ? Object.keys(this.randomDoublesSets) : Object.keys(this.randomSets);\n\t\tconst [pokemonPool, baseSpeciesPool] = this.getPokemonPool(type, pokemon, isMonotype, pokemonList);\n\n\t\tlet leadsRemaining = this.format.gameType === 'doubles' ? 2 : 1;\n\t\twhile (baseSpeciesPool.length && pokemon.length < this.maxTeamSize) {\n\t\t\tconst baseSpecies = this.sampleNoReplace(baseSpeciesPool);\n\t\t\tlet species = this.dex.species.get(this.sample(pokemonPool[baseSpecies]));\n\t\t\tif (!species.exists) continue;\n\n\t\t\t// Limit to one of each species (Species Clause)\n\t\t\tif (baseFormes[species.baseSpecies]) continue;\n\n\t\t\t// Treat Ogerpon formes and Terapagos like the Tera Blast user role; reject if team has one already\n\t\t\tif (['ogerpon', 'ogerponhearthflame', 'terapagos'].includes(species.id) && teamDetails.teraBlast) continue;\n\n\t\t\t// Illusion shouldn't be on the last slot\n\t\t\tif (species.baseSpecies === 'Zoroark' && pokemon.length >= (this.maxTeamSize - 1)) continue;\n\n\t\t\tconst types = species.types;\n\t\t\tconst typeCombo = types.slice().sort().join();\n\t\t\tconst weakToFreezeDry = (\n\t\t\t\tthis.dex.getEffectiveness('Ice', species) > 0 ||\n\t\t\t\t(this.dex.getEffectiveness('Ice', species) > -2 && types.includes('Water'))\n\t\t\t);\n\t\t\t// Dynamically scale limits for different team sizes. The default and minimum value is 1.\n\t\t\tconst limitFactor = Math.round(this.maxTeamSize / 6) || 1;\n\n\t\t\tif (!isMonotype && !this.forceMonotype) {\n\t\t\t\tlet skip = false;\n\n\t\t\t\t// Limit two of any type\n\t\t\t\tfor (const typeName of types) {\n\t\t\t\t\tif (typeCount[typeName] >= 2 * limitFactor) {\n\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (skip) continue;\n\n\t\t\t\t// Limit three weak to any type, and one double weak to any type\n\t\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\t\t// it's weak to the type\n\t\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 0) {\n\t\t\t\t\t\tif (!typeWeaknesses[typeName]) typeWeaknesses[typeName] = 0;\n\t\t\t\t\t\tif (typeWeaknesses[typeName] >= 3 * limitFactor) {\n\t\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 1) {\n\t\t\t\t\t\tif (!typeDoubleWeaknesses[typeName]) typeDoubleWeaknesses[typeName] = 0;\n\t\t\t\t\t\tif (typeDoubleWeaknesses[typeName] >= limitFactor) {\n\t\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (skip) continue;\n\n\t\t\t\t// Count Dry Skin/Fluffy as Fire weaknesses\n\t\t\t\tif (\n\t\t\t\t\tthis.dex.getEffectiveness('Fire', species) === 0 &&\n\t\t\t\t\tObject.values(species.abilities).filter(a => ['Dry Skin', 'Fluffy'].includes(a)).length\n\t\t\t\t) {\n\t\t\t\t\tif (!typeWeaknesses['Fire']) typeWeaknesses['Fire'] = 0;\n\t\t\t\t\tif (typeWeaknesses['Fire'] >= 3 * limitFactor) continue;\n\t\t\t\t}\n\n\t\t\t\t// Limit four weak to Freeze-Dry\n\t\t\t\tif (weakToFreezeDry) {\n\t\t\t\t\tif (!typeWeaknesses['Freeze-Dry']) typeWeaknesses['Freeze-Dry'] = 0;\n\t\t\t\t\tif (typeWeaknesses['Freeze-Dry'] >= 4 * limitFactor) continue;\n\t\t\t\t}\n\n\t\t\t\t// Limit one level 100 Pokemon\n\t\t\t\tif (!this.adjustLevel && (this.getLevel(species, isDoubles) === 100) && numMaxLevelPokemon >= limitFactor) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Limit three of any type combination in Monotype\n\t\t\tif (!this.forceMonotype && isMonotype && (typeComboCount[typeCombo] >= 3 * limitFactor)) continue;\n\n\t\t\t// The Pokemon of the Day\n\t\t\tif (potd?.exists && (pokemon.length === 1 || this.maxTeamSize === 1)) species = potd;\n\n\t\t\tlet set: RandomTeamsTypes.RandomSet;\n\n\t\t\tif (leadsRemaining) {\n\t\t\t\tif (\n\t\t\t\t\tisDoubles && DOUBLES_NO_LEAD_POKEMON.includes(species.baseSpecies) ||\n\t\t\t\t\t!isDoubles && NO_LEAD_POKEMON.includes(species.baseSpecies)\n\t\t\t\t) {\n\t\t\t\t\tif (pokemon.length + leadsRemaining === this.maxTeamSize) continue;\n\t\t\t\t\tset = this.randomSet(species, teamDetails, false, isDoubles);\n\t\t\t\t\tpokemon.push(set);\n\t\t\t\t} else {\n\t\t\t\t\tset = this.randomSet(species, teamDetails, true, isDoubles);\n\t\t\t\t\tpokemon.unshift(set);\n\t\t\t\t\tleadsRemaining--;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tset = this.randomSet(species, teamDetails, false, isDoubles);\n\t\t\t\tpokemon.push(set);\n\t\t\t}\n\n\t\t\t// Don't bother tracking details for the last Pokemon\n\t\t\tif (pokemon.length === this.maxTeamSize) break;\n\n\t\t\t// Now that our Pokemon has passed all checks, we can increment our counters\n\t\t\tbaseFormes[species.baseSpecies] = 1;\n\n\t\t\t// Increment type counters\n\t\t\tfor (const typeName of types) {\n\t\t\t\tif (typeName in typeCount) {\n\t\t\t\t\ttypeCount[typeName]++;\n\t\t\t\t} else {\n\t\t\t\t\ttypeCount[typeName] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeCombo in typeComboCount) {\n\t\t\t\ttypeComboCount[typeCombo]++;\n\t\t\t} else {\n\t\t\t\ttypeComboCount[typeCombo] = 1;\n\t\t\t}\n\n\t\t\t// Increment weakness counter\n\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\t// it's weak to the type\n\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 0) {\n\t\t\t\t\ttypeWeaknesses[typeName]++;\n\t\t\t\t}\n\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 1) {\n\t\t\t\t\ttypeDoubleWeaknesses[typeName]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Count Dry Skin/Fluffy as Fire weaknesses\n\t\t\tif (['Dry Skin', 'Fluffy'].includes(set.ability) && this.dex.getEffectiveness('Fire', species) === 0) {\n\t\t\t\ttypeWeaknesses['Fire']++;\n\t\t\t}\n\t\t\tif (weakToFreezeDry) typeWeaknesses['Freeze-Dry']++;\n\n\t\t\t// Increment level 100 counter\n\t\t\tif (set.level === 100) numMaxLevelPokemon++;\n\n\t\t\t// Track what the team has\n\t\t\tif (set.ability === 'Drizzle' || set.moves.includes('raindance')) teamDetails.rain = 1;\n\t\t\tif (set.ability === 'Drought' || set.ability === 'Orichalcum Pulse' || set.moves.includes('sunnyday')) {\n\t\t\t\tteamDetails.sun = 1;\n\t\t\t}\n\t\t\tif (set.ability === 'Sand Stream') teamDetails.sand = 1;\n\t\t\tif (set.ability === 'Snow Warning' || set.moves.includes('snowscape') || set.moves.includes('chillyreception')) {\n\t\t\t\tteamDetails.snow = 1;\n\t\t\t}\n\t\t\tif (set.moves.includes('healbell')) teamDetails.statusCure = 1;\n\t\t\tif (set.moves.includes('spikes') || set.moves.includes('ceaselessedge')) {\n\t\t\t\tteamDetails.spikes = (teamDetails.spikes || 0) + 1;\n\t\t\t}\n\t\t\tif (set.moves.includes('toxicspikes') || set.ability === 'Toxic Debris') teamDetails.toxicSpikes = 1;\n\t\t\tif (set.moves.includes('stealthrock') || set.moves.includes('stoneaxe')) teamDetails.stealthRock = 1;\n\t\t\tif (set.moves.includes('stickyweb')) teamDetails.stickyWeb = 1;\n\t\t\tif (set.moves.includes('defog')) teamDetails.defog = 1;\n\t\t\tif (set.moves.includes('rapidspin') || set.moves.includes('mortalspin')) teamDetails.rapidSpin = 1;\n\t\t\tif (set.moves.includes('auroraveil') || (set.moves.includes('reflect') && set.moves.includes('lightscreen'))) {\n\t\t\t\tteamDetails.screens = 1;\n\t\t\t}\n\t\t\tif (set.role === 'Tera Blast user' || ['ogerpon', 'ogerponhearthflame', 'terapagos'].includes(species.id)) {\n\t\t\t\tteamDetails.teraBlast = 1;\n\t\t\t}\n\t\t}\n\t\tif (pokemon.length < this.maxTeamSize && pokemon.length < 12) { // large teams sometimes cannot be built\n\t\t\tthrow new Error(`Could not build a random team for ${this.format} (seed=${seed})`);\n\t\t}\n\n\t\treturn pokemon;\n\t}\n\n\trandomCCTeam(): RandomTeamsTypes.RandomSet[] {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tconst dex = this.dex;\n\t\tconst team = [];\n\n\t\tconst natures = this.dex.natures.all();\n\t\tconst items = this.dex.items.all();\n\n\t\tconst randomN = this.randomNPokemon(this.maxTeamSize, this.forceMonotype, undefined, undefined, true);\n\n\t\tfor (let forme of randomN) {\n\t\t\tlet species = dex.species.get(forme);\n\t\t\tif (species.isNonstandard) species = dex.species.get(species.baseSpecies);\n\n\t\t\t// Random legal item\n\t\t\tlet item = '';\n\t\t\tlet isIllegalItem;\n\t\t\tlet isBadItem;\n\t\t\tif (this.gen >= 2) {\n\t\t\t\tdo {\n\t\t\t\t\titem = this.sample(items).name;\n\t\t\t\t\tisIllegalItem = this.dex.items.get(item).gen > this.gen || this.dex.items.get(item).isNonstandard;\n\t\t\t\t\tisBadItem = item.startsWith(\"TR\") || this.dex.items.get(item).isPokeball;\n\t\t\t\t} while (isIllegalItem || (isBadItem && this.randomChance(19, 20)));\n\t\t\t}\n\n\t\t\t// Make sure forme is legal\n\t\t\tif (species.battleOnly) {\n\t\t\t\tif (typeof species.battleOnly === 'string') {\n\t\t\t\t\tspecies = dex.species.get(species.battleOnly);\n\t\t\t\t} else {\n\t\t\t\t\tspecies = dex.species.get(this.sample(species.battleOnly));\n\t\t\t\t}\n\t\t\t\tforme = species.name;\n\t\t\t} else if (species.requiredItems && !species.requiredItems.some(req => toID(req) === item)) {\n\t\t\t\tif (!species.changesFrom) throw new Error(`${species.name} needs a changesFrom value`);\n\t\t\t\tspecies = dex.species.get(species.changesFrom);\n\t\t\t\tforme = species.name;\n\t\t\t}\n\n\t\t\t// Make sure that a base forme does not hold any forme-modifier items.\n\t\t\tlet itemData = this.dex.items.get(item);\n\t\t\tif (itemData.forcedForme && forme === this.dex.species.get(itemData.forcedForme).baseSpecies) {\n\t\t\t\tdo {\n\t\t\t\t\titemData = this.sample(items);\n\t\t\t\t\titem = itemData.name;\n\t\t\t\t} while (\n\t\t\t\t\titemData.gen > this.gen ||\n\t\t\t\t\titemData.isNonstandard ||\n\t\t\t\t\t(itemData.forcedForme && forme === this.dex.species.get(itemData.forcedForme).baseSpecies)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Random legal ability\n\t\t\tconst abilities = Object.values(species.abilities).filter(a => this.dex.abilities.get(a).gen <= this.gen);\n\t\t\tconst ability: string = this.gen <= 2 ? 'No Ability' : this.sample(abilities);\n\n\t\t\t// Four random unique moves from the movepool\n\t\t\tlet pool = ['struggle'];\n\t\t\tif (forme === 'Smeargle') {\n\t\t\t\tpool = this.dex.moves.all()\n\t\t\t\t\t.filter(move => !(move.isNonstandard || move.isZ || move.isMax || move.realMove))\n\t\t\t\t\t.map(m => m.id);\n\t\t\t} else {\n\t\t\t\tpool = [...this.dex.species.getMovePool(species.id)];\n\t\t\t}\n\n\t\t\tconst moves = this.multipleSamplesNoReplace(pool, this.maxMoveCount);\n\n\t\t\t// Random EVs\n\t\t\tconst evs: StatsTable = { hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0 };\n\t\t\tconst s: StatID[] = [\"hp\", \"atk\", \"def\", \"spa\", \"spd\", \"spe\"];\n\t\t\tlet evpool = 510;\n\t\t\tdo {\n\t\t\t\tconst x = this.sample(s);\n\t\t\t\tconst y = this.random(Math.min(256 - evs[x], evpool + 1));\n\t\t\t\tevs[x] += y;\n\t\t\t\tevpool -= y;\n\t\t\t} while (evpool > 0);\n\n\t\t\t// Random IVs\n\t\t\tconst ivs = {\n\t\t\t\thp: this.random(32),\n\t\t\t\tatk: this.random(32),\n\t\t\t\tdef: this.random(32),\n\t\t\t\tspa: this.random(32),\n\t\t\t\tspd: this.random(32),\n\t\t\t\tspe: this.random(32),\n\t\t\t};\n\n\t\t\t// Random nature\n\t\t\tconst nature = this.sample(natures).name;\n\n\t\t\t// Level balance--calculate directly from stats rather than using some silly lookup table\n\t\t\tconst mbstmin = 1307; // Sunkern has the lowest modified base stat total, and that total is 807\n\n\t\t\tlet stats = species.baseStats;\n\t\t\t// If Wishiwashi, use the school-forme's much higher stats\n\t\t\tif (species.baseSpecies === 'Wishiwashi') stats = Dex.species.get('wishiwashischool').baseStats;\n\t\t\t// If Terapagos, use Terastal-forme's stats\n\t\t\tif (species.baseSpecies === 'Terapagos') stats = Dex.species.get('terapagosterastal').baseStats;\n\n\t\t\t// Modified base stat total assumes 31 IVs, 85 EVs in every stat\n\t\t\tlet mbst = (stats[\"hp\"] * 2 + 31 + 21 + 100) + 10;\n\t\t\tmbst += (stats[\"atk\"] * 2 + 31 + 21 + 100) + 5;\n\t\t\tmbst += (stats[\"def\"] * 2 + 31 + 21 + 100) + 5;\n\t\t\tmbst += (stats[\"spa\"] * 2 + 31 + 21 + 100) + 5;\n\t\t\tmbst += (stats[\"spd\"] * 2 + 31 + 21 + 100) + 5;\n\t\t\tmbst += (stats[\"spe\"] * 2 + 31 + 21 + 100) + 5;\n\n\t\t\tlet level;\n\t\t\tif (this.adjustLevel) {\n\t\t\t\tlevel = this.adjustLevel;\n\t\t\t} else {\n\t\t\t\tlevel = Math.floor(100 * mbstmin / mbst); // Initial level guess will underestimate\n\n\t\t\t\twhile (level < 100) {\n\t\t\t\t\tmbst = Math.floor((stats[\"hp\"] * 2 + 31 + 21 + 100) * level / 100 + 10);\n\t\t\t\t\t// Since damage is roughly proportional to level\n\t\t\t\t\tmbst += Math.floor(((stats[\"atk\"] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);\n\t\t\t\t\tmbst += Math.floor((stats[\"def\"] * 2 + 31 + 21 + 100) * level / 100 + 5);\n\t\t\t\t\tmbst += Math.floor(((stats[\"spa\"] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);\n\t\t\t\t\tmbst += Math.floor((stats[\"spd\"] * 2 + 31 + 21 + 100) * level / 100 + 5);\n\t\t\t\t\tmbst += Math.floor((stats[\"spe\"] * 2 + 31 + 21 + 100) * level / 100 + 5);\n\n\t\t\t\t\tif (mbst >= mbstmin) break;\n\t\t\t\t\tlevel++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Random happiness\n\t\t\tconst happiness = this.random(256);\n\n\t\t\t// Random shininess\n\t\t\tconst shiny = this.randomChance(1, 1024);\n\n\t\t\tconst set: RandomTeamsTypes.RandomSet = {\n\t\t\t\tname: species.baseSpecies,\n\t\t\t\tspecies: species.name,\n\t\t\t\tgender: species.gender,\n\t\t\t\titem,\n\t\t\t\tability,\n\t\t\t\tmoves,\n\t\t\t\tevs,\n\t\t\t\tivs,\n\t\t\t\tnature,\n\t\t\t\tlevel,\n\t\t\t\thappiness,\n\t\t\t\tshiny,\n\t\t\t};\n\t\t\tif (this.gen === 9) {\n\t\t\t\t// Tera type\n\t\t\t\tif (this.forceTeraType) {\n\t\t\t\t\tset.teraType = this.forceTeraType;\n\t\t\t\t} else {\n\t\t\t\t\tset.teraType = this.sample(this.dex.types.names());\n\t\t\t\t}\n\t\t\t}\n\t\t\tteam.push(set);\n\t\t}\n\n\t\treturn team;\n\t}\n\n\tprivate getPools(requiredType?: string, minSourceGen?: number, ruleTable?: RuleTable, requireMoves = false) {\n\t\t// Memoize pool and speciesPool because, at least during tests, they are constructed with the same parameters\n\t\t// hundreds of times and are expensive to compute.\n\t\tconst isNotCustom = !ruleTable;\n\t\tlet pool: number[] = [];\n\t\tlet speciesPool: Species[] = [];\n\t\tconst ck = this.poolsCacheKey;\n\t\tif (ck && this.cachedPool && this.cachedSpeciesPool &&\n\t\t\tck[0] === requiredType && ck[1] === minSourceGen && ck[2] === ruleTable && ck[3] === requireMoves) {\n\t\t\tspeciesPool = this.cachedSpeciesPool.slice();\n\t\t\tpool = this.cachedPool.slice();\n\t\t} else if (isNotCustom) {\n\t\t\tspeciesPool = [...this.dex.species.all()];\n\t\t\tfor (const species of speciesPool) {\n\t\t\t\tif (species.isNonstandard && species.isNonstandard !== 'Unobtainable') continue;\n\t\t\t\tif (requireMoves) {\n\t\t\t\t\tconst hasMovesInCurrentGen = this.dex.species.getMovePool(species.id).size;\n\t\t\t\t\tif (!hasMovesInCurrentGen) continue;\n\t\t\t\t}\n\t\t\t\tif (requiredType && !species.types.includes(requiredType)) continue;\n\t\t\t\tif (minSourceGen && species.gen < minSourceGen) continue;\n\t\t\t\tconst num = species.num;\n\t\t\t\tif (num <= 0 || pool.includes(num)) continue;\n\t\t\t\tpool.push(num);\n\t\t\t}\n\t\t\tthis.poolsCacheKey = [requiredType, minSourceGen, ruleTable, requireMoves];\n\t\t\tthis.cachedPool = pool.slice();\n\t\t\tthis.cachedSpeciesPool = speciesPool.slice();\n\t\t} else {\n\t\t\tconst EXISTENCE_TAG = ['past', 'future', 'lgpe', 'unobtainable', 'cap', 'custom', 'nonexistent'];\n\t\t\tconst nonexistentBanReason = ruleTable.check('nonexistent');\n\t\t\t// Assume tierSpecies does not differ from species here (mega formes can be used without their stone, etc)\n\t\t\tfor (const species of this.dex.species.all()) {\n\t\t\t\tif (requiredType && !species.types.includes(requiredType)) continue;\n\n\t\t\t\tlet banReason = ruleTable.check('pokemon:' + species.id);\n\t\t\t\tif (banReason) continue;\n\t\t\t\tif (banReason !== '') {\n\t\t\t\t\tif (species.isMega && ruleTable.check('pokemontag:mega')) continue;\n\n\t\t\t\t\tbanReason = ruleTable.check('basepokemon:' + toID(species.baseSpecies));\n\t\t\t\t\tif (banReason) continue;\n\t\t\t\t\tif (banReason !== '' || this.dex.species.get(species.baseSpecies).isNonstandard !== species.isNonstandard) {\n\t\t\t\t\t\tconst nonexistentCheck = Tags.nonexistent.genericFilter!(species) && nonexistentBanReason;\n\t\t\t\t\t\tlet tagWhitelisted = false;\n\t\t\t\t\t\tlet tagBlacklisted = false;\n\t\t\t\t\t\tfor (const ruleid of ruleTable.tagRules) {\n\t\t\t\t\t\t\tif (ruleid.startsWith('*')) continue;\n\t\t\t\t\t\t\tconst tagid = ruleid.slice(12) as ID;\n\t\t\t\t\t\t\tconst tag = Tags[tagid];\n\t\t\t\t\t\t\tif ((tag.speciesFilter || tag.genericFilter)!(species)) {\n\t\t\t\t\t\t\t\tconst existenceTag = EXISTENCE_TAG.includes(tagid);\n\t\t\t\t\t\t\t\tif (ruleid.startsWith('+')) {\n\t\t\t\t\t\t\t\t\tif (!existenceTag && nonexistentCheck) continue;\n\t\t\t\t\t\t\t\t\ttagWhitelisted = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttagBlacklisted = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (tagBlacklisted) continue;\n\t\t\t\t\t\tif (!tagWhitelisted) {\n\t\t\t\t\t\t\tif (ruleTable.check('pokemontag:allpokemon')) continue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tspeciesPool.push(species);\n\t\t\t\tconst num = species.num;\n\t\t\t\tif (pool.includes(num)) continue;\n\t\t\t\tpool.push(num);\n\t\t\t}\n\t\t\tthis.poolsCacheKey = [requiredType, minSourceGen, ruleTable, requireMoves];\n\t\t\tthis.cachedPool = pool.slice();\n\t\t\tthis.cachedSpeciesPool = speciesPool.slice();\n\t\t}\n\t\treturn { pool, speciesPool };\n\t}\n\n\trandomNPokemon(n: number, requiredType?: string, minSourceGen?: number, ruleTable?: RuleTable, requireMoves = false) {\n\t\t// Picks `n` random pokemon--no repeats, even among formes\n\t\t// Also need to either normalize for formes or select formes at random\n\t\t// Unreleased are okay but no CAP\n\t\tif (requiredType && !this.dex.types.get(requiredType).exists) {\n\t\t\tthrow new Error(`\"${requiredType}\" is not a valid type.`);\n\t\t}\n\n\t\tconst { pool, speciesPool } = this.getPools(requiredType, minSourceGen, ruleTable, requireMoves);\n\t\tconst isNotCustom = !ruleTable;\n\n\t\tconst hasDexNumber: { [k: string]: number } = {};\n\t\tfor (let i = 0; i < n; i++) {\n\t\t\tconst num = this.sampleNoReplace(pool);\n\t\t\thasDexNumber[num] = i;\n\t\t}\n\n\t\tconst formes: string[][] = [];\n\t\tfor (const species of speciesPool) {\n\t\t\tif (!(species.num in hasDexNumber)) continue;\n\t\t\tif (isNotCustom && (species.gen > this.gen ||\n\t\t\t\t(species.isNonstandard && species.isNonstandard !== 'Unobtainable'))) continue;\n\t\t\tif (requiredType && !species.types.includes(requiredType)) continue;\n\t\t\tif (!formes[hasDexNumber[species.num]]) formes[hasDexNumber[species.num]] = [];\n\t\t\tformes[hasDexNumber[species.num]].push(species.name);\n\t\t}\n\n\t\tif (formes.length < n) {\n\t\t\tthrow new Error(`Legal Pokemon forme count insufficient to support Max Team Size: (${formes.length} / ${n}).`);\n\t\t}\n\n\t\tconst nPokemon = [];\n\t\tfor (let i = 0; i < n; i++) {\n\t\t\tif (!formes[i].length) {\n\t\t\t\tthrow new Error(`Invalid pokemon gen ${this.gen}: ${JSON.stringify(formes)} numbers ${JSON.stringify(hasDexNumber)}`);\n\t\t\t}\n\t\t\tnPokemon.push(this.sample(formes[i]));\n\t\t}\n\t\treturn nPokemon;\n\t}\n\n\trandomHCTeam(): PokemonSet[] {\n\t\tconst hasCustomBans = this.hasDirectCustomBanlistChanges();\n\t\tconst ruleTable = this.dex.formats.getRuleTable(this.format);\n\t\tconst hasNonexistentBan = hasCustomBans && ruleTable.check('nonexistent');\n\t\tconst hasNonexistentWhitelist = hasCustomBans && (hasNonexistentBan === '');\n\n\t\tif (hasCustomBans) {\n\t\t\tthis.enforceNoDirectComplexBans();\n\t\t}\n\n\t\t// Item Pool\n\t\tconst doItemsExist = this.gen > 1;\n\t\tlet itemPool: Item[] = [];\n\t\tif (doItemsExist) {\n\t\t\tif (!hasCustomBans) {\n\t\t\t\titemPool = [...this.dex.items.all()].filter(item => (item.gen <= this.gen && !item.isNonstandard));\n\t\t\t} else {\n\t\t\t\tconst hasAllItemsBan = ruleTable.check('pokemontag:allitems');\n\t\t\t\tfor (const item of this.dex.items.all()) {\n\t\t\t\t\tlet banReason = ruleTable.check('item:' + item.id);\n\t\t\t\t\tif (banReason) continue;\n\t\t\t\t\tif (banReason !== '' && item.id) {\n\t\t\t\t\t\tif (hasAllItemsBan) continue;\n\t\t\t\t\t\tif (item.isNonstandard) {\n\t\t\t\t\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(item.isNonstandard));\n\t\t\t\t\t\t\tif (banReason) continue;\n\t\t\t\t\t\t\tif (banReason !== '' && item.isNonstandard !== 'Unobtainable') {\n\t\t\t\t\t\t\t\tif (hasNonexistentBan) continue;\n\t\t\t\t\t\t\t\tif (!hasNonexistentWhitelist) continue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\titemPool.push(item);\n\t\t\t\t}\n\t\t\t\tif (ruleTable.check('item:noitem')) {\n\t\t\t\t\tthis.enforceCustomPoolSizeNoComplexBans('item', itemPool, this.maxTeamSize, 'Max Team Size');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Ability Pool\n\t\tconst doAbilitiesExist = (this.gen > 2) && (this.dex.currentMod !== 'gen7letsgo');\n\t\tlet abilityPool: Ability[] = [];\n\t\tif (doAbilitiesExist) {\n\t\t\tif (!hasCustomBans) {\n\t\t\t\tabilityPool = [...this.dex.abilities.all()].filter(ability => (ability.gen <= this.gen && !ability.isNonstandard));\n\t\t\t} else {\n\t\t\t\tconst hasAllAbilitiesBan = ruleTable.check('pokemontag:allabilities');\n\t\t\t\tfor (const ability of this.dex.abilities.all()) {\n\t\t\t\t\tlet banReason = ruleTable.check('ability:' + ability.id);\n\t\t\t\t\tif (banReason) continue;\n\t\t\t\t\tif (banReason !== '') {\n\t\t\t\t\t\tif (hasAllAbilitiesBan) continue;\n\t\t\t\t\t\tif (ability.isNonstandard) {\n\t\t\t\t\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(ability.isNonstandard));\n\t\t\t\t\t\t\tif (banReason) continue;\n\t\t\t\t\t\t\tif (banReason !== '') {\n\t\t\t\t\t\t\t\tif (hasNonexistentBan) continue;\n\t\t\t\t\t\t\t\tif (!hasNonexistentWhitelist) continue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tabilityPool.push(ability);\n\t\t\t\t}\n\t\t\t\tif (ruleTable.check('ability:noability')) {\n\t\t\t\t\tthis.enforceCustomPoolSizeNoComplexBans('ability', abilityPool, this.maxTeamSize, 'Max Team Size');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Move Pool\n\t\tconst setMoveCount = ruleTable.maxMoveCount;\n\t\tlet movePool: Move[] = [];\n\t\tif (!hasCustomBans) {\n\t\t\tmovePool = [...this.dex.moves.all()].filter(move =>\n\t\t\t\t(move.gen <= this.gen && !move.isNonstandard));\n\t\t} else {\n\t\t\tconst hasAllMovesBan = ruleTable.check('pokemontag:allmoves');\n\t\t\tfor (const move of this.dex.moves.all()) {\n\t\t\t\tlet banReason = ruleTable.check('move:' + move.id);\n\t\t\t\tif (banReason) continue;\n\t\t\t\tif (banReason !== '') {\n\t\t\t\t\tif (hasAllMovesBan) continue;\n\t\t\t\t\tif (move.isNonstandard) {\n\t\t\t\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(move.isNonstandard));\n\t\t\t\t\t\tif (banReason) continue;\n\t\t\t\t\t\tif (banReason !== '' && move.isNonstandard !== 'Unobtainable') {\n\t\t\t\t\t\t\tif (hasNonexistentBan) continue;\n\t\t\t\t\t\t\tif (!hasNonexistentWhitelist) continue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmovePool.push(move);\n\t\t\t}\n\t\t\tthis.enforceCustomPoolSizeNoComplexBans('move', movePool, this.maxTeamSize * setMoveCount, 'Max Team Size * Max Move Count');\n\t\t}\n\n\t\t// Nature Pool\n\t\tconst doNaturesExist = this.gen > 2;\n\t\tlet naturePool: Nature[] = [];\n\t\tif (doNaturesExist) {\n\t\t\tif (!hasCustomBans) {\n\t\t\t\tnaturePool = [...this.dex.natures.all()];\n\t\t\t} else {\n\t\t\t\tconst hasAllNaturesBan = ruleTable.check('pokemontag:allnatures');\n\t\t\t\tfor (const nature of this.dex.natures.all()) {\n\t\t\t\t\tlet banReason = ruleTable.check('nature:' + nature.id);\n\t\t\t\t\tif (banReason) continue;\n\t\t\t\t\tif (banReason !== '' && nature.id) {\n\t\t\t\t\t\tif (hasAllNaturesBan) continue;\n\t\t\t\t\t\tif (nature.isNonstandard) {\n\t\t\t\t\t\t\tbanReason = ruleTable.check('pokemontag:' + toID(nature.isNonstandard));\n\t\t\t\t\t\t\tif (banReason) continue;\n\t\t\t\t\t\t\tif (banReason !== '' && nature.isNonstandard !== 'Unobtainable') {\n\t\t\t\t\t\t\t\tif (hasNonexistentBan) continue;\n\t\t\t\t\t\t\t\tif (!hasNonexistentWhitelist) continue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnaturePool.push(nature);\n\t\t\t\t}\n\t\t\t\t// There is no 'nature:nonature' rule so do not constrain pool size\n\t\t\t}\n\t\t}\n\n\t\tconst randomN = this.randomNPokemon(this.maxTeamSize, this.forceMonotype, undefined,\n\t\t\thasCustomBans ? ruleTable : undefined);\n\n\t\tconst team = [];\n\t\tfor (const forme of randomN) {\n\t\t\t// Choose forme\n\t\t\tconst species = this.dex.species.get(forme);\n\n\t\t\t// Random unique item\n\t\t\tlet item = '';\n\t\t\tlet itemData;\n\t\t\tlet isBadItem;\n\t\t\tif (doItemsExist) {\n\t\t\t\t// We discard TRs and Balls with 95% probability because of their otherwise overwhelming presence\n\t\t\t\tdo {\n\t\t\t\t\titemData = this.sampleNoReplace(itemPool);\n\t\t\t\t\titem = itemData?.name;\n\t\t\t\t\tisBadItem = item.startsWith(\"TR\") || itemData.isPokeball;\n\t\t\t\t} while (isBadItem && this.randomChance(19, 20) && itemPool.length > this.maxTeamSize);\n\t\t\t}\n\n\t\t\t// Random unique ability\n\t\t\tlet ability = 'No Ability';\n\t\t\tlet abilityData;\n\t\t\tif (doAbilitiesExist) {\n\t\t\t\tabilityData = this.sampleNoReplace(abilityPool);\n\t\t\t\tability = abilityData?.name;\n\t\t\t}\n\n\t\t\t// Random unique moves\n\t\t\tconst m = [];\n\t\t\tdo {\n\t\t\t\tconst move = this.sampleNoReplace(movePool);\n\t\t\t\tm.push(move.id);\n\t\t\t} while (m.length < setMoveCount);\n\n\t\t\t// Random EVs\n\t\t\tconst evs = { hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0 };\n\t\t\tif (this.gen === 6) {\n\t\t\t\tlet evpool = 510;\n\t\t\t\tdo {\n\t\t\t\t\tconst x = this.sample(Dex.stats.ids());\n\t\t\t\t\tconst y = this.random(Math.min(256 - evs[x], evpool + 1));\n\t\t\t\t\tevs[x] += y;\n\t\t\t\t\tevpool -= y;\n\t\t\t\t} while (evpool > 0);\n\t\t\t} else {\n\t\t\t\tfor (const x of Dex.stats.ids()) {\n\t\t\t\t\tevs[x] = this.random(256);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Random IVs\n\t\t\tconst ivs: StatsTable = {\n\t\t\t\thp: this.random(32),\n\t\t\t\tatk: this.random(32),\n\t\t\t\tdef: this.random(32),\n\t\t\t\tspa: this.random(32),\n\t\t\t\tspd: this.random(32),\n\t\t\t\tspe: this.random(32),\n\t\t\t};\n\n\t\t\t// Random nature\n\t\t\tlet nature = '';\n\t\t\tif (doNaturesExist && (naturePool.length > 0)) {\n\t\t\t\tnature = this.sample(naturePool).name;\n\t\t\t}\n\n\t\t\t// Level balance\n\t\t\tconst mbstmin = 1307;\n\t\t\tconst stats = species.baseStats;\n\t\t\tlet mbst = (stats['hp'] * 2 + 31 + 21 + 100) + 10;\n\t\t\tmbst += (stats['atk'] * 2 + 31 + 21 + 100) + 5;\n\t\t\tmbst += (stats['def'] * 2 + 31 + 21 + 100) + 5;\n\t\t\tmbst += (stats['spa'] * 2 + 31 + 21 + 100) + 5;\n\t\t\tmbst += (stats['spd'] * 2 + 31 + 21 + 100) + 5;\n\t\t\tmbst += (stats['spe'] * 2 + 31 + 21 + 100) + 5;\n\n\t\t\tlet level;\n\t\t\tif (this.adjustLevel) {\n\t\t\t\tlevel = this.adjustLevel;\n\t\t\t} else {\n\t\t\t\tlevel = Math.floor(100 * mbstmin / mbst);\n\t\t\t\twhile (level < 100) {\n\t\t\t\t\tmbst = Math.floor((stats['hp'] * 2 + 31 + 21 + 100) * level / 100 + 10);\n\t\t\t\t\tmbst += Math.floor(((stats['atk'] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);\n\t\t\t\t\tmbst += Math.floor((stats['def'] * 2 + 31 + 21 + 100) * level / 100 + 5);\n\t\t\t\t\tmbst += Math.floor(((stats['spa'] * 2 + 31 + 21 + 100) * level / 100 + 5) * level / 100);\n\t\t\t\t\tmbst += Math.floor((stats['spd'] * 2 + 31 + 21 + 100) * level / 100 + 5);\n\t\t\t\t\tmbst += Math.floor((stats['spe'] * 2 + 31 + 21 + 100) * level / 100 + 5);\n\t\t\t\t\tif (mbst >= mbstmin) break;\n\t\t\t\t\tlevel++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Random happiness\n\t\t\tconst happiness = this.random(256);\n\n\t\t\t// Random shininess\n\t\t\tconst shiny = this.randomChance(1, 1024);\n\n\t\t\tconst set: PokemonSet = {\n\t\t\t\tname: species.baseSpecies,\n\t\t\t\tspecies: species.name,\n\t\t\t\tgender: species.gender,\n\t\t\t\titem,\n\t\t\t\tability,\n\t\t\t\tmoves: m,\n\t\t\t\tevs,\n\t\t\t\tivs,\n\t\t\t\tnature,\n\t\t\t\tlevel,\n\t\t\t\thappiness,\n\t\t\t\tshiny,\n\t\t\t};\n\t\t\tif (this.gen === 9) {\n\t\t\t\t// Random Tera type\n\t\t\t\tif (this.forceTeraType) {\n\t\t\t\t\tset.teraType = this.forceTeraType;\n\t\t\t\t} else {\n\t\t\t\t\tset.teraType = this.sample(this.dex.types.names());\n\t\t\t\t}\n\t\t\t}\n\t\t\tteam.push(set);\n\t\t}\n\n\t\treturn team;\n\t}\n\n\trandomFactorySets: { [format: string]: { [species: string]: BattleFactorySpecies } } = require('./factory-sets.json');\n\n\trandomFactorySet(\n\t\tspecies: Species, teamData: RandomTeamsTypes.FactoryTeamDetails, tier: string\n\t): RandomTeamsTypes.RandomFactorySet | null {\n\t\tconst id = toID(species.name);\n\t\tconst setList = this.randomFactorySets[tier][id].sets;\n\n\t\tconst itemsLimited = ['choicespecs', 'choiceband', 'choicescarf'];\n\t\tconst movesLimited: { [k: string]: string } = {\n\t\t\tstealthrock: 'stealthRock',\n\t\t\tstoneaxe: 'stealthRock',\n\t\t\tspikes: 'spikes',\n\t\t\tceaselessedge: 'spikes',\n\t\t\ttoxicspikes: 'toxicSpikes',\n\t\t\trapidspin: 'hazardClear',\n\t\t\tdefog: 'hazardClear',\n\t\t};\n\t\tconst abilitiesLimited: { [k: string]: string } = {\n\t\t\ttoxicdebris: 'toxicSpikes',\n\t\t};\n\n\t\t// Build a pool of eligible sets, given the team partners\n\t\t// Also keep track of moves and items limited to one per team\n\t\tconst effectivePool: {\n\t\t\tset: BattleFactorySet, moves?: string[], item?: string,\n\t\t}[] = [];\n\n\t\tfor (const set of setList) {\n\t\t\tlet reject = false;\n\n\t\t\t// limit to 1 dedicated tera user per team\n\t\t\tif (set.wantsTera && teamData.wantsTeraCount) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// reject disallowed items, specifically a second of any given choice item\n\t\t\tconst allowedItems: string[] = [];\n\t\t\tfor (const itemString of set.item) {\n\t\t\t\tconst itemId = toID(itemString);\n\t\t\t\tif (itemsLimited.includes(itemId) && teamData.has[itemId]) continue;\n\t\t\t\tallowedItems.push(itemString);\n\t\t\t}\n\t\t\tif (!allowedItems.length) continue;\n\t\t\tconst item = this.sample(allowedItems);\n\n\t\t\tconst abilityId = toID(this.sample(set.ability));\n\n\t\t\tif (abilitiesLimited[abilityId] && teamData.has[abilitiesLimited[abilityId]]) continue;\n\n\t\t\tconst moves: string[] = [];\n\t\t\tfor (const move of set.moves) {\n\t\t\t\tconst allowedMoves: string[] = [];\n\t\t\t\tfor (const m of move) {\n\t\t\t\t\tconst moveId = toID(m);\n\t\t\t\t\tif (movesLimited[moveId] && teamData.has[movesLimited[moveId]]) continue;\n\t\t\t\t\tallowedMoves.push(m);\n\t\t\t\t}\n\t\t\t\tif (!allowedMoves.length) {\n\t\t\t\t\treject = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tmoves.push(this.sample(allowedMoves));\n\t\t\t}\n\t\t\tif (reject) continue;\n\t\t\teffectivePool.push({ set, moves, item });\n\t\t}\n\n\t\tif (!effectivePool.length) {\n\t\t\tif (!teamData.forceResult) return null;\n\t\t\tfor (const set of setList) {\n\t\t\t\teffectivePool.push({ set });\n\t\t\t}\n\t\t}\n\n\t\t// Sets have individual weight, choose one with weighted random selection\n\n\t\tlet setData = this.sample(effectivePool); // Init with unweighted random set as fallback\n\n\t\tconst total = effectivePool.reduce((a, b) => a + b.set.weight, 0);\n\t\tconst setRand = this.random(total);\n\n\t\tlet cur = 0;\n\t\tfor (const set of effectivePool) {\n\t\t\tcur += set.set.weight;\n\t\t\tif (cur > setRand) {\n\t\t\t\tsetData = set; // Bingo!\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst moves = [];\n\t\tfor (const [i, moveSlot] of setData.set.moves.entries()) {\n\t\t\tmoves.push(setData.moves ? setData.moves[i] : this.sample(moveSlot));\n\t\t}\n\n\t\tconst item = setData.item || this.sample(setData.set.item);\n\n\t\treturn {\n\t\t\tname: species.baseSpecies,\n\t\t\tspecies: (typeof species.battleOnly === 'string') ? species.battleOnly : species.name,\n\t\t\tteraType: this.sample(setData.set.teraType),\n\t\t\tgender:\tsetData.set.gender || species.gender || (tier === 'OU' ? 'F' : ''), // F for Cute Charm Enamorus\n\t\t\titem,\n\t\t\tability: this.sample(setData.set.ability),\n\t\t\tshiny: setData.set.shiny || this.randomChance(1, 1024),\n\t\t\tlevel: this.adjustLevel || (tier === \"LC\" ? 5 : 100),\n\t\t\thappiness: 255,\n\t\t\tevs: { hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0, ...setData.set.evs },\n\t\t\tivs: { hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31, ...setData.set.ivs },\n\t\t\tnature: this.sample(setData.set.nature) || \"Serious\",\n\t\t\tmoves,\n\t\t\twantsTera: setData.set.wantsTera,\n\t\t};\n\t}\n\n\trandomFactoryTeam(side: PlayerOptions, depth = 0): RandomTeamsTypes.RandomFactorySet[] {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tconst forceResult = depth >= 12;\n\n\t\tif (!this.factoryTier) {\n\t\t\t// this.factoryTier = this.sample(['Uber', 'OU', 'UU', 'RU', 'NU', 'PU', 'LC']);\n\t\t\tthis.factoryTier = this.sample(['Uber', 'OU', 'UU', 'RU', 'NU', 'PU']);\n\t\t}\n\n\t\tconst tierValues: { [k: string]: number } = {\n\t\t\tUber: 5,\n\t\t\tOU: 4, UUBL: 4,\n\t\t\tUU: 3, RUBL: 3,\n\t\t\tRU: 2, NUBL: 2,\n\t\t\tNU: 1, PUBL: 1,\n\t\t\tPU: 0,\n\t\t};\n\n\t\tconst pokemon = [];\n\t\tconst pokemonPool = Object.keys(this.randomFactorySets[this.factoryTier]);\n\n\t\tconst teamData: TeamData = {\n\t\t\ttypeCount: {},\n\t\t\ttypeComboCount: {},\n\t\t\tbaseFormes: {},\n\t\t\thas: {},\n\t\t\twantsTeraCount: 0,\n\t\t\tforceResult,\n\t\t\tweaknesses: {},\n\t\t\tresistances: {},\n\t\t};\n\t\tconst resistanceAbilities: { [k: string]: string[] } = {\n\t\t\tdryskin: ['Water'], waterabsorb: ['Water'], stormdrain: ['Water'],\n\t\t\tflashfire: ['Fire'], heatproof: ['Fire'], waterbubble: ['Fire'], wellbakedbody: ['Fire'],\n\t\t\tlightningrod: ['Electric'], motordrive: ['Electric'], voltabsorb: ['Electric'],\n\t\t\tsapsipper: ['Grass'],\n\t\t\tthickfat: ['Ice', 'Fire'],\n\t\t\teartheater: ['Ground'], levitate: ['Ground'],\n\t\t};\n\t\tconst movesLimited: { [k: string]: string } = {\n\t\t\tstealthrock: 'stealthRock',\n\t\t\tstoneaxe: 'stealthRock',\n\t\t\tspikes: 'spikes',\n\t\t\tceaselessedge: 'spikes',\n\t\t\ttoxicspikes: 'toxicSpikes',\n\t\t\trapidspin: 'hazardClear',\n\t\t\tdefog: 'hazardClear',\n\t\t};\n\t\tconst abilitiesLimited: { [k: string]: string } = {\n\t\t\ttoxicdebris: 'toxicSpikes',\n\t\t};\n\t\tconst limitFactor = Math.ceil(this.maxTeamSize / 6);\n\t\t/**\n\t\t * Weighted random shuffle\n\t\t * Uses the fact that for two uniform variables x1 and x2, x1^(1/w1) is larger than x2^(1/w2)\n\t\t * with probability equal to w1/(w1+w2), which is what we want. See e.g. here https://arxiv.org/pdf/1012.0256.pdf,\n\t\t * original paper is behind a paywall.\n\t\t */\n\t\tconst shuffledSpecies = [];\n\t\tfor (const speciesName of pokemonPool) {\n\t\t\tconst sortObject = {\n\t\t\t\tspeciesName,\n\t\t\t\tscore: this.prng.random() ** (1 / this.randomFactorySets[this.factoryTier][speciesName].weight),\n\t\t\t};\n\t\t\tshuffledSpecies.push(sortObject);\n\t\t}\n\t\tshuffledSpecies.sort((a, b) => a.score - b.score);\n\n\t\twhile (shuffledSpecies.length && pokemon.length < this.maxTeamSize) {\n\t\t\t// repeated popping from weighted shuffle is equivalent to repeated weighted sampling without replacement\n\t\t\tconst species = this.dex.species.get(shuffledSpecies.pop()!.speciesName);\n\t\t\tif (!species.exists) continue;\n\n\t\t\t// Lessen the need of deleting sets of Pokemon after tier shifts\n\t\t\tif (\n\t\t\t\tthis.factoryTier in tierValues && species.tier in tierValues &&\n\t\t\t\ttierValues[species.tier] > tierValues[this.factoryTier]\n\t\t\t) continue;\n\n\t\t\tif (this.forceMonotype && !species.types.includes(this.forceMonotype)) continue;\n\n\t\t\t// Limit to one of each species (Species Clause)\n\t\t\tif (teamData.baseFormes[species.baseSpecies]) continue;\n\n\t\t\t// Limit 2 of any type (most of the time)\n\t\t\tconst types = species.types;\n\t\t\tlet skip = false;\n\t\t\tif (!this.forceMonotype) {\n\t\t\t\tfor (const type of types) {\n\t\t\t\t\tif (teamData.typeCount[type] >= 2 * limitFactor && this.randomChance(4, 5)) {\n\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (skip) continue;\n\n\t\t\tif (!teamData.forceResult && !this.forceMonotype) {\n\t\t\t\t// Limit 3 of any weakness\n\t\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\t\t// it's weak to the type\n\t\t\t\t\tif (this.dex.getEffectiveness(typeName, species) > 0 && this.dex.getImmunity(typeName, types)) {\n\t\t\t\t\t\tif (teamData.weaknesses[typeName] >= 3 * limitFactor) {\n\t\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (skip) continue;\n\n\t\t\tconst set = this.randomFactorySet(species, teamData, this.factoryTier);\n\t\t\tif (!set) continue;\n\n\t\t\t// Limit 1 of any type combination\n\t\t\tlet typeCombo = types.slice().sort().join();\n\t\t\tif (set.ability === \"Drought\" || set.ability === \"Drizzle\") {\n\t\t\t\t// Drought and Drizzle don't count towards the type combo limit\n\t\t\t\ttypeCombo = set.ability;\n\t\t\t}\n\t\t\tif (!this.forceMonotype && teamData.typeComboCount[typeCombo] >= limitFactor) continue;\n\n\t\t\t// Okay, the set passes, add it to our team\n\t\t\tpokemon.push(set);\n\n\t\t\t// Now that our Pokemon has passed all checks, we can update team data:\n\t\t\tfor (const type of types) {\n\t\t\t\tif (type in teamData.typeCount) {\n\t\t\t\t\tteamData.typeCount[type]++;\n\t\t\t\t} else {\n\t\t\t\t\tteamData.typeCount[type] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeCombo in teamData.typeComboCount) {\n\t\t\t\tteamData.typeComboCount[typeCombo]++;\n\t\t\t} else {\n\t\t\t\tteamData.typeComboCount[typeCombo] = 1;\n\t\t\t}\n\n\t\t\tteamData.baseFormes[species.baseSpecies] = 1;\n\n\t\t\tteamData.has[toID(set.item)] = 1;\n\n\t\t\tif (set.wantsTera) {\n\t\t\t\tif (!teamData.wantsTeraCount) teamData.wantsTeraCount = 0;\n\t\t\t\tteamData.wantsTeraCount++;\n\t\t\t}\n\n\t\t\tfor (const move of set.moves) {\n\t\t\t\tconst moveId = toID(move);\n\t\t\t\tif (movesLimited[moveId]) {\n\t\t\t\t\tteamData.has[movesLimited[moveId]] = 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ability = this.dex.abilities.get(set.ability);\n\t\t\tif (abilitiesLimited[ability.id]) {\n\t\t\t\tteamData.has[abilitiesLimited[ability.id]] = 1;\n\t\t\t}\n\n\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\tconst typeMod = this.dex.getEffectiveness(typeName, types);\n\t\t\t\t// Track resistances because we will require it for triple weaknesses\n\t\t\t\tif (\n\t\t\t\t\ttypeMod < 0 ||\n\t\t\t\t\tresistanceAbilities[ability.id]?.includes(typeName) ||\n\t\t\t\t\t!this.dex.getImmunity(typeName, types)\n\t\t\t\t) {\n\t\t\t\t\t// We don't care about the number of resistances, so just set to 1\n\t\t\t\t\tteamData.resistances[typeName] = 1;\n\t\t\t\t// Track weaknesses\n\t\t\t\t} else if (typeMod > 0) {\n\t\t\t\t\tteamData.weaknesses[typeName] = (teamData.weaknesses[typeName] || 0) + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!teamData.forceResult && pokemon.length < this.maxTeamSize) return this.randomFactoryTeam(side, ++depth);\n\n\t\t// Quality control we cannot afford for monotype\n\t\tif (!teamData.forceResult && !this.forceMonotype) {\n\t\t\tfor (const type in teamData.weaknesses) {\n\t\t\t\t// We reject if our team is triple weak to any type without having a resist\n\t\t\t\tif (teamData.resistances[type]) continue;\n\t\t\t\tif (teamData.weaknesses[type] >= 3 * limitFactor) return this.randomFactoryTeam(side, ++depth);\n\t\t\t}\n\t\t\t// Try to force Stealth Rock on non-Uber teams\n\t\t\tif (!teamData.has['stealthRock'] && this.factoryTier !== 'Uber') return this.randomFactoryTeam(side, ++depth);\n\t\t}\n\t\treturn pokemon;\n\t}\n\n\trandomBSSFactorySets: AnyObject = require(\"./bss-factory-sets.json\");\n\n\trandomBSSFactorySet(\n\t\tspecies: Species, teamData: RandomTeamsTypes.FactoryTeamDetails\n\t): RandomTeamsTypes.RandomFactorySet | null {\n\t\tconst id = toID(species.name);\n\t\tconst setList = this.randomBSSFactorySets[id].sets;\n\n\t\tconst movesMax: { [k: string]: number } = {\n\t\t\tbatonpass: 1,\n\t\t\tstealthrock: 1,\n\t\t\ttoxicspikes: 1,\n\t\t\ttrickroom: 1,\n\t\t\tauroraveil: 1,\n\t\t};\n\t\tconst weatherAbilities = ['drizzle', 'drought', 'snowwarning', 'sandstream'];\n\t\tconst terrainAbilities: { [k: string]: string } = {\n\t\t\telectricsurge: \"electric\",\n\t\t\tpsychicsurge: \"psychic\",\n\t\t\tgrassysurge: \"grassy\",\n\t\t\tseedsower: \"grassy\",\n\t\t\tmistysurge: \"misty\",\n\t\t};\n\t\tconst terrainItemsRequire: { [k: string]: string } = {\n\t\t\telectricseed: \"electric\",\n\t\t\tpsychicseed: \"psychic\",\n\t\t\tgrassyseed: \"grassy\",\n\t\t\tmistyseed: \"misty\",\n\t\t};\n\n\t\tconst maxWantsTera = 2;\n\n\t\t// Build a pool of eligible sets, given the team partners\n\t\t// Also keep track of sets with moves the team requires\n\t\tconst effectivePool: {\n\t\t\tset: BSSFactorySet, moveVariants?: number[], itemVariants?: number, abilityVariants?: number,\n\t\t}[] = [];\n\n\t\tfor (const curSet of setList) {\n\t\t\tlet reject = false;\n\n\t\t\t// limit to 2 dedicated tera users per team\n\t\t\tif (curSet.wantsTera && teamData.wantsTeraCount && teamData.wantsTeraCount >= maxWantsTera) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// reject 2+ weather setters\n\t\t\tif (teamData.weather && weatherAbilities.includes(curSet.ability)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (terrainAbilities[curSet.ability]) {\n\t\t\t\tif (!teamData.terrain) teamData.terrain = [];\n\t\t\t\tteamData.terrain.push(terrainAbilities[curSet.ability]);\n\t\t\t}\n\n\t\t\tfor (const item of curSet.item) {\n\t\t\t\tif (terrainItemsRequire[item] && !teamData.terrain?.includes(terrainItemsRequire[item])) {\n\t\t\t\t\treject = true; // reject any sets with a seed item possible and no terrain setter to activate it\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst curSetMoveVariants = [];\n\t\t\tfor (const move of curSet.moves) {\n\t\t\t\tconst variantIndex = this.random(move.length);\n\t\t\t\tconst moveId = toID(move[variantIndex]);\n\t\t\t\tif (movesMax[moveId] && teamData.has[moveId] >= movesMax[moveId]) {\n\t\t\t\t\treject = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcurSetMoveVariants.push(variantIndex);\n\t\t\t}\n\t\t\tif (reject) continue;\n\t\t\tconst set = { set: curSet, moveVariants: curSetMoveVariants };\n\t\t\teffectivePool.push(set);\n\t\t}\n\n\t\tif (!effectivePool.length) {\n\t\t\tif (!teamData.forceResult) return null;\n\t\t\tfor (const curSet of setList) {\n\t\t\t\teffectivePool.push({ set: curSet });\n\t\t\t}\n\t\t}\n\n\t\t// Sets have individual weight, choose one with weighted random selection\n\n\t\tlet setData = this.sample(effectivePool); // Init with unweighted random set as fallback\n\n\t\tconst total = effectivePool.reduce((a, b) => a + b.set.weight, 0);\n\t\tconst setRand = this.random(total);\n\n\t\tlet cur = 0;\n\t\tfor (const set of effectivePool) {\n\t\t\tcur += set.set.weight;\n\t\t\tif (cur > setRand) {\n\t\t\t\tsetData = set; // Bingo!\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst moves = [];\n\t\tfor (const [i, moveSlot] of setData.set.moves.entries()) {\n\t\t\tmoves.push(setData.moveVariants ? moveSlot[setData.moveVariants[i]] : this.sample(moveSlot));\n\t\t}\n\n\t\treturn {\n\t\t\tname: setData.set.species || species.baseSpecies,\n\t\t\tspecies: setData.set.species,\n\t\t\tteraType: (this.sampleIfArray(setData.set.teraType)),\n\t\t\tgender:\tsetData.set.gender || species.gender || (this.randomChance(1, 2) ? \"M\" : \"F\"),\n\t\t\titem: this.sampleIfArray(setData.set.item) || \"\",\n\t\t\tability: this.sampleIfArray(setData.set.ability),\n\t\t\tshiny: this.randomChance(1, 1024),\n\t\t\tlevel: 50,\n\t\t\thappiness: 255,\n\t\t\tevs: { hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0, ...setData.set.evs },\n\t\t\tivs: { hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31, ...setData.set.ivs },\n\t\t\tnature: setData.set.nature || \"Serious\",\n\t\t\tmoves,\n\t\t\twantsTera: setData.set.wantsTera,\n\t\t};\n\t}\n\n\trandomBSSFactoryTeam(side: PlayerOptions, depth = 0): RandomTeamsTypes.RandomFactorySet[] {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tconst forceResult = depth >= 4;\n\n\t\tconst pokemon = [];\n\n\t\tconst pokemonPool = Object.keys(this.randomBSSFactorySets);\n\n\t\tconst teamData: TeamData = {\n\t\t\ttypeCount: {},\n\t\t\ttypeComboCount: {},\n\t\t\tbaseFormes: {},\n\t\t\thas: {},\n\t\t\twantsTeraCount: 0,\n\t\t\tforceResult,\n\t\t\tweaknesses: {},\n\t\t\tresistances: {},\n\t\t};\n\t\tconst weatherAbilitiesSet: { [k: string]: string } = {\n\t\t\tdrizzle: \"raindance\",\n\t\t\tdrought: \"sunnyday\",\n\t\t\tsnowwarning: \"hail\",\n\t\t\tsandstream: \"sandstorm\",\n\t\t};\n\t\tconst resistanceAbilities: { [k: string]: string[] } = {\n\t\t\twaterabsorb: [\"Water\"],\n\t\t\tflashfire: [\"Fire\"],\n\t\t\tlightningrod: [\"Electric\"],\n\t\t\tvoltabsorb: [\"Electric\"],\n\t\t\tthickfat: [\"Ice\", \"Fire\"],\n\t\t\tlevitate: [\"Ground\"],\n\t\t};\n\t\tconst limitFactor = Math.ceil(this.maxTeamSize / 6);\n\t\t/**\n\t\t * Weighted random shuffle\n\t\t * Uses the fact that for two uniform variables x1 and x2, x1^(1/w1) is larger than x2^(1/w2)\n\t\t * with probability equal to w1/(w1+w2), which is what we want. See e.g. here https://arxiv.org/pdf/1012.0256.pdf,\n\t\t * original paper is behind a paywall.\n\t\t */\n\t\tconst shuffledSpecies = [];\n\t\tfor (const speciesName of pokemonPool) {\n\t\t\tconst sortObject = {\n\t\t\t\tspeciesName,\n\t\t\t\tscore: this.prng.random() ** (1 / this.randomBSSFactorySets[speciesName].weight),\n\t\t\t};\n\t\t\tshuffledSpecies.push(sortObject);\n\t\t}\n\t\tshuffledSpecies.sort((a, b) => a.score - b.score);\n\n\t\twhile (shuffledSpecies.length && pokemon.length < this.maxTeamSize) {\n\t\t\t// repeated popping from weighted shuffle is equivalent to repeated weighted sampling without replacement\n\t\t\tconst species = this.dex.species.get(shuffledSpecies.pop()!.speciesName);\n\t\t\tif (!species.exists) continue;\n\n\t\t\tif (this.forceMonotype && !species.types.includes(this.forceMonotype)) continue;\n\n\t\t\t// Limit to one of each species (Species Clause)\n\t\t\tif (teamData.baseFormes[species.baseSpecies]) continue;\n\n\t\t\t// Limit 2 of any type (most of the time)\n\t\t\tconst types = species.types;\n\t\t\tlet skip = false;\n\t\t\tif (!this.forceMonotype) {\n\t\t\t\tfor (const type of types) {\n\t\t\t\t\tif (teamData.typeCount[type] >= 2 * limitFactor && this.randomChance(4, 5)) {\n\t\t\t\t\t\tskip = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (skip) continue;\n\n\t\t\tconst set = this.randomBSSFactorySet(species, teamData);\n\t\t\tif (!set) continue;\n\n\t\t\t// Limit 1 of any type combination\n\t\t\tlet typeCombo = types.slice().sort().join();\n\t\t\tif (set.ability === \"Drought\" || set.ability === \"Drizzle\") {\n\t\t\t\t// Drought and Drizzle don't count towards the type combo limit\n\t\t\t\ttypeCombo = set.ability;\n\t\t\t}\n\t\t\tif (!this.forceMonotype && teamData.typeComboCount[typeCombo] >= limitFactor) continue;\n\n\t\t\tconst itemData = this.dex.items.get(set.item);\n\t\t\tif (teamData.has[itemData.id]) continue; // Item Clause\n\n\t\t\t// Okay, the set passes, add it to our team\n\t\t\tpokemon.push(set);\n\n\t\t\t// Now that our Pokemon has passed all checks, we can update team data:\n\t\t\tfor (const type of types) {\n\t\t\t\tif (type in teamData.typeCount) {\n\t\t\t\t\tteamData.typeCount[type]++;\n\t\t\t\t} else {\n\t\t\t\t\tteamData.typeCount[type] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeCombo in teamData.typeComboCount) {\n\t\t\t\tteamData.typeComboCount[typeCombo]++;\n\t\t\t} else {\n\t\t\t\tteamData.typeComboCount[typeCombo] = 1;\n\t\t\t}\n\n\t\t\tteamData.baseFormes[species.baseSpecies] = 1;\n\n\t\t\tteamData.has[itemData.id] = 1;\n\n\t\t\tif (set.wantsTera) {\n\t\t\t\tif (!teamData.wantsTeraCount) teamData.wantsTeraCount = 0;\n\t\t\t\tteamData.wantsTeraCount++;\n\t\t\t}\n\n\t\t\tconst abilityState = this.dex.abilities.get(set.ability);\n\t\t\tif (abilityState.id in weatherAbilitiesSet) {\n\t\t\t\tteamData.weather = weatherAbilitiesSet[abilityState.id];\n\t\t\t}\n\n\t\t\tfor (const move of set.moves) {\n\t\t\t\tconst moveId = toID(move);\n\t\t\t\tif (moveId in teamData.has) {\n\t\t\t\t\tteamData.has[moveId]++;\n\t\t\t\t} else {\n\t\t\t\t\tteamData.has[moveId] = 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const typeName of this.dex.types.names()) {\n\t\t\t\t// Cover any major weakness (3+) with at least one resistance\n\t\t\t\tif (teamData.resistances[typeName] >= 1) continue;\n\t\t\t\tif (resistanceAbilities[abilityState.id]?.includes(typeName) ||\t!this.dex.getImmunity(typeName, types)) {\n\t\t\t\t\t// Heuristic: assume that Pok\u00E9mon with these abilities don't have (too) negative typing.\n\t\t\t\t\tteamData.resistances[typeName] = (teamData.resistances[typeName] || 0) + 1;\n\t\t\t\t\tif (teamData.resistances[typeName] >= 1) teamData.weaknesses[typeName] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst typeMod = this.dex.getEffectiveness(typeName, types);\n\t\t\t\tif (typeMod < 0) {\n\t\t\t\t\tteamData.resistances[typeName] = (teamData.resistances[typeName] || 0) + 1;\n\t\t\t\t\tif (teamData.resistances[typeName] >= 1) teamData.weaknesses[typeName] = 0;\n\t\t\t\t} else if (typeMod > 0) {\n\t\t\t\t\tteamData.weaknesses[typeName] = (teamData.weaknesses[typeName] || 0) + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!teamData.forceResult && pokemon.length < this.maxTeamSize) return this.randomBSSFactoryTeam(side, ++depth);\n\n\t\t// Quality control we cannot afford for monotype\n\t\tif (!teamData.forceResult && !this.forceMonotype) {\n\t\t\tfor (const type in teamData.weaknesses) {\n\t\t\t\tif (teamData.weaknesses[type] >= 3 * limitFactor) return this.randomBSSFactoryTeam(side, ++depth);\n\t\t\t}\n\t\t}\n\n\t\treturn pokemon;\n\t}\n\n\trandomDraftFactoryMatchups: AnyObject = require(\"./draft-factory-matchups.json\").matchups;\n\trdfMatchupIndex = -1;\n\trdfMatchupSide = -1;\n\n\trandomDraftFactoryTeam(side: PlayerOptions): RandomTeamsTypes.RandomDraftFactorySet[] {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tif (this.rdfMatchupIndex === -1) this.rdfMatchupIndex = this.random(0, this.randomDraftFactoryMatchups.length);\n\t\tif (this.rdfMatchupSide === -1) this.rdfMatchupSide = this.random(0, 2);\n\n\t\tconst matchup = this.randomDraftFactoryMatchups[this.rdfMatchupIndex];\n\t\tconst team = Teams.unpack(matchup[this.rdfMatchupSide]);\n\t\tif (!team) throw new Error(`Invalid team for draft factory matchup ${this.rdfMatchupIndex}`);\n\t\tthis.rdfMatchupSide = 1 - this.rdfMatchupSide;\n\t\treturn team.map(set => {\n\t\t\tlet species = this.dex.species.get(set.species);\n\t\t\tif (species.battleOnly) {\n\t\t\t\tif (typeof species.battleOnly !== 'string') {\n\t\t\t\t\tthrow new Error(`Invalid species ${species.name} for draft factory matchup ${this.rdfMatchupIndex} team ${this.rdfMatchupSide}`);\n\t\t\t\t}\n\t\t\t\tspecies = this.dex.species.get(species.battleOnly);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: species.baseSpecies,\n\t\t\t\tspecies: species.name,\n\t\t\t\tgender: set.gender,\n\t\t\t\tmoves: set.moves,\n\t\t\t\tability: set.ability,\n\t\t\t\tevs: set.evs,\n\t\t\t\tivs: set.ivs,\n\t\t\t\titem: set.item,\n\t\t\t\tlevel: this.adjustLevel || set.level,\n\t\t\t\tshiny: !!set.shiny,\n\t\t\t\tnature: set.nature,\n\t\t\t\tteraType: set.teraType,\n\t\t\t\tteraCaptain: set.name === 'Tera Captain',\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport default RandomTeams;\n"], | |
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA0B;AAC1B,iBAAsB;AACtB,kBAAoC;AAEpC,kBAAqB;AACrB,mBAAsB;AAgDf,MAAM,oBAAoB,iBAAM,SAAiB;AAAA,EAGvD,cAAc;AACb,UAAM;AACN,SAAK,gBAAgB,oBAAI,IAAI;AAAA,EAC9B;AACD;AASA,MAAM,iBAAiB;AAAA,EACtB;AAAA,EAAa;AAAA,EAAa;AAAA,EAAa;AAAA,EAAc;AAAA,EAAW;AAAA,EAAS;AAAA,EAAW;AAAA,EAAY;AAAA,EAAc;AAAA,EAAe;AAC9H;AAEA,MAAM,iBAAiB;AAAA,EACtB;AAAA,EAAe;AAAA,EAAe;AAAA,EAAa;AAAA,EAAc;AAAA,EAAY;AAAA,EAAW;AAAA,EAAc;AAC/F;AAEA,MAAM,iBAAiB;AAAA,EACtB;AAAA,EAAa;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAS;AA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