(Last edited: 10 Apr 2016) *** CHANGES *** - Apr16: Corrected boundary condition for AI_Smart_Meanlook - Apr16: Corrected AI_Smart_Sleep (only encourages if enemy has Dream Eater or Nightmare and only 50/50 in that case) - Nov15: Cleaned up some formatting and wording in the writeup - Sep15: Corrected boundary conditions for HP comparisons (1/4, 1/2) and speed comparisons - Sep15: Corrected heal items -> Whether enemy is confused is irrelevant for choosing to use item -> 20% (not 50%) to heal when 25% < enemy's HP <= 50% - Sep15: Clarified that the 'first turn' check in the CAUTIOUS layer refers to the enemy's first turn - Sep15: Corrected error in Rain Dance / Sunny Day section (previously mixed 'player' up with 'enemy' in useful move check) *** TODO *** - Apr16: CheckPlayerMoveTypeMatchups function is not completely accounted for: affects Smart layers (MeanLook, PerishSong, BatonPass, Whirlwind) —> Cutoffs for ‘Player has shown NVE / neutral / SE moves’ - Aug15: Differences between Gold & Crystal (esp. things that might have been added/modified for Battle Tower)? - Aug15: Revisit various assumptions that I didn't check thoroughly [[ Ed. Note ]] Massive credit to the pokecrystal (https://github.com/pret/pokecrystal) contributors, who did most of the difficult work. I am borrowing much of their terminology and findings with some additions, corrections/clarifications, and a more readable writeup. For those that didn't find this through the PSR forums, the corresponding thread can be found here: http://forums.pokemonspeedruns.com/viewtopic.php?f=7&t=490. Any item denoted with question marks (??) indicates that I haven't confirmed it through in-game testing. I. BASICS All moves start with an equal score (20). There are 10 ‘layers’ of AI; different trainer classes have different combinations of these layers. When choosing a move, each layer is navigated and might encourage (decrease the score of) or discourage (increase the score of) some of the enemy’s moves, depending on the current state of the battle. After going through each layer of AI, the move with the lowest score is selected. If there are ties, one of the moves with the lowest score is randomly selected. (The actual mechanics are a bit more convoluted than this, but this is in effect what happens.) Unlike in Gen 1, the trainers do not ‘cheat’. They make their decisions before the player character chooses what to do. II. ITEMS/SWITCHING Before checking for moves, trainers with items will do a check to possibly use an item, if their highest level Pokemon (including ties) is currently out. There is a lot of logic, but only a few items are actually used in practice: (a) Dire Hit - 50/50 on enemy’s first turn. (b) Full Heal - Always used if statused (c) Hyper Potion/Max Potion - Always used if enemy's HP is 25% or below - 20% (50/256) if 25% < enemy’s HP <= 50% (d) Full Restore - Always used if statused - Always used if enemy's HP is 25% or below - 20% (50/256) if 25% < enemy’s HP <= 50% Trainers can also switch Pokemon before the move checks, but I haven’t delved into the details. One situation they will always switch is if their currently active Pokemon’s perish count is at 1. Apart from that, it appears rare (at best). (??) III. TRAINER CLASSES AND LAYERS Everyone has the BASIC + STATUS layers except for wild Pokemon and Twins (who choose moves at random). The RISKY layer is worth singling out; trainers with this layer will essentially lock in to moves that can KO (with the exception of a few ‘risky’ moves). ‘Can KO’ effectively means ‘has a chance to KO, barring crits or max damage rolls’. SMART is the most complex layer and is effectively comprised of a large number of sub-layers. SMART is reserved for the ‘boss’ battles, as well as the outcasts of the pokeworld (Super Nerds/Jugglers/Pokefans). Trainer classes approximately sorted by complexity/difficulty: ***** NON-SMART, NON-RISKY AI ***** Wild Pokemon/Twins : NO AI Youngster : BASIC + STATUS Lass/Picnicker/Camper : BASIC + CAUTIOUS + STATUS Bug Catcher : BASIC + SETUP + STATUS Hiker : BASIC + OFFENSIVE + STATUS Gentleman : BASIC + SETUP + AGGRESSIVE + STATUS Teacher : BASIC + OPPORTUNIST + AGGRESSIVE + STATUS Sailor : BASIC + OFFENSIVE + OPPORTUNIST + STATUS Burglar : BASIC + OFFENSIVE + CAUTIOUS + STATUS Boarder/Officer : BASIC + TYPES + OPPORTUNIST + STATUS Bird Keeper : BASIC + TYPES + OFFENSIVE + OPPORTUNIST + STATUS Beauty/Fisher/Psychic/Kimono Girl : BASIC + TYPES + OPPORTUNIST + CAUTIOUS + STATUS Pokemaniac : BASIC + SETUP + OFFENSIVE + AGGRESSIVE + STATUS Swimmer (M) : BASIC + SETUP + TYPES + OFFENSIVE + STATUS Swimmer (F)/Guitarist : BASIC + SETUP + TYPES + CAUTIOUS + STATUS Firebreather : BASIC + SETUP + OFFENSIVE + OPPORTUNIST + STATUS Schoolboy : BASIC + SETUP + TYPES + OPPORTUNIST + CAUTIOUS + STATUS ***** SMART, NON-RISKY AI ***** Super Nerd/Juggler/Pokefan (M/F) : BASIC + TYPES + SMART + STATUS ***** RISKY, NON-SMART AI ***** Biker : BASIC + TYPES + STATUS + RISKY Blackbelt : BASIC + OFFENSIVE + STATUS + RISKY Scientist/Skier : BASIC + SETUP + TYPES + STATUS + RISKY Sage/Medium : BASIC + SETUP + TYPES + CAUTIOUS + STATUS + RISKY Grunt (F) : BASIC + TYPES + OPPORTUNIST + CAUTIOUS + STATUS + RISKY Grunt (M) : BASIC + SETUP + TYPES + OPPORTUNIST + CAUTIOUS + STATUS + RISKY ***** SMART, RISKY AI ***** Executive (M/F) : BASIC + SETUP + TYPES + SMART + OPPORTUNIST + CAUTIOUS + STATUS + RISKY "Boss" (Gym Leader/Elite 4/Cooltrainer (F/M)/Rival/Eusine/Lance/Red) : BASIC + SETUP + SMART + AGGRESSIVE + CAUTIOUS + STATUS + RISKY IV. SCORING LAYER MECHANICS The probabilities and the impact of each clause on a move’s score is inlined below. E.g. (+1) = score of relevant move(s) is increased by 1. ‘Enemy’ always refers to the NPC AI's currently active Pokemon. ‘Player’ always refers to the player character's currently active Pokemon. NOTE - 'First turn' clause: Use of items does not increment a Pokemon's turn number in battle. Therefore, if the player character uses an item on the first turn of its currently active Pokemon, it will remain that Pokemon’s ‘first turn’ for the purposes of AI. Can be seen in the following layers: - (2) SETUP - (7) CAUTIOUS - [10.18] Smart_Bind - [10.22] Smart_SpeedDownHit - [10.42] Smart_Curse - [10.49] Smart_Swagger | Smart_Attract - [10.55] Smart_RainDance - [10.56] Smart_SunnyDay (1) BASIC ; Don’t do anything redundant. > Everyone (except Twins & Wild Pokemon) (a) Dismiss (+10) moves with special effects if they are useless or not a good choice right now. > Recover, Softboiled, Rest, Milk Drink, Morning Sun, Synthesis, Moonlight, Light Screen, Mist, Focus Energy, Transform, Reflect, Substitute, Snore, Sleep Talk, Mean Look, Nightmare, Spikes, Foresight, Perish Song, Safeguard, Sandstorm, Rain Dance, Sunny Day, Teleport, Future Sight, Dream Eater, Leech Seed, Disable, Encore, Attract, Supersonic, Confuse Ray, Sweet Kiss, Swagger NOTE - The only non-obvious case(s): Supersonic, Confuse Ray, Sweet Kiss consider whether player currently has a Safeguard in effect; however, this check is not performed when considering Swagger. (b) Dismiss (+10) status-only moves if the player can't be statused, taking into account whether the player currently has a Safeguard in effect. > Sing, Sleep Powder, Hypnosis, Lovely Kiss, Spore, Toxic, Poisonpowder, Poison Gas, Stun Spore, Thunder Wave, Glare NOTE - The disassembly includes a note (‘dismiss Safeguard if it's already active’), but this is inaccurate; as mentioned above, this is a check to see if the player character's team has a safeguard active. (Also quite kind of Game Freak to not include checks for Mist/Guard Spec on stat-down moves as they do for Safeguard on status moves, making Red far more reasonable to deal with.) (2) SETUP ; Use stat-modifying moves on turn 1 > Bug Catcher, Gentleman, Pokemaniac, Swimmer (M/F), Guitarist, Firebreather, Schoolboy, Scientist, Skier, Sage, Medium, Grunt (M), Executive (M/F), "Boss" (a) 50% to greatly encourage (-2) stat-up moves during the enemy's first turn. > Meditate, Sharpen, Swords Dance, Harden, Withdraw, Barrier, Acid Armor, Agility, Growth, Amnesia, Double Team, Minimize (b) 50% to greatly encourage (-2) stat-down moves during the player's first turn. (NOTE - 'First turn' clause applies. This is why Red’s Pikachu continues to use Charm with equal probability while the player sets up.) > Growl, Charm, Tail Whip, Leer, Screech, String Shot, Cotton Spore, Scary Face, Sand-Attack, Smokescreen, Kinesis, Flash, Sweet Scent (c) Otherwise, 88% (226/256) to greatly discourage (+2) stat-modifying moves. (3) TYPES ; Use effective moves; don’t use ineffective moves > Boarder, Officer, Bird Keeper, Beauty, Fisher, Psychic, Kimono Girl, Swimmer (M/F), Guitarist, Schoolboy, Super Nerd, Juggler, Pokefan (M/F), Biker, Scientist, Skier, Sage, Medium, Grunt (M/F), Executive (M/F) (a) Dismiss (+10) any move that the player is immune to. (b) Encourage (-1) super-effective moves. (c) Discourage (+1) not very effective moves unless all damaging moves are of the same type. NOTE - The immune check appears to consider moves regardless of whether they do damage. The super/not very effective checks only considers moves with non-zero move power. It appears moves with a power of 1 are still considered (Horn Drill, Counter, Seismic Toss, Fissure, Night Shade, Psywave, Super Fang, Flail, Reversal, Return, Present, Frustration, Magnitude, Hidden Power, Mirror Coat), which includes many moves that don’t make too much sense to include (??). (4) OFFENSIVE ; Don’t use non-damaging moves > Hiker, Sailor, Burglar, Bird Keeper, Pokemaniac, Swimmer (M), Firebreather, Blackbelt (a) Greatly discourage (+2) non-damaging moves (i.e. moves with power = 0). > Non-damaging moves (power = 0) Guillotine (!?), Whirlwind, Sand-Attack, Tail Whip, Leer, Growl, Roar, Sing, Supersonic, Disable, Mist, Leech Seed, Growth, Poisonpowder, Stun Spore, Sleep Powder, String Shot, Thunder Wave, Toxic, Hypnosis, Meditate, Agility, Teleport, Mimic, Screech, Double Team, Recover, Harden, Minimize, Smokescreen, Confuse Ray, Withdraw, Defense Curl, Barrier, Light Screen, Haze, Reflect, Focus Energy, Bide, Metronome, Mirror Move, Amnesia, Kinesis, Softboiled, Glare, Poison Gas, Lovely Kiss, Transform, Spore, Flash, Splash, Acid Armor, Rest, Sharpen, Conversion, Substitute, Sketch, Spider Web, Mind Reader, Nightmare, Curse, Cotton Spore, Spite, Scary Face, Sweet Kiss, Belly Drum, Spikes, Foresight, Destiny Bond, Perish Song, Detect, Lock On, Sandstorm, Endure, Charm, Swagger, Milk Drink, Mean Look, Attract, Sleep Talk, Heal Bell, Safeguard, Pain Split, Baton Pass, Encore, Sweet Scent, Morning Sun, Synthesis, Moonlight, Rain Dance, Sunny Day, Psych Up (5) OPPORTUNIST ; Discourage stall moves when the enemy's HP is low. > Teacher, Sailor, Boarder, Officer, Bird Keeper, Beauty, Fisher, Psychic, Kimono Girl, Firebreather, Schoolboy, Grunt (F), Grunt (M), Executive (M/F) (a) Do nothing (+0) if enemy's HP is above 50%. (b) Discourage (+1) stall moves if enemy's HP is 25% or below. (c) 50% to discourage (+1) stall moves if 25% < enemy’s HP <= 50%. > Stall moves Swords Dance, Tail Whip, Leer, Growl, Disable, Mist, Counter, Leech Seed, Growth, String Shot, Meditate, Agility, Rage, Mimic, Screech, Harden, Withdraw, Defense Curl, Barrier, Light Screen, Haze, Reflect, Focus Energy, Bide, Amnesia, Transform, Splash, Acid Armor, Sharpen, Conversion, Substitute, Flame Wheel (6) AGGRESSIVE ; Discourage damaging moves besides the one that deals the most damage. > Gentleman, Teacher, Pokemaniac, "Boss" (a) Discourage moves (+1) that aren't the most damaging move with the following exceptions: - Do nothing (+0) if the move deals no damage or variable damage (power is 0 or 1). - Do nothing (+0) if the move is reckless. > Reckless Moves - EXPLOSION: Selfdestruct, Explosion - RAMPAGE: Thrash, Petal Dance, Outrage - MULTI-HIT: Doubleslap, Comet Punch, Fury Attack, Pin Missile, Spike Cannon, Barrage, Fury Swipes, Bone Rush - DOUBLE-HIT: Double Kick, Bonemerang > Variable damage moves (power = 1) Horn Drill, Counter, Seismic Toss, Fissure, Night Shade, Psywave, Super Fang, Flail, Reversal, Return, Present, Frustration, Magnitude, Hidden Power, Mirror Coat NOTE - Reckless moves and moves with variable damage are considered when determining the strongest move; however, they will not be discouraged if they are not the strongest move. The AI damage calcs are separate from the damage formula, so some moves with 1 power may not be sensibly calculated (??). NOTE - Some other exceptional cases: damage calcs for Fury Cutter, Rage, and Rollout appear to always be based off the first 'stage' of damage. (7) CAUTIOUS ; Discourage moves with residual effects after turn 1 > Lass, Picnicker, Camper, Burglar, Beauty, Fisher, Psychic, Kimono Girl, Swimmer (F), Guitarist, Schoolboy, Sage, Medium, Grunt (M/F), Executive (M/F), "Boss" (a) 90% (230/256) to discourage (+1) moves with residual effects after the enemy's first turn. (NOTE - 'First turn' clause applies.) > Residual moves Mist, Leech Seed, Poisonpowder, Stun Spore, Thunder Wave, Focus Energy, Bide, Poison Gas, Transform, Conversion, Substitute, Spikes (8) STATUS ; Dismiss status moves that don't affect the player. > Everyone (except Twins & Wild Pokemon) (a) Poisonpowder, Poison Gas, Toxic dismissed (+10) if the player is Poison-type (b) Status-only moves (Sing, Sleep Powder, Hypnosis, Lovely Kiss, Spore, Toxic, Poisonpowder, Poison Gas, Stun Spore, Thunder Wave, Glare) dismissed (+10) if the player has a type that is immune to the status move’s type NOTE - It appears the immunity is checked even if the move does work against the player (e.g. Sing against a Ghost type) (??) (9) RISKY ; Use moves that can KO the target, excepting some risky moves > Biker, Blackbelt, Scientist, Skier, Sage, Medium, Grunt (M/F), Executive (M/F), "Boss" (a) Extremely encourage (-5) any non-risky move that can KO the player. (b) Ignore (+0) risky moves if the enemy’s HP is full. (c) If the enemy’s HP is not full, consider risky moves that can KO the target - 78% (200/256) to do nothing (+0) - 22% (56/256) to extremely encourage them (-5). > Risky Moves - EXPLOSION: Selfdestruct, Explosion - OHKO: Guillotine, Horn Drill, Fissure NOTE - ‘Can KO’ effectively means ‘has a chance to KO, barring crits or max damage rolls’. NOTE - The AI damage calcs are separate from the damage formula, so some moves with 1 power may not be sensibly calculated (??). NOTE - Some other exceptional cases: damage calcs for Fury Cutter, Rage, and Rollout appear to always be based off the first 'stage' of damage. (10) SMART ; Context-specific scoring > Super Nerd, Juggler, Pokefan (M/F), Executive (M/F), "Boss" The following sublayers are only considered for relevant moves. With the exception of the Smart_LockOn sublayer, only the scores of the relevant moves will be adjusted. ; IMPORTANT NOTE - Steps are laid out in an if-then-else logic. If a conditional is met for a given step, it is implied that the scoring function completes and returns (unless it is specifically stated otherwise). This includes steps with chance elements; "x% to encourage/discourage" implies "(100-x)% to DO NOTHING". If the conditional is not met, then continue to the next step. In some complex cases, there are nested conditionals. ; For example, consider the Smart_Haze sublayer: ; (a) 84% (216/256) to encourage (-1) if any of enemy's stat levels is lower than -2 or if any of player's stat levels is higher than +2 ; (b) Otherwise, discourage (+1) ; In the 16% chance that the roll to encourage Haze fails, the scoring function DOES NOTHING (+0) and returns. Discouraging Haze in (b) only takes place if the conditional in (a) is not met (i.e. if all of the enemy’s stat levels are at least -2 and if all of the player’s stat levels are at most +2). [10.01] Smart_Sleep > Sing, Sleep Powder, Hypnosis, Lovely Kiss, Spore (a) 50% to greatly encourage (-2) if the enemy has either Dream Eater or Nightmare. NOTE - This takes place regardless of whether the player is statused. The BASIC layer will take care of dismissing sleep moves if they will have no effect. [10.02] Smart_LeechHit > Absorb, Mega Drain, Giga Drain, Leech Life (a) 60% (156/256) to discourage (+1) if the player resists the move. (b) Do nothing (+0) if the move deals neutral damage to the player. (c) Else, do nothing (+0) if enemy's HP is full. (d) Else, 80% (206/256) to encourage (-1) if it is super effective against the player and the enemy is not at max HP. [10.03] Smart_Explosion > Explosion, Selfdestruct (a) Greatly discourage (+3) if this is the foe's last Pokemon and the player character has multiple Pokemon left (b) Otherwise: - Greatly discourage (+3) if enemy’s HP is above 50% - 92% (236/256) to greatly discourage (+3) if 25% < enemy’s HP <= 50% [10.04] Smart_DreamEater > Dream Eater (a) 90% (231/256) to greatly encourage (-3) NOTE - This takes place regardless of whether the player is asleep. The BASIC layer will take care of dismissing Dream Eater if the player is awake. [10.05] Smart_MirrorMove > Mirror Move (a) If the player did not use any move last turn - Do nothing (+0) if enemy is not faster than player - Dismiss (+10) if enemy is faster than player (b) If player did use a move last turn - Do nothing (+0) if the move was not a useful move - If the move was useful, do BOTH of the following checks: : 50% to encourage (-1) : 90% (231/256) to encourage (-1) if enemy is faster than player > Useful moves Double Edge, Sing, Flamethrower, Hydro Pump, Surf, Ice Beam, Blizzard, Hyper Beam, Sleep Powder, Thunderbolt, Thunder, Earthquake, Toxic, Psychic, Hypnosis, Recover, Fire Blast, Softboiled, Super Fang [10.06] Smart_EvasionUp > Double Team, Minimize NOTE - ‘Continue’ means the function does not return, but instead jumps ahead to the next 'section', where further computations are performed. Computation will go from section i -> ii -> iii -> iv unless there is a note that says to return. [i.] (a) Dismiss (+10) if evasion level is +6 {RETURN} (b) Else, if enemy’s HP is full - Greatly encourage (-2) if player is badly poisoned {RETURN} - If player is not badly poisoned : 70% (178/256) to greatly encourage (-2) {RETURN} : 30% ( 78/256) to do nothing (+0) {CONTINUE} (c) Otherwise, {CONTINUE} [ii.] (d) Greatly discourage (+2) if enemy’s HP is 25% or below {CONTINUE} (e) If enemy’s HP is above 25% - 4% (10/256) to greatly encourage (-2) {RETURN} - 96% (246/256) to do nothing (+0) {CONTINUE} [iii.] (f) If 25% < enemy’s HP <= 50% - 50% to greatly discourage (+2) {CONTINUE} - 50% to do nothing (+0) {CONTINUE} (g) If enemy’s HP is above 50% - 78% (200/256) to do nothing (+0) {CONTINUE} - 22% (56/256) to greatly encourage (-2) {RETURN} (h) Otherwise, {CONTINUE} [iv.] (i) 69% (186/256) to greatly encourage (-2) if player is badly poisoned (j) Else, 50% to encourage (-1) if player is seeded (k) Else, discourage (+1) if enemy's evasion level is higher than player's accuracy level (l) Else, greatly encourage (-2) if player is in the middle of Fury Cutter or Rollout [10.07] Smart_AlwaysHit > Swift, Faint Attack, Vital Throw (a) 78% (200/256) to greatly encourage (-2) if either the enemy’s accuracy stage is -3 or worse or the player’s evasion stage is +3 or better [10.08] Smart_AccuracyDown > Sand-Attack, Smokescreen, Kinesis, Flash NOTE - ‘Continue’ means the function does not return, but instead jumps ahead to the next 'section', where further computations are performed. Computation will go from section i -> ii -> iii -> iv unless there is a note that says to return. [i.] (a) If player’s HP is full and enemy’s HP is above 50% - Greatly encourage (-2) if player is badly poisoned {RETURN} - If player is not badly poisoned : 70% (178/256) to greatly encourage (-2) {RETURN} : 30% ( 78/256) to do nothing (+0) {CONTINUE} (b) Otherwise, {CONTINUE} [ii.] (c) Greatly discourage (+2) if player’s HP is 25% or below {CONTINUE} (d) If player’s HP is above 25% - 4% (10/256) to greatly encourage (-2) {RETURN} - 96% (246/256) to do nothing (+0) {CONTINUE} [iii.] (e) If 25% < player’s HP <= 50% - 50% to greatly discourage (+2) {CONTINUE} - 50% to do nothing (+0) {CONTINUE} (f) If player’s HP is above 50% - 78% (200/256) to do nothing (+0) {CONTINUE} - 22% (56/256) to greatly encourage (-2) {RETURN} (g) Otherwise, {CONTINUE} [iv.] (h) 69% (186/256) to greatly encourage (-2) if player is badly poisoned (i) Else, 50% to encourage (-1) if player is seeded (j) Else, discourage (+1) if enemy's evasion level is higher than player's accuracy level (k) Else, greatly encourage (-2) if player is in the middle of Fury Cutter or Rollout [10.09] Smart_Haze > Haze (a) 84% (216/256) to encourage (-1) if any of enemy's stat levels is lower than -2 or if any of player's stat levels is higher than +2 (b) Otherwise, discourage (+1) [10.10] Smart_Bide > Bide (a) 90% (231/256) to discourage (+1) if enemy’s HP is not full [10.11] Smart_Whirlwind > Whirlwind, Roar Smart_BatonPass > Baton Pass (a) Discourage (+1) if the player has not shown any moves that are super effective against the enemy. Consider the player’s type(s) if its moves are unknown. [10.12] Smart_Heal > Recover, Softboiled, Milk Drink, Rest Smart_MorningSun > Morning Sun Smart_Synthesis > Synthesis Smart_Moonlight > Moonlight (a) 90% (231/256) to greatly encourage (-2) if enemy's HP is 25% or below. (b) Discourage (+1) if enemy's HP is above 50%. [10.13] Smart_Toxic > Toxic Smart_LeechSeed > Leech Seed (a) Discourage (+1) if player’s HP is 50% or below [10.14] Smart_LightScreen > Light Screen Smart_Reflect > Reflect (a) 92% (236/256) to discourage (+1) if the enemy’s HP is not full [10.15] Smart_Ohko > Guillotine, Horn Drill, Fissure (a) Dismiss (+10) if player's level is higher than enemy's level. (b) Else, discourage (+1) if player’s HP is 50% or below [10.16] Smart_RazorWind > Razor Wind (a) Discourage (+1) if enemy’s perish count is < 3 (b) Else, dismiss (+6) if player has used Protect (c) Else, 78% (200/256) to discourage (+1) if enemy is confused or the enemy’s HP is 50% or below [10.17] Smart_SuperFang > Super Fang (a) Discourage (+1) if player's HP is 25% or below. [10.18] Smart_Bind > Whirlpool, Bind, Clamp, Fire Spin, Wrap (a) 50% to discourage (+1) if the player is already trapped. (b) Else, 50% to greatly encourage (-2) if player is either badly poisoned, in love, identified, stuck in Rollout, or has a Nightmare. (c) Else, 50% to greatly encourage (-2) if it's the player's first turn. (NOTE - 'First turn' clause applies.) (d) Otherwise, 50% to discourage (+1) [10.19] Smart_Confuse > Supersonic, Confuse Ray, Sweet Kiss (a) Do BOTH of the following checks: - 90% (231/256) to discourage (+1) if player's HP is 50% or below - Discourage (+1) if player’s HP is 25% or below [10.20] Smart_SpDefenseUp2 > Amnesia (a) Discourage (+1) if enemy's HP is 50% or below (b) Else, discourage (+1) if enemy's special defense level is higher than +3 (c) Else, 78% (200/256) to greatly encourage (-2) if enemy's special defense level is lower than +2 and the player is of a special type. [10.21] Smart_Paralyze > Stun Spore, Thunder Wave, Glare (a) 50% to discourage (+1) if player's HP is 25% or below (b) Else, 78% (200/256) to greatly encourage (-2) if enemy is not faster than player and enemy’s HP is above 25%. [10.22] Smart_SpeedDownHit > Icy Wind (a) 88% (226/256) to greatly encourage (-2) if the following conditions are ALL met: - Enemy's HP is above 25%. - It's the player's first turn. (NOTE - 'First turn' clause applies.) - Enemy is not faster than player. [10.23] Smart_Substitute > Substitute (a) Dismiss (+10) if enemy's HP is 50% or below [10.24] Smart_HyperBeam > Hyper Beam (a) Do nothing (+0) if 25% < enemy’s HP <= 50% (b) 50% to encourage (-1) if enemy's HP is 25% or below. (c) If enemy’s HP is above 50% - 16% (40/256) to do nothing (+0) - 84% (216/256) to discourage (+1), followed by a 50/50 roll to discourage (+1) a second time [10.25] Smart_Rage > Rage (a) If enemy’s rage is building, do ALL of the following checks - 50% to encourage (-1) - Encourage (-1) if enemy’s rage counter > 1 - Encourage (-1) if enemy’s rage counter > 2 (b) If enemy’s rage is not building - Discourage (+1) if enemy’s HP is 50% or below - Otherwise, 50% to encourage (-1) [10.26] Smart_Mimic > Mimic (a) If the player did not use any move last turn - Discourage (+1) if enemy is not faster than player - Dismiss (+10) if enemy is faster than player (b) If player did use a move last turn - Discourage (+1) if enemy’s HP is 50% or below or if move is not very effective vs player - Otherwise, do BOTH of the following checks: : 50% to encourage (-1) if move is super effective vs player : 50% to encourage (-1) if the move was useful > Useful moves Double Edge, Sing, Flamethrower, Hydro Pump, Surf, Ice Beam, Blizzard, Hyper Beam, Sleep Powder, Thunderbolt, Thunder, Earthquake, Toxic, Psychic, Hypnosis, Recover, Fire Blast, Softboiled, Super Fang [10.27] Smart_Disable > Disable (a) 92% (236/256) to discourage (+1) if the enemy is not faster than the player (b) If the enemy is faster than the player: - 61% (156/256) to encourage (-1) if the player’s last move was useful - Else, 92% (236/256) to discourage (+1) if the player’s last move was non-damaging > Useful moves Double Edge, Sing, Flamethrower, Hydro Pump, Surf, Ice Beam, Blizzard, Hyper Beam, Sleep Powder, Thunderbolt, Thunder, Earthquake, Toxic, Psychic, Hypnosis, Recover, Fire Blast, Softboiled, Super Fang [10.28] Smart_Counter > Counter (a) 61% (156/256) to encourage (-1) if player has used 3 or more damaging physical moves (b) Discourage (+1) if player has not used any damaging physical moves (c) Else, 61% (156/256) to encourage (-1) if the last move the player used was a damaging, physical move [10.29] Smart_Encore > Encore (a) Greatly discourage if enemy is not faster than player (+3) (b) If enemy is faster: - Dismiss (+10) if player did not use a move last turn - 73% (186/256) to greatly encourage (-2) if player’s last move was damaging and enemy is immune to it - Do nothing (+0) if player’s last move was damaging and not very effective against enemy - Otherwise : 73% (186/256) to greatly encourage (-2) if move is an encore move : Greatly discourage (+3) if move is not an encore move > Encore moves DAMAGING - Dream Eater, Super Fang, Triple Kick, Flame Wheel, Aeroblast, Powder Snow NON-DAMAGING - Swords Dance, Whirlwind, Leer, Roar, Disable, Mist, Leech Seed, Growth, Poisonpowder, String Shot, Meditate, Agility, Teleport, Screech, Haze, Focus Energy, Poison Gas, Splash, Sharpen, Conversion, Substitute, Spider Web, Mind Reader, Cotton Spore [10.30] Smart_PainSplit > Pain Split (a) Discourage (+1) if [enemy's current HP * 2 > player's current HP]. [10.31] Smart_Snore > Snore Smart_SleepTalk > Sleep Talk (a) Greatly discourage (+3) if enemy is fast asleep and will wake up this turn (b) Otherwise, greatly encourage (-3) NOTE - This takes place regardless of whether the enemy is asleep. The basic layer will take care of dismissing Snore and Sleep Talk if the enemy is awake. [10.32] Smart_Conversion2 > Conversion2 (a) 90% (231/256) to discourage (+1) if player hasn’t used a move (b) 90% (231/256) to discourage (+1) if the enemy resists the player’s last move (c) Do nothing (+0) if the player’s last move is of neutral effectiveness against the enemy (d) 50% to encourage (-1) if the player’s last move is super effective against the enemy [10.33] Smart_LockOn > Lock On, Mind Reader (a) If not already locked on to player - Discourage (+1) if enemy's HP is 25% or below - Discourage (+1) if 25% < enemy’s HP <= 50% and enemy is not faster than player - Else, 50% to greatly encourage (-2) if enemy’s accuracy stage is -3 or worse OR player’s evasion stage is +3 or better - Else, do nothing (+0) if enemy’s accuracy stage is -1 or -2 OR player’s evasion stage is +1 or +2 - Else, discourage (+1) if every other enemy move is either >= 70% (180/256) accurate or not very effective vs player (b) If already locked on to player, do BOTH of the following: - Greatly encourage (-2) all enemy moves that are < 70% (180/256) accurate - Dismiss (+10) moves that lock on to the player [10.34] Smart_DestinyBond > Destiny Bond Smart_Reversal > Flail, Reversal Smart_SkullBash > Skull Bash (a) Discourage (+1) if enemy's HP is above 25% [10.35] Smart_Spite > Spite (a) If the player did not use any move last turn - 50% to discourage (+1) if enemy is not faster than player - Dismiss (+10) if enemy is faster than player (b) If the player did use a move last turn - 61% (156/256) to greatly encourage (-2) if last player move has <= 5 PP - Discourage (+1) if last player move has >= 15 PP - Otherwise, 39% (100/256) to discourage (+1) [10.36] Smart_HealBell > Heal Bell (a) Dismiss (+10) if none of the Pokemon in the foe’s party is statused (b) Do nothing (+0) if the enemy is the only statused Pokemon in the foe’s party (c) If at least one Pokemon in the foe’s party, excluding the currently active Pokemon, is statused: - Encourage (-1) if the enemy is not statused - Do nothing (+0) if the enemy is BRN/PRZ/PSN (??) - 50% to greatly encourage (-2) if the enemy is FRZ or SLP (??) [10.37] Smart_PriorityHit > Quick Attack, Mach Punch, Extremespeed (a) Do nothing (+0) if enemy is faster than player (b) If enemy is not faster than player: - Dismiss (+10) if player is flying or underground - Else, greatly encourage (-3) if it can KO the player NOTE - ‘Can KO’ effectively means ‘has a chance to KO, barring crits or max damage rolls’. [10.38] Smart_Thief > Thief (a) Dismiss entirely (+31) (NOTE - Won’t be chosen unless it is the only move available) [10.39] Smart_MeanLook > Mean Look, Spider Web (a) Discourage (+1) if enemy’s HP is 50% or below (b) Else, dismiss (+10) if this is the player character’s last Pokemon (c) Else, 78% (200/256) to greatly encourage (-3) if enemy is badly poisoned (weird), or the player is in love, is stuck in rollout, has been identified, or has a nightmare (d) Otherwise, discourage (+1) if the player has shown super effective moves against the enemy. Consider player's type(s) if its moves are unknown. [10.40] Smart_Nightmare > Nightmare (a) 50% to encourage (-1) NOTE - This takes place regardless of whether the player is asleep. The basic layer will take care of dismissing Nightmare if the player is awake or already has a nightmare. [10.41] Smart_FlameWheel > Flame Wheel (a) Extremely encourage (-5) if the enemy is frozen. [10.42] Smart_Curse > Curse (a) If enemy is not a ghost: - Discourage (+1) if enemy’s HP is 50% or below - Else, discourage (+1) if enemy’s attack level is +4 or higher - Else, do nothing (+0) if enemy’s attack level is +2 or +3 - Else, greatly discourage (+2) if the player is a ghost type - Else, do nothing (+0) if the player is a special type - Otherwise, 78% (200/256) to greatly encourage (-2) (b) If enemy is a ghost: - Dismiss (+10) if player is already cursed - Else, extremely discourage (+4) if this is the foe’s last Pokemon and the player character has multiple Pokemon left - Else, 50% to greatly encourage (-2) if this is the player character’s last Pokemon and the foe has multiple Pokemon left - Otherwise: : Extremely discourage (+4) if the enemy’s HP is 25% or below : Greatly discourage (+2) if 25% < enemy’s HP <= 50% : Else, do nothing (+0) if the enemy’s HP is not full or if this is not the player’s first turn. (NOTE - 'First turn' clause applies.) : Otherwise, 50% to greatly encourage (-2) [10.43] Smart_Protect > Protect, Detect (a) If enemy’s protect counter > 0, do BOTH of the following: - Discourage (+1) - 92% (236/256) to greatly discourage (+2) (b) Else, 92% (236/256) to greatly discourage (+2) if locked on to the player (c) Else, 78% (200/256) to encourage (-1) if player’s Fury Cutter count is >= 3, if player’s Rollout count >= 3, if player is using a charging move, or if player is badly poisoned/seeded/cursed (d) Otherwise, 92% (236/256) to greatly discourage (+2) (NOTE - including if player is stuck in Rollout and the current Rollout count < 3) [10.44] Smart_Foresight > Foresight (a) 61% (156/256) to greatly encourage (-2) if enemy’s accuracy level is -3 or worse, if player’s evasion level is +3 or better, or if the player is a ghost type (b) Otherwise, 92% (236/256) to discourage (+1) [10.45] Smart_PerishSong > Perish Song (a) Extremely discourage (+5) if foe has no other unfainted Pokemon (b) Else, 50% to encourage (-1) if the player cannot run (c) Else, 50% to discourage (+1) if the player has not shown a super effective against the enemy. Consider the player’s type(s) if its moves are unknown. [10.46] Smart_Sandstorm > Sandstorm (a) Greatly discourage (+2) if player is immune to sandstorm damage (i.e. Rock, Ground, Steel type Pokemon) (b) Else, discourage (+1) if player’s HP is 50% or below (c) Otherwise, 50% to encourage (-1) [10.47] Smart_Endure > Endure (a) Greatly discourage (+2) if enemy’s protect counter > 0 or if enemy is at max HP (b) Else, discourage (+1) if enemy’s HP is above 25% (c) Else, 78% (200/256) to greatly encourage (-3) if the enemy has Reversal or Flail (d) Else, 50% to greatly encourage (-2) if player is currently locked on to enemy [10.48] Smart_FuryCutter > Fury Cutter Smart_Rollout > Rollout NOTE - ‘Continue’ means the function does not return, but instead jumps ahead to the next 'section', where further computations are performed. [i.] Fury Cutter only (a) Do ALL of the following checks IF enemy’s fury cutter count > 0 - Encourage (-1) - Greatly encourage (-2) if Fury Cutter count is >= 2 - Greatly encourage (-3) if Fury Cutter count is >= 3 - {CONTINUE} [ii.] Fury Cutter/Rollout (b) 78% (200/256) to discourage (+1) if the enemy is in love, confused, or paralyzed, if the enemy’s HP is 25% or below, if the enemy’s accuracy level is -1 or worse, or if the player’s evasion level is +1 or better (c) Otherwise, 78% (200/256) to greatly encourage (-2) [10.49] Smart_Swagger > Swagger Smart_Attract > Attract (a) 78% (200/256) to encourage (-1) during the player's first turn. (NOTE - 'First turn' clause applies.) (b) Otherwise, 78% (200/256) to discourage (+1) [10.50] Smart_Safeguard > Safeguard (a) 78% (200/256) to discourage (+1) if player's HP is 50% or below [10.51] Smart_Magnitude > Magnitude Smart_Earthquake > Earthquake (a) Do nothing (+0) if the player’s last move was not Dig (b) If the player is currently underground, greatly encourage (-2) if the enemy is faster (c) Else, 50% to encourage (-1) if the enemy is not faster than the player [10.52] Smart_Pursuit > Pursuit (a) 50% to greatly encourage (-2) if player's HP is 25% or below (b) Otherwise, 78% (200/256) to discourage (+1) [10.53] Smart_RapidSpin > Rapid Spin (a) 78% (200/256) to greatly encourage (-2) if the enemy is trapped (Bind effect), seeded, or scattered with spikes [10.54] Smart_HiddenPower > Hidden Power (a) Discourage (+1) if Hidden Power type is not very effective or its power < 50 (b) Encourage (-1) if Hidden Power type is super effective or its power is exactly 70 [10.55] Smart_RainDance > Rain Dance (a) Greatly discourage (+3) if player is a water type (b) If player is a fire type: - Greatly encourage (-2) if the player’s HP is above 50% and it is either the player’s first turn or the enemy’s first turn. (NOTE - 'First turn' clause applies.) (c) Else, greatly discourage (+3) if the enemy doesn’t have a useful rain move or if the player’s HP is 50% or below (d) Otherwise, 50% to encourage (-1) > Useful Rain Moves Water Gun, Hydro Pump, Surf, Bubblebeam, Thunder, Waterfall, Clamp, Bubble, Crabhammer, Octazooka, Whirlpool [10.56] Smart_SunnyDay > Sunny Day (a) Greatly discourage (+3) if player is a fire type (b) If player is a water type: - Greatly encourage (-2) if the player’s HP is above 50% and it is either the player’s first turn or the enemy’s first turn. (NOTE - 'First turn' clause applies.) (c) Else, greatly discourage (+3) if the enemy doesn’t have a useful sun move or if the player’s HP is 50% or below (d) Otherwise, 50% to encourage (-1) > Useful Sun Moves Fire Punch, Ember, Flamethrower, Fire Spin, Fire Blast, Sacred Fire, Morning Sun, Synthesis (NOTE - Solarbeam not included for some reason) [10.57] Smart_BellyDrum > Belly Drum (a) Extremely discourage (+5) if enemy's attack is higher than +2 or if enemy's HP is 50% or below. (b) Else, discourage (+1) if enemy's HP is not full. [10.58] Smart_PsychUp > Psych Up (a) Greatly discourage (+2) if the sum of the player’s stat modifiers are no higher than those of the enemy (b) Else, do nothing (+0) if the player’s accuracy level is lower than -1 or the enemy’s evasion level is +1 or higher (c) Otherwise, 78% (200/256) to encourage (-1) [10.59] Smart_MirrorCoat > Mirror Coat (a) 61% (156/256) to encourage (-1) if player has used 3 or more damaging special moves (b) Discourage (+1) if player has not used any damaging special moves (c) Else, 61% (156/256) to encourage (-1) if the last move the player used was a damaging, special move [10.60] Smart_Twister > Twister Smart_Gust > Gust (a) Do nothing (+0) if the player’s last move was not Fly (b) If the player is currently flying, greatly encourage (-2) if the enemy is faster (c) Else, 50% to encourage (-1) if the enemy is not faster than the player [10.61] Smart_FutureSight > Future Sight (a) Greatly encourage (-2) if the player is flying or underground, and slower than the enemy. [10.62] Smart_Stomp > Stomp (a) 78% (200/256) to encourage (-1) if the player has used Minimize. [10.63] Smart_Solarbeam > Solarbeam (a) 78% (200/256) to greatly encourage (-2) if it's sunny. (b) 90% (231/256) to greatly discourage (+2) if it's raining. [10.64] Smart_Thunder > Thunder (a) 90% (231/256) to discourage (+1) if it's sunny. [10.65] Smart_Fly > Fly, Dig (a) Greatly encourage (-3) if the player is flying or underground, and slower than the enemy.