{ "version": 3, "sources": ["../../../data/random-teams.ts"], "sourcesContent": ["import {Dex, toID} from '../sim/dex';\nimport {Utils} from '../lib';\nimport {PRNG, PRNGSeed} from '../sim/prng';\nimport {RuleTable} from '../sim/dex-formats';\nimport {Tags} from './tags';\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\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\tflags: {limEevee?: 1};\n\tsets: BattleFactorySet[];\n}\ninterface BattleFactorySet {\n\tspecies: string;\n\titem: string;\n\tability: string;\n\tnature: string;\n\tmoves: string[];\n\tevs?: Partial;\n\tivs?: Partial;\n}\nexport class MoveCounter extends Utils.Multiset {\n\tdamagingMoves: Set;\n\tironFist: number;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.damagingMoves = new Set();\n\t\tthis.ironFist = 0;\n\t}\n\n\tget(key: string): number {\n\t\treturn super.get(key) || 0;\n\t}\n}\n\ntype MoveEnforcementChecker = (\n\tmovePool: string[], moves: Set, abilities: Set, 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', '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', 'trailblaze',\n];\n// Conglomerate for ease of access\nconst SETUP = [\n\t'acidarmor', 'agility', 'autotomize', 'bellydrum', 'bulkup', 'calmmind', 'clangoroussoul', 'coil', 'cosmicpower', 'curse',\n\t'dragondance', 'flamecharge', 'growth', 'honeclaws', 'howl', 'irondefense', 'meditate', 'nastyplot', 'noretreat', 'poweruppunch',\n\t'quiverdance', 'rockpolish', 'shellsmash', 'shiftgear', 'swordsdance', 'tailglow', 'tidyup', 'trailblaze', 'workup', 'victorydance',\n];\nconst SPEED_CONTROL = [\n\t'electroweb', 'glare', 'icywind', 'lowsweep', 'quash', 'rocktomb', 'stringshot', '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', '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', 'honchkrow', 'mimikyu', 'scizor',\n];\n\n/** Pokemon who should never be in the lead slot */\nconst NO_LEAD_POKEMON = [\n\t'Iron Boulder', 'Slither Wing', 'Zacian', 'Zamazenta',\n];\nconst DOUBLES_NO_LEAD_POKEMON = [\n\t'Basculegion', 'Houndstone', 'Roaring Moon', 'Zacian', 'Zamazenta',\n];\n\nconst DEFENSIVE_TERA_BLAST_USERS = [\n\t'alcremie', 'bellossom', 'comfey', 'florges',\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\tdex: 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\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 && !Array.isArray(prng) ? prng : new PRNG(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'))\n\t\t\t),\n\t\t\tDark: (movePool, moves, abilities, types, counter) => !counter.get('Dark'),\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.has('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 (counter.get('Psychic')) return false;\n\t\t\t\tif (movePool.includes('calmmind') || abilities.has('Strong Jaw')) return true;\n\t\t\t\tif (isDoubles && movePool.includes('psychicfangs')) return true;\n\t\t\t\treturn abilities.has('Psychic Surge') || ['Electric', 'Fighting', 'Fire', 'Grass', 'Poison'].some(m => types.includes(m));\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}\n\n\tsetSeed(prng?: PRNG | PRNGSeed) {\n\t\tthis.prng = prng && !Array.isArray(prng) ? prng : new PRNG(prng);\n\t}\n\n\tgetTeam(options?: PlayerOptions | 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-ignore\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(items: readonly T[]): T {\n\t\treturn this.prng.sample(items);\n\t}\n\n\tsampleIfArray(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.next(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(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.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 | null,\n\t\tspecies: Species,\n\t\tteraType: string,\n\t\tabilities: Set = new Set(),\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.ironFist++;\n\t\t\t\tif (move.flags['sound']) counter.add('sound');\n\t\t\t\tif (move.priority > 0 || (moveid === 'grassyglide' && abilities.has('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,\n\t\tabilities: Set,\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.dex.moves.all()\n\t\t\t.filter(move => move.category === 'Status')\n\t\t\t.map(move => move.id);\n\n\t\t// Team-based move culls\n\t\tif (teamDetails.screens && movePool.length >= this.maxMoveCount + 2) {\n\t\t\tif (movePool.includes('reflect')) this.fastPop(movePool, movePool.indexOf('reflect'));\n\t\t\tif (movePool.includes('lightscreen')) this.fastPop(movePool, movePool.indexOf('lightscreen'));\n\t\t\tif (moves.size + movePool.length <= this.maxMoveCount) return;\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\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', 'waterspout', '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\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['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['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['toxic', ['willowisp', 'thunderwave']],\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// Beartic\n\t\t\t['snowscape', 'swordsdance'],\n\t\t\t// Magnezone\n\t\t\t['bodypress', 'mirrorcoat'],\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', 'strengthsap'], 'encore');\n\n\t\tif (!types.includes('Dark') && teraType !== 'Dark') this.incompatibleMoves(moves, movePool, 'knockoff', 'suckerpunch');\n\n\t\tif (!abilities.has('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 === 'cyclizar') this.incompatibleMoves(moves, movePool, 'taunt', 'knockoff');\n\t\tif (species.id === 'mesprit') this.incompatibleMoves(moves, movePool, 'healingwish', 'uturn');\n\t\tif (species.id === 'camerupt') this.incompatibleMoves(moves, movePool, 'roar', 'willowisp');\n\t}\n\n\t// Checks for and removes incompatible moves, starting with the first move in movesA.\n\tincompatibleMoves(\n\t\tmoves: Set,\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,\n\t\ttypes: string[],\n\t\tabilities: Set,\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: Set, 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.has('Aerilate')) return 'Flying';\n\t\t\tif (abilities.has('Galvanize')) return 'Electric';\n\t\t\tif (abilities.has('Pixilate')) return 'Fairy';\n\t\t\tif (abilities.has('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: Set,\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 {\n\t\tconst moves = new Set();\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.has('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 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 Flip Turn on pure Water-type Wallbreakers\n\t\tif (types.length === 1 && types.includes('Water') && role === 'Wallbreaker') {\n\t\t\tif (movePool.includes('flipturn')) {\n\t\t\t\tcounter = this.addMove('flipturn', 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 = ['auroraveil', '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.has('Prankster') || abilities.has('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.has('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.has('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 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}\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,\n\t\tabilities: Set,\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\tif ([\n\t\t\t'Armor Tail', 'Battle Bond', 'Early Bird', 'Flare Boost', 'Galvanize', 'Gluttony', 'Harvest', 'Hydration', 'Ice Body', 'Immunity',\n\t\t\t'Liquid Voice', 'Marvel Scale', 'Misty Surge', 'Moody', 'Pressure', 'Quick Feet', 'Rain Dish', 'Sand Veil', 'Shed Skin',\n\t\t\t'Sniper', 'Snow Cloak', 'Steadfast', 'Steam Engine', 'Sweet Veil',\n\t\t].includes(ability)) return true;\n\n\t\tswitch (ability) {\n\t\t// Abilities which are primarily useful for certain moves\n\t\tcase 'Contrary': case 'Serene Grace': case 'Skill Link': case 'Strong Jaw':\n\t\t\treturn !counter.get(toID(ability));\n\t\tcase 'Chlorophyll':\n\t\t\treturn (!moves.has('sunnyday') && !teamDetails.sun && species.id !== 'lilligant');\n\t\tcase 'Cloud Nine':\n\t\t\treturn (species.id !== 'golduck');\n\t\tcase 'Competitive':\n\t\t\treturn (species.id === 'kilowattrel' && !isDoubles);\n\t\tcase 'Compound Eyes': case 'No Guard':\n\t\t\treturn !counter.get('inaccurate');\n\t\tcase 'Cursed Body':\n\t\t\treturn abilities.has('Infiltrator');\n\t\tcase 'Defiant':\n\t\t\treturn (!counter.get('Physical') || (abilities.has('Prankster') && (moves.has('thunderwave') || moves.has('taunt'))));\n\t\tcase 'Flame Body':\n\t\t\treturn (species.id === 'magcargo' && moves.has('shellsmash'));\n\t\tcase 'Flash Fire':\n\t\t\treturn (\n\t\t\t\t['Drought', 'Flame Body', 'Intimidate', 'Rock Head', 'Weak Armor'].some(m => abilities.has(m)) &&\n\t\t\t\tthis.dex.getEffectiveness('Fire', species) < 0\n\t\t\t);\n\t\tcase 'Guts':\n\t\t\treturn (!moves.has('facade') && !moves.has('sleeptalk'));\n\t\tcase 'Hustle':\n\t\t\t// some of this is just for Delibird in singles/doubles\n\t\t\treturn (!counter.get('Physical') || moves.has('fakeout') || moves.has('rapidspin'));\n\t\tcase 'Infiltrator':\n\t\t\treturn (isDoubles && abilities.has('Clear Body'));\n\t\tcase 'Insomnia':\n\t\t\treturn (role === 'Wallbreaker');\n\t\tcase 'Intimidate':\n\t\t\tif (abilities.has('Hustle')) return true;\n\t\t\tif (abilities.has('Sheer Force') && !!counter.get('sheerforce')) return true;\n\t\t\tif (species.id === 'hitmontop' && moves.has('tripleaxel')) return true;\n\t\t\treturn (abilities.has('Stakeout'));\n\t\tcase 'Iron Fist':\n\t\t\treturn !counter.ironFist || moves.has('dynamicpunch');\n\t\tcase 'Justified':\n\t\t\treturn !counter.get('Physical');\n\t\tcase 'Libero': case 'Protean':\n\t\t\treturn role === 'Offensive Protect' || (species.id === 'meowscarada' && role === 'Fast Attacker');\n\t\tcase 'Lightning Rod':\n\t\t\treturn species.id === 'rhyperior';\n\t\tcase 'Mold Breaker':\n\t\t\treturn (['Sharpness', 'Sheer Force', 'Unburden'].some(m => abilities.has(m)));\n\t\tcase 'Moxie':\n\t\t\treturn (!counter.get('Physical') || moves.has('stealthrock'));\n\t\tcase 'Natural Cure':\n\t\t\treturn species.id === 'pawmot';\n\t\tcase 'Neutralizing Gas':\n\t\t\treturn !isDoubles;\n\t\tcase 'Overcoat':\n\t\t\treturn types.includes('Grass');\n\t\tcase 'Overgrow':\n\t\t\treturn !counter.get('Grass');\n\t\tcase 'Own Tempo':\n\t\t\treturn (!isDoubles || (counter.get('Special')) > 1);\n\t\tcase 'Prankster':\n\t\t\treturn (!counter.get('Status') || (species.id === 'grafaiai' && role === 'Setup Sweeper'));\n\t\tcase 'Reckless':\n\t\t\treturn !counter.get('recoil');\n\t\tcase 'Regenerator':\n\t\t\treturn (species.id === 'mienshao' && role === 'Wallbreaker');\n\t\tcase 'Rock Head':\n\t\t\treturn !counter.get('recoil');\n\t\tcase 'Sand Force': case 'Sand Rush':\n\t\t\treturn !teamDetails.sand;\n\t\tcase 'Sap Sipper':\n\t\t\treturn species.id === 'wyrdeer';\n\t\tcase 'Seed Sower':\n\t\t\treturn role === 'Bulky Support';\n\t\tcase 'Sheer Force':\n\t\t\tconst braviaryCase = (species.id === 'braviaryhisui' && (role === 'Wallbreaker' || role === 'Bulky Protect'));\n\t\t\tconst abilitiesCase = (abilities.has('Guts') || abilities.has('Sharpness'));\n\t\t\tconst movesCase = (moves.has('bellydrum') || moves.has('flamecharge'));\n\t\t\treturn (!counter.get('sheerforce') || braviaryCase || abilitiesCase || movesCase);\n\t\tcase 'Slush Rush':\n\t\t\treturn !teamDetails.snow;\n\t\tcase 'Solar Power':\n\t\t\treturn (!teamDetails.sun || !counter.get('Special'));\n\t\tcase 'Speed Boost':\n\t\t\treturn (species.id === 'yanmega' && !moves.has('protect'));\n\t\tcase 'Sticky Hold':\n\t\t\treturn (species.id === 'muk');\n\t\tcase 'Sturdy':\n\t\t\treturn (!!counter.get('recoil') && species.id !== 'skarmory');\n\t\tcase 'Swarm':\n\t\t\treturn (!counter.get('Bug') || !!counter.get('recovery'));\n\t\tcase 'Swift Swim':\n\t\t\treturn (abilities.has('Intimidate') || (!moves.has('raindance') && !teamDetails.rain));\n\t\tcase 'Synchronize':\n\t\t\treturn (species.id !== 'umbreon' && species.id !== 'rabsca');\n\t\tcase 'Technician':\n\t\t\treturn (!counter.get('technician') || abilities.has('Punk Rock') || abilities.has('Fur Coat'));\n\t\tcase 'Tinted Lens':\n\t\t\tconst hbraviaryCase = (species.id === 'braviaryhisui' && (role === 'Setup Sweeper' || role === 'Doubles Wallbreaker'));\n\t\t\tconst yanmegaCase = (species.id === 'yanmega' && moves.has('protect'));\n\t\t\treturn (yanmegaCase || hbraviaryCase || species.id === 'illumise');\n\t\tcase 'Unaware':\n\t\t\treturn (species.id === 'clefable' && role !== 'Bulky Support');\n\t\tcase 'Unburden':\n\t\t\treturn (abilities.has('Prankster') || !counter.get('setup') || species.id === 'sceptile');\n\t\tcase 'Vital Spirit':\n\t\t\t// Magmar and Electabuzz want their contact status abilities in Doubles\n\t\t\treturn (species.nfe && isDoubles);\n\t\tcase 'Volt Absorb':\n\t\t\tif (abilities.has('Iron Fist') && counter.ironFist >= 2) return true;\n\t\t\treturn (this.dex.getEffectiveness('Electric', species) < -1);\n\t\tcase 'Water Absorb':\n\t\t\treturn (['lanturn', 'politoed', 'quagsire'].includes(species.id) || moves.has('raindance'));\n\t\tcase 'Weak Armor':\n\t\t\treturn (moves.has('shellsmash') && species.id !== 'magcargo');\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tgetAbility(\n\t\ttypes: string[],\n\t\tmoves: Set,\n\t\tabilities: Set,\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\tconst abilityData = Array.from(abilities).map(a => this.dex.abilities.get(a));\n\t\tUtils.sortBy(abilityData, abil => -abil.rating);\n\n\t\tif (abilityData.length <= 1) return abilityData[0].name;\n\n\t\t// Hard-code abilities here\n\t\tif (species.id === 'florges') return 'Flower Veil';\n\t\tif (species.id === 'bombirdier' && !counter.get('Rock')) return 'Big Pecks';\n\t\tif (species.id === 'scovillain') return 'Chlorophyll';\n\t\tif (species.id === 'empoleon') return 'Competitive';\n\t\tif (species.id === 'swampert' && !counter.get('Water') && !moves.has('flipturn')) return 'Damp';\n\t\tif (species.id === 'dodrio') return 'Early Bird';\n\t\tif (species.id === 'chandelure') return 'Flash Fire';\n\t\tif (species.id === 'golemalola' && moves.has('doubleedge')) return 'Galvanize';\n\t\tif (abilities.has('Guts') && (moves.has('facade') || moves.has('sleeptalk') || species.id === 'gurdurr')) return 'Guts';\n\t\tif (species.id === 'copperajah' && moves.has('heavyslam')) return 'Heavy Metal';\n\t\tif (species.id === 'jumpluff') return 'Infiltrator';\n\t\tif (species.id === 'toucannon' && !counter.get('skilllink')) return 'Keen Eye';\n\t\tif (species.id === 'reuniclus') return 'Magic Guard';\n\t\tif (species.id === 'smeargle' && !counter.get('technician')) return 'Own Tempo';\n\t\tif (species.id === 'zebstrika') return (moves.has('wildcharge')) ? 'Sap Sipper' : 'Lightning Rod';\n\t\tif (species.id === 'sandaconda' || (species.id === 'scrafty' && moves.has('rest'))) return 'Shed Skin';\n\t\tif (species.id === 'cetitan' && (role === 'Wallbreaker' || isDoubles)) return 'Sheer Force';\n\t\tif (species.id === 'dipplin') return 'Sticky Hold';\n\t\tif (species.id === 'breloom' || species.id === 'cinccino') return 'Technician';\n\t\tif (species.id === 'shiftry' && moves.has('tailwind')) return 'Wind Rider';\n\n\t\t// singles\n\t\tif (!isDoubles) {\n\t\t\tif (species.id === 'hypno') return 'Insomnia';\n\t\t\tif (species.id === 'staraptor') return 'Reckless';\n\t\t\tif (species.id === 'arcaninehisui') return 'Rock Head';\n\t\t\tif (['raikou', 'suicune', 'vespiquen'].includes(species.id)) return 'Pressure';\n\t\t\tif (species.id === 'enamorus' && moves.has('calmmind')) return 'Cute Charm';\n\t\t\tif (species.id === 'klawf' && role === 'Setup Sweeper') return 'Anger Shell';\n\t\t\tif (abilities.has('Cud Chew') && moves.has('substitute')) return 'Cud Chew';\n\t\t\tif (abilities.has('Harvest') && (moves.has('protect') || moves.has('substitute'))) return 'Harvest';\n\t\t\tif (abilities.has('Serene Grace') && moves.has('headbutt')) return 'Serene Grace';\n\t\t\tif (abilities.has('Own Tempo') && moves.has('petaldance')) return 'Own Tempo';\n\t\t\tif (abilities.has('Slush Rush') && moves.has('snowscape')) return 'Slush Rush';\n\t\t\tif (abilities.has('Soundproof') && (moves.has('substitute') || counter.get('setup'))) return 'Soundproof';\n\t\t}\n\n\t\t// doubles, multi, and ffa\n\t\tif (isDoubles) {\n\t\t\tif (species.id === 'gumshoos' || species.id === 'porygonz') return 'Adaptability';\n\t\t\tif (species.id === 'farigiraf') return 'Armor Tail';\n\t\t\tif (species.id === 'dragapult') return 'Clear Body';\n\t\t\tif (species.id === 'altaria') return 'Cloud Nine';\n\t\t\tif (species.id === 'meowsticf') return 'Competitive';\n\t\t\tif (species.id === 'armarouge' && !moves.has('meteorbeam')) return 'Flash Fire';\n\t\t\tif (species.id === 'talonflame') return 'Gale Wings';\n\t\t\tif (\n\t\t\t\t['oinkologne', 'oinkolognef', 'snorlax', 'swalot'].includes(species.id) && role !== 'Doubles Wallbreaker'\n\t\t\t) return 'Gluttony';\n\t\t\tif (species.id === 'conkeldurr' && role === 'Doubles Wallbreaker') return 'Guts';\n\t\t\tif (species.id !== 'arboliva' && abilities.has('Harvest')) return 'Harvest';\n\t\t\tif (species.id === 'dragonite' || species.id === 'lucario') return 'Inner Focus';\n\t\t\tif (species.id === 'ariados') return 'Insomnia';\n\t\t\tif (species.id === 'primarina') return 'Liquid Voice';\n\t\t\tif (species.id === 'kommoo') return 'Soundproof';\n\t\t\tif (\n\t\t\t\t(species.id === 'flapple' && role === 'Doubles Bulky Attacker') ||\n\t\t\t\t(species.id === 'appletun' && this.randomChance(1, 2))\n\t\t\t) return 'Ripen';\n\t\t\tif (species.id === 'magnezone') return 'Sturdy';\n\t\t\tif (species.id === 'clefable' && role === 'Doubles Support') return 'Unaware';\n\t\t\tif (['drifblim', 'hitmonlee', 'sceptile'].includes(species.id) && !moves.has('shedtail')) return 'Unburden';\n\t\t\tif (abilities.has('Intimidate')) return 'Intimidate';\n\n\t\t\tif (this.randomChance(1, 2) && species.id === 'kingambit') return 'Defiant';\n\n\t\t\t// just doubles and multi\n\t\t\tif (this.format.gameType !== 'freeforall') {\n\t\t\t\tif (\n\t\t\t\t\tspecies.id === 'clefairy' ||\n\t\t\t\t\t(species.baseSpecies === 'Maushold' && role === 'Doubles Support')\n\t\t\t\t) return 'Friend Guard';\n\t\t\t\tif (species.id === 'blissey') return 'Healer';\n\t\t\t\tif (species.id === 'sinistcha') return 'Hospitality';\n\t\t\t\tif (species.id === 'duraludon') return 'Stalwart';\n\t\t\t\tif (species.id === 'barraskewda') return 'Propeller Tail';\n\t\t\t\tif (species.id === 'oranguru' || abilities.has('Pressure') && abilities.has('Telepathy')) return 'Telepathy';\n\n\t\t\t\tif (this.randomChance(1, 2) && species.id === 'mukalola') return 'Power of Alchemy';\n\t\t\t}\n\t\t}\n\n\t\tlet abilityAllowed: Ability[] = [];\n\t\t// Obtain a list of abilities that are allowed (not culled)\n\t\tfor (const ability of abilityData) {\n\t\t\tif (ability.rating >= 1 && !this.shouldCullAbility(\n\t\t\t\tability.name, 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// If all abilities are rejected, re-allow all abilities\n\t\tif (!abilityAllowed.length) {\n\t\t\tfor (const ability of abilityData) {\n\t\t\t\tif (ability.rating > 0) abilityAllowed.push(ability);\n\t\t\t}\n\t\t\tif (!abilityAllowed.length) abilityAllowed = abilityData;\n\t\t}\n\n\t\tif (abilityAllowed.length === 1) return abilityAllowed[0].name;\n\t\t// Sort abilities by rating with an element of randomness\n\t\t// All three abilities can be chosen\n\t\tif (abilityAllowed[2] && abilityAllowed[0].rating - 0.5 <= abilityAllowed[2].rating) {\n\t\t\tif (abilityAllowed[1].rating <= abilityAllowed[2].rating) {\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[1], abilityAllowed[2]] = [abilityAllowed[2], abilityAllowed[1]];\n\t\t\t} else {\n\t\t\t\tif (this.randomChance(1, 3)) [abilityAllowed[1], abilityAllowed[2]] = [abilityAllowed[2], abilityAllowed[1]];\n\t\t\t}\n\t\t\tif (abilityAllowed[0].rating <= abilityAllowed[1].rating) {\n\t\t\t\tif (this.randomChance(2, 3)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\n\t\t\t} else {\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\n\t\t\t}\n\t\t} else {\n\t\t\t// Third ability cannot be chosen\n\t\t\tif (abilityAllowed[0].rating <= abilityAllowed[1].rating) {\n\t\t\t\tif (this.randomChance(1, 2)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\n\t\t\t} else if (abilityAllowed[0].rating - 0.5 <= abilityAllowed[1].rating) {\n\t\t\t\tif (this.randomChance(1, 3)) [abilityAllowed[0], abilityAllowed[1]] = [abilityAllowed[1], abilityAllowed[0]];\n\t\t\t}\n\t\t}\n\n\t\t// After sorting, choose the first ability\n\t\treturn abilityAllowed[0].name;\n\t}\n\n\tgetPriorityItem(\n\t\tability: string,\n\t\ttypes: string[],\n\t\tmoves: Set,\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 (\n\t\t\t\t!isLead && role === 'Bulky Setup' &&\n\t\t\t\t(ability === 'Quark Drive' || ability === 'Protosynthesis')\n\t\t\t) {\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 (species.id === 'smeargle') return 'Focus Sash';\n\t\tif (species.id === 'froslass' || moves.has('populationbomb')) return 'Wide Lens';\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 (moves.has('lastrespects') || moves.has('dragonenergy')) return 'Choice Scarf';\n\t\tif (\n\t\t\tability === 'Imposter' ||\n\t\t\t(species.id === 'magnezone' && moves.has('bodypress') && !isDoubles)\n\t\t) return 'Choice Scarf';\n\t\tif (species.id === 'rampardos' && (role === 'Fast Attacker' || isDoubles)) return 'Choice Scarf';\n\t\tif (species.id === 'luvdisc' || moves.has('courtchange')) 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 (species.nfe) return 'Eviolite';\n\t\tif (ability === 'Poison Heal') return 'Toxic Orb';\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 (species.id === 'reuniclus' || (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,\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\n\t\tif (species.id === 'ursalunabloodmoon' || (moves.has('doubleedge') && moves.has('fakeout'))) 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 (moves.has('waterspout')) return 'Choice Scarf';\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') ||\n\t\t\tspecies.id === 'eternatus'\n\t\t) return 'Leftovers';\n\t\tif (species.id === 'sylveon') return 'Pixie Plate';\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') || species.baseStats.atk >= 120 || 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') &&\n\t\t\t\t['firstimpression', 'uturn', 'voltswitch'].every(m => !moves.has(m)) && species.id !== 'ironvaliant'\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\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,\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 (types.includes('Normal') && moves.has('fakeout')) return 'Silk Scarf';\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', 'partingshot', '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' && !counter.get('Physical')\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 (species.id === 'palkia') return 'Lustrous Orb';\n\t\tif (moves.has('substitute')) return 'Leftovers';\n\t\tif (moves.has('stickyweb') && species.id !== 'araquanid' && isLead) 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\t(species.id === 'garchomp' && role === 'Fast Support') || (\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) return 'Rocky Helmet';\n\t\tif (moves.has('outrage')) return 'Lum Berry';\n\t\tif (moves.has('protect') && ability !== 'Speed Boost') return 'Leftovers';\n\t\tif (\n\t\t\trole === 'Fast Support' && isLead &&\n\t\t\t!counter.get('recovery') && !counter.get('recoil') &&\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 (\n\t\t\t['Fast Bulky Setup', 'Fast Attacker', 'Setup Sweeper', 'Wallbreaker'].some(m => role === m) &&\n\t\t\ttypes.includes('Dark') && moves.has('suckerpunch') && !PRIORITY_POKEMON.includes(species.id) &&\n\t\t\tcounter.get('physicalsetup') && counter.get('Dark')\n\t\t) return 'Black Glasses';\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> = {\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 as any)[`random${isDoubles ? 'Doubles' : ''}Sets`][species.id][\"sets\"];\n\t\tconst possibleSets = [];\n\n\t\tconst ruleTable = this.dex.formats.getRuleTable(this.format);\n\n\t\tfor (const set of sets) {\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 = new Set(Object.values(species.abilities));\n\t\tif (species.unreleasedHidden) abilities.delete(species.abilities.H);\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'].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))) {\n\t\t\t\t// Two Substitutes should activate Sitrus Berry\n\t\t\t\tif (hp % 4 === 0) break;\n\t\t\t} else if ((moves.has('bellydrum') || moves.has('filletaway')) && (item === 'Sitrus Berry' || ability === 'Gluttony')) {\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\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// Magearna and doubles Dragonite, though these can work well as a general rule\n\t\t\tif (move.id === 'terablast' && (\n\t\t\t\tspecies.id === 'porygon2' || moves.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('./random-sets.json');\n\trandomDoublesSets: {[species: string]: RandomTeamsTypes.RandomSpeciesData} = require('./random-doubles-sets.json');\n\n\trandomTeam() {\n\t\tthis.enforceNoDirectCustomBanlistChanges();\n\n\t\tconst seed = this.prng.seed;\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 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 ((species.baseSpecies === 'Ogerpon' || species.baseSpecies === 'Terapagos') && 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\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}\n\t\t\t\tif (skip) continue;\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}\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('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' || species.baseSpecies === \"Ogerpon\" || species.baseSpecies === \"Terapagos\") {\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.all()).name;\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\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 isNotCustom = !ruleTable;\n\n\t\tconst pool: number[] = [];\n\t\tlet speciesPool: Species[] = [];\n\t\tif (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} 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);\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}\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.all()).name;\n\t\t\t\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