View difference between Paste ID: JWfLVGqb and EjAW76cx
SHOW: | | - or go back to the newest paste.
1
(Last edited: 10 Apr 2016)
2
3
4
*** CHANGES ***
5
6
- Apr16: Corrected boundary condition for AI_Smart_Meanlook
7
- Apr16: Corrected AI_Smart_Sleep (only encourages if enemy has Dream Eater or Nightmare and only 50/50 in that case)
8
- Nov15: Cleaned up some formatting and wording in the writeup
9
- Sep15: Corrected boundary conditions for HP comparisons (1/4, 1/2) and speed comparisons
10
- Sep15: Corrected heal items
11
    -> Whether enemy is confused is irrelevant for choosing to use item
12
    -> 20% (not 50%) to heal when 25% < enemy's HP <= 50%
13
- Sep15: Clarified that the 'first turn' check in the CAUTIOUS layer refers to the enemy's first turn
14
- Sep15: Corrected error in Rain Dance / Sunny Day section (previously mixed 'player' up with 'enemy' in useful move check)
15
16
17
*** TODO ***
18
19
- Apr16: CheckPlayerMoveTypeMatchups function is not completely accounted for: affects Smart layers (MeanLook, PerishSong, BatonPass, Whirlwind)
20
    —> Cutoffs for ‘Player has shown NVE / neutral / SE moves’
21
- Aug15: Differences between Gold & Crystal (esp. things that might have been added/modified for Battle Tower)?
22
- Aug15: Revisit various assumptions that I didn't check thoroughly
23
24
25
26
[[ Ed. Note ]] 
27
28
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.
29
30
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.
31
32
Any item denoted with question marks (??) indicates that I haven't confirmed it through in-game testing.
33
34
35
36
37
I. BASICS
38
 
39
40
All moves start with an equal score (20).
41
 
42
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.
43
 
44
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.)
45
 
46
Unlike in Gen 1, the trainers do not ‘cheat’. They make their decisions before the player character chooses what to do.
47
 
48
 
49
50
 
51
II. ITEMS/SWITCHING
52
 
53
54
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.
55
 
56
There is a lot of logic, but only a few items are actually used in practice:
57
 
58
(a) Dire Hit
59
        - 50/50 on enemy’s first turn.
60
 
61
(b) Full Heal
62
        - Always used if statused
63
 
64
(c) Hyper Potion/Max Potion
65
        - Always used if enemy's HP is 25% or below
66
        - 20% (50/256) if 25% < enemy’s HP <= 50%
67
 
68
(d) Full Restore
69
        - Always used if statused
70
        - Always used if enemy's HP is 25% or below
71
        - 20% (50/256) if 25% < enemy’s HP <= 50%
72
 
73
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). (??)
74
 
75
76
77
 
78
III. TRAINER CLASSES AND LAYERS
79
80
 
81
Everyone has the BASIC + STATUS layers except for wild Pokemon and Twins (who choose moves at random).
82
 
83
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’.
84
 
85
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).
86
 
87
Trainer classes approximately sorted by complexity/difficulty:
88
 
89
 
90
 
91
*****  NON-SMART, NON-RISKY AI  *****
92
 
93
Wild Pokemon/Twins
94
    : NO AI
95
 
96
Youngster
97
    : BASIC + STATUS
98
 
99
Lass/Picnicker/Camper
100
    : BASIC + CAUTIOUS + STATUS
101
 
102
Bug Catcher
103
    : BASIC + SETUP + STATUS
104
 
105
Hiker
106
    : BASIC + OFFENSIVE + STATUS
107
 
108
Gentleman
109
    : BASIC + SETUP + AGGRESSIVE + STATUS
110
 
111
Teacher
112
    : BASIC + OPPORTUNIST + AGGRESSIVE + STATUS
113
 
114
Sailor
115
    : BASIC + OFFENSIVE + OPPORTUNIST + STATUS
116
 
117
Burglar
118
    : BASIC + OFFENSIVE + CAUTIOUS + STATUS
119
 
120
Boarder/Officer
121
    : BASIC + TYPES + OPPORTUNIST + STATUS
122
 
123
Bird Keeper
124
    : BASIC + TYPES + OFFENSIVE + OPPORTUNIST + STATUS
125
 
126
Beauty/Fisher/Psychic/Kimono Girl
127
    : BASIC + TYPES + OPPORTUNIST + CAUTIOUS + STATUS
128
 
129
Pokemaniac
130
    : BASIC + SETUP + OFFENSIVE + AGGRESSIVE + STATUS
131
 
132
Swimmer (M)
133
    : BASIC + SETUP + TYPES + OFFENSIVE + STATUS
134
 
135
Swimmer (F)/Guitarist
136
    : BASIC + SETUP + TYPES + CAUTIOUS + STATUS
137
 
138
Firebreather
139
    : BASIC + SETUP + OFFENSIVE + OPPORTUNIST + STATUS
140
 
141
Schoolboy
142
    : BASIC + SETUP + TYPES + OPPORTUNIST + CAUTIOUS + STATUS
143
 
144
 
145
 
146
*****  SMART, NON-RISKY AI  *****
147
 
148
Super Nerd/Juggler/Pokefan (M/F)
149
    : BASIC + TYPES + SMART + STATUS
150
 
151
 
152
 
153
*****  RISKY, NON-SMART AI  *****
154
 
155
Biker
156
    : BASIC + TYPES + STATUS + RISKY
157
 
158
Blackbelt
159
    : BASIC + OFFENSIVE + STATUS + RISKY
160
 
161
Scientist/Skier
162
    : BASIC + SETUP + TYPES + STATUS + RISKY
163
 
164
Sage/Medium
165
    : BASIC + SETUP + TYPES + CAUTIOUS + STATUS + RISKY
166
 
167
Grunt (F)
168
    : BASIC + TYPES + OPPORTUNIST + CAUTIOUS + STATUS + RISKY
169
 
170
Grunt (M)
171
    : BASIC + SETUP + TYPES + OPPORTUNIST + CAUTIOUS + STATUS + RISKY
172
 
173
 
174
 
175
*****  SMART, RISKY AI  *****
176
 
177
Executive (M/F)
178
    : BASIC + SETUP + TYPES + SMART + OPPORTUNIST + CAUTIOUS + STATUS + RISKY
179
 
180
"Boss" (Gym Leader/Elite 4/Cooltrainer (F/M)/Rival/Eusine/Lance/Red)
181
    : BASIC + SETUP + SMART + AGGRESSIVE + CAUTIOUS + STATUS + RISKY
182
 
183
 
184
185
 
186
IV. SCORING LAYER MECHANICS
187
188
 
189
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.
190
 
191
‘Enemy’ always refers to the NPC AI's currently active Pokemon. ‘Player’ always refers to the player character's currently active Pokemon.
192
 
193
194
NOTE - 'First turn' clause: 
195
196
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. 
197
198
Can be seen in the following layers: 
199
    - (2) SETUP
200
    - (7) CAUTIOUS
201
    - [10.18] Smart_Bind
202
    - [10.22] Smart_SpeedDownHit
203
    - [10.42] Smart_Curse
204
    - [10.49] Smart_Swagger | Smart_Attract
205
    - [10.55] Smart_RainDance
206
    - [10.56] Smart_SunnyDay
207
208
209
 
210
 
211
(1) BASIC   ; Don’t do anything redundant.
212
            
213
> Everyone (except Twins & Wild Pokemon)
214
215
216
(a) Dismiss (+10) moves with special effects if they are useless or not a good choice right now.
217
 
218
 > 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
219
 
220
 
221
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.
222
 
223
 
224
(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.
225
 
226
> Sing, Sleep Powder, Hypnosis, Lovely Kiss, Spore, Toxic, Poisonpowder, Poison Gas, Stun Spore, Thunder Wave, Glare
227
 
228
 
229
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.)
230
 
231
 
232
 
233
234
(2) SETUP   ; Use stat-modifying moves on turn 1
235
            
236
> Bug Catcher, Gentleman, Pokemaniac, Swimmer (M/F), Guitarist, Firebreather, Schoolboy, Scientist, Skier, Sage, Medium, Grunt (M), Executive (M/F), "Boss"
237
238
239
(a) 50% to greatly encourage (-2) stat-up moves during the enemy's first turn.
240
 
241
> Meditate, Sharpen, Swords Dance, Harden, Withdraw, Barrier, Acid Armor, Agility, Growth, Amnesia, Double Team, Minimize
242
 
243
 
244
(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.)
245
 
246
> Growl, Charm, Tail Whip, Leer, Screech, String Shot, Cotton Spore, Scary Face, Sand-Attack, Smokescreen, Kinesis, Flash, Sweet Scent
247
248
249
(c) Otherwise, 88% (226/256) to greatly discourage (+2) stat-modifying moves.
250
  
251
252
 
253
 
254
(3) TYPES   ; Use effective moves; don’t use ineffective moves
255
256
> 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)
257
258
 
259
(a) Dismiss (+10) any move that the player is immune to.
260
(b) Encourage (-1) super-effective moves.
261
(c) Discourage (+1) not very effective moves unless all damaging moves are of the same type.
262
 
263
 
264
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 (??).
265
 
266
 
267
 
268
(4) OFFENSIVE   ; Don’t use non-damaging moves
269
270
> Hiker, Sailor, Burglar, Bird Keeper, Pokemaniac, Swimmer (M), Firebreather, Blackbelt
271
272
 
273
(a) Greatly discourage (+2) non-damaging moves (i.e. moves with power = 0).
274
 
275
276
> Non-damaging moves (power = 0)
277
278
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
279
 
280
 
281
 
282
(5) OPPORTUNIST   ; Discourage stall moves when the enemy's HP is low.
283
 
284
> Teacher, Sailor, Boarder, Officer, Bird Keeper, Beauty, Fisher, Psychic, Kimono Girl, Firebreather, Schoolboy, Grunt (F), Grunt (M), Executive (M/F)
285
286
287
(a) Do nothing (+0) if enemy's HP is above 50%.
288
(b) Discourage (+1) stall moves if enemy's HP is 25% or below.    
289
(c) 50% to discourage (+1) stall moves if 25% < enemy’s HP <= 50%.
290
 
291
 
292
> Stall moves
293
 
294
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
295
 
296
 
297
298
(6) AGGRESSIVE   ; Discourage damaging moves besides the one that deals the most damage. 
299
300
> Gentleman, Teacher, Pokemaniac, "Boss"
301
302
303
(a) Discourage moves (+1) that aren't the most damaging move with the following exceptions:
304
    - Do nothing (+0) if the move deals no damage or variable damage (power is 0 or 1).
305
    - Do nothing (+0) if the move is reckless.     
306
 
307
 
308
> Reckless Moves
309
 
310
- EXPLOSION:   Selfdestruct, Explosion
311
- RAMPAGE:     Thrash, Petal Dance, Outrage
312
- MULTI-HIT:   Doubleslap, Comet Punch, Fury Attack, Pin Missile, Spike Cannon, Barrage, Fury Swipes, Bone Rush
313
- DOUBLE-HIT:  Double Kick, Bonemerang
314
 
315
316
> Variable damage moves (power = 1)
317
318
Horn Drill, Counter, Seismic Toss, Fissure, Night Shade, Psywave, Super Fang, Flail, Reversal, Return, Present, Frustration, Magnitude, Hidden Power, Mirror Coat
319
320
 
321
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 (??).
322
323
NOTE - Some other exceptional cases: damage calcs for Fury Cutter, Rage, and Rollout appear to always be based off the first 'stage' of damage.
324
325
326
   
327
(7) CAUTIOUS   ; Discourage moves with residual effects after turn 1
328
 
329
> Lass, Picnicker, Camper, Burglar, Beauty, Fisher, Psychic, Kimono Girl, Swimmer (F), Guitarist, Schoolboy, Sage, Medium, Grunt (M/F), Executive (M/F), "Boss"
330
331
332
(a) 90% (230/256) to discourage (+1) moves with residual effects after the enemy's first turn. (NOTE - 'First turn' clause applies.)
333
 
334
335
> Residual moves
336
 
337
Mist, Leech Seed, Poisonpowder, Stun Spore, Thunder Wave, Focus Energy, Bide, Poison Gas, Transform, Conversion, Substitute, Spikes
338
 
339
 
340
 
341
(8) STATUS   ; Dismiss status moves that don't affect the player.
342
 
343
> Everyone (except Twins & Wild Pokemon)
344
345
346
(a) Poisonpowder, Poison Gas, Toxic dismissed (+10) if the player is Poison-type
347
(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
348
 
349
 
350
NOTE - It appears the immunity is checked even if the move does work against the player (e.g. Sing against a Ghost type) (??)
351
 
352
353
 
354
(9) RISKY   ; Use moves that can KO the target, excepting some risky moves
355
 
356
> Biker, Blackbelt, Scientist, Skier, Sage, Medium, Grunt (M/F), Executive (M/F), "Boss"
357
358
359
(a) Extremely encourage (-5) any non-risky move that can KO the player.
360
(b) Ignore (+0) risky moves if the enemy’s HP is full.
361
(c) If the enemy’s HP is not full, consider risky moves that can KO the target
362
    - 78% (200/256) to do nothing (+0)
363
    - 22%  (56/256) to extremely encourage them (-5).       
364
 
365
366
> Risky Moves
367
 
368
- EXPLOSION:  Selfdestruct, Explosion
369
- OHKO:       Guillotine, Horn Drill, Fissure
370
 
371
 
372
NOTE - ‘Can KO’ effectively means ‘has a chance to KO, barring crits or max damage rolls’.
373
374
NOTE - The AI damage calcs are separate from the damage formula, so some moves with 1 power may not be sensibly calculated (??). 
375
376
NOTE - Some other exceptional cases: damage calcs for Fury Cutter, Rage, and Rollout appear to always be based off the first 'stage' of damage.
377
378
379
380
(10) SMART   ; Context-specific scoring
381
382
> Super Nerd, Juggler, Pokefan (M/F), Executive (M/F), "Boss"
383
384
385
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.
386
387
388
; 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.
389
390
; For example, consider the Smart_Haze sublayer:
391
392
; (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
393
; (b) Otherwise, discourage (+1)
394
395
; 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).
396
397
398
399
[10.01] Smart_Sleep   > Sing, Sleep Powder, Hypnosis, Lovely Kiss, Spore
400
401
(a) 50% to greatly encourage (-2) if the enemy has either Dream Eater or Nightmare.
402
403
404
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.
405
406
407
408
[10.02] Smart_LeechHit   > Absorb, Mega Drain, Giga Drain, Leech Life
409
410
(a) 60% (156/256) to discourage (+1) if the player resists the move.
411
(b) Do nothing (+0) if the move deals neutral damage to the player.
412
(c) Else, do nothing (+0) if enemy's HP is full.
413
(d) Else, 80% (206/256) to encourage (-1) if it is super effective against the player and the enemy is not at max HP.
414
415
416
417
[10.03] Smart_Explosion   > Explosion, Selfdestruct
418
419
(a) Greatly discourage (+3) if this is the foe's last Pokemon and the player character has multiple Pokemon left
420
(b) Otherwise:
421
    - Greatly discourage (+3) if enemy’s HP is above 50%
422
    - 92% (236/256) to greatly discourage (+3) if 25% < enemy’s HP <= 50%
423
424
425
426
[10.04] Smart_DreamEater   > Dream Eater
427
428
(a) 90% (231/256) to greatly encourage (-3)
429
430
431
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.
432
433
434
435
[10.05] Smart_MirrorMove   > Mirror Move
436
437
(a) If the player did not use any move last turn
438
    - Do nothing (+0) if enemy is not faster than player
439
    - Dismiss (+10) if enemy is faster than player
440
441
(b) If player did use a move last turn
442
    - Do nothing (+0) if the move was not a useful move
443
    - If the move was useful, do BOTH of the following checks:
444
        : 50% to encourage (-1)
445
        : 90% (231/256) to encourage (-1) if enemy is faster than player
446
447
448
> Useful moves 
449
450
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
451
452
453
454
[10.06] Smart_EvasionUp   > Double Team, Minimize
455
456
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.
457
458
459
[i.]
460
461
(a) Dismiss (+10) if evasion level is +6 {RETURN}
462
(b) Else, if enemy’s HP is full
463
    - Greatly encourage (-2) if player is badly poisoned {RETURN}
464
    - If player is not badly poisoned
465
        : 70% (178/256) to greatly encourage (-2) {RETURN}
466
        : 30% ( 78/256) to do nothing (+0) {CONTINUE}
467
(c) Otherwise, {CONTINUE}
468
469
470
[ii.]
471
472
(d) Greatly discourage (+2) if enemy’s HP is 25% or below {CONTINUE}
473
(e) If enemy’s HP is above 25%
474
    -  4%  (10/256) to greatly encourage (-2) {RETURN}
475
    - 96% (246/256) to do nothing (+0) {CONTINUE}
476
477
478
[iii.]
479
480
(f) If 25% < enemy’s HP <= 50%
481
    - 50% to greatly discourage (+2) {CONTINUE}
482
    - 50% to do nothing (+0) {CONTINUE}
483
(g) If enemy’s HP is above 50%
484
    - 78% (200/256) to do nothing (+0) {CONTINUE}
485
    - 22%  (56/256) to greatly encourage (-2) {RETURN}
486
(h) Otherwise, {CONTINUE}
487
488
489
[iv.]
490
491
(i) 69% (186/256) to greatly encourage (-2) if player is badly poisoned
492
(j) Else, 50% to encourage (-1) if player is seeded
493
(k) Else, discourage (+1) if enemy's evasion level is higher than player's accuracy level
494
(l) Else, greatly encourage (-2) if player is in the middle of Fury Cutter or Rollout
495
496
497
498
[10.07] Smart_AlwaysHit   > Swift, Faint Attack, Vital Throw
499
500
(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
501
502
503
504
[10.08] Smart_AccuracyDown   > Sand-Attack, Smokescreen, Kinesis, Flash
505
506
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.
507
508
509
[i.]
510
511
(a) If player’s HP is full and enemy’s HP is above 50%
512
    - Greatly encourage (-2) if player is badly poisoned {RETURN}
513
    - If player is not badly poisoned
514
        : 70% (178/256) to greatly encourage (-2) {RETURN}
515
        : 30% ( 78/256) to do nothing (+0) {CONTINUE}
516
(b) Otherwise, {CONTINUE}
517
518
519
[ii.]
520
521
(c) Greatly discourage (+2) if player’s HP is 25% or below {CONTINUE}
522
(d) If player’s HP is above 25%
523
    -  4%  (10/256) to greatly encourage (-2) {RETURN}
524
    - 96% (246/256) to do nothing (+0) {CONTINUE}
525
526
527
[iii.]
528
529
(e) If 25% < player’s HP <= 50%
530
    - 50% to greatly discourage (+2) {CONTINUE}
531
    - 50% to do nothing (+0) {CONTINUE}
532
(f) If player’s HP is above 50%
533
    - 78% (200/256) to do nothing (+0) {CONTINUE}
534
    - 22%  (56/256) to greatly encourage (-2) {RETURN}
535
(g) Otherwise, {CONTINUE}
536
537
538
[iv.]
539
540
(h) 69% (186/256) to greatly encourage (-2) if player is badly poisoned
541
(i) Else, 50% to encourage (-1) if player is seeded
542
(j) Else, discourage (+1) if enemy's evasion level is higher than player's accuracy level
543
(k) Else, greatly encourage (-2) if player is in the middle of Fury Cutter or Rollout
544
545
546
547
[10.09] Smart_Haze   > Haze
548
549
(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
550
(b) Otherwise, discourage (+1)
551
552
553
554
[10.10] Smart_Bide   > Bide
555
556
(a) 90% (231/256) to discourage (+1) if enemy’s HP is not full
557
558
559
560
[10.11] Smart_Whirlwind   > Whirlwind, Roar
561
        Smart_BatonPass   > Baton Pass
562
563
(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.
564
565
566
567
[10.12] Smart_Heal         > Recover, Softboiled, Milk Drink, Rest  
568
        Smart_MorningSun   > Morning Sun
569
        Smart_Synthesis    > Synthesis
570
        Smart_Moonlight    > Moonlight
571
572
(a) 90% (231/256) to greatly encourage (-2) if enemy's HP is 25% or below.
573
(b) Discourage (+1) if enemy's HP is above 50%.
574
575
576
577
[10.13] Smart_Toxic       > Toxic
578
        Smart_LeechSeed   > Leech Seed
579
580
(a) Discourage (+1) if player’s HP is 50% or below
581
582
583
584
[10.14] Smart_LightScreen   > Light Screen
585
        Smart_Reflect       > Reflect
586
587
(a) 92% (236/256) to discourage (+1) if the enemy’s HP is not full
588
589
590
591
[10.15] Smart_Ohko   > Guillotine, Horn Drill, Fissure
592
593
(a) Dismiss (+10) if player's level is higher than enemy's level.
594
(b) Else, discourage (+1) if player’s HP is 50% or below
595
596
597
598
[10.16] Smart_RazorWind   > Razor Wind
599
600
(a) Discourage (+1) if enemy’s perish count is < 3
601
(b) Else, dismiss (+6) if player has used Protect
602
(c) Else, 78% (200/256) to discourage (+1) if enemy is confused or the enemy’s HP is 50% or below
603
604
605
606
[10.17] Smart_SuperFang   > Super Fang
607
608
(a) Discourage (+1) if player's HP is 25% or below.
609
610
611
612
[10.18] Smart_Bind   > Whirlpool, Bind, Clamp, Fire Spin, Wrap
613
614
(a) 50% to discourage (+1) if the player is already trapped.
615
(b) Else, 50% to greatly encourage (-2) if player is either badly poisoned, in love, identified, stuck in Rollout, or has a Nightmare.
616
(c) Else, 50% to greatly encourage (-2) if it's the player's first turn. (NOTE - 'First turn' clause applies.)
617
(d) Otherwise, 50% to discourage (+1)
618
619
620
621
[10.19] Smart_Confuse   > Supersonic, Confuse Ray, Sweet Kiss
622
623
(a) Do BOTH of the following checks:
624
    - 90% (231/256) to discourage (+1) if player's HP is 50% or below
625
    - Discourage (+1) if player’s HP is 25% or below
626
627
628
629
[10.20] Smart_SpDefenseUp2   > Amnesia
630
631
(a) Discourage (+1) if enemy's HP is 50% or below
632
(b) Else, discourage (+1) if enemy's special defense level is higher than +3
633
(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.
634
635
636
637
[10.21] Smart_Paralyze   > Stun Spore, Thunder Wave, Glare
638
639
(a) 50% to discourage (+1) if player's HP is 25% or below
640
(b) Else, 78% (200/256) to greatly encourage (-2) if enemy is not faster than player and enemy’s HP is above 25%.
641
642
643
644
[10.22] Smart_SpeedDownHit   > Icy Wind
645
646
(a) 88% (226/256) to greatly encourage (-2) if the following conditions are ALL met:
647
    - Enemy's HP is above 25%.
648
    - It's the player's first turn. (NOTE - 'First turn' clause applies.)
649
    - Enemy is not faster than player.
650
651
652
653
[10.23] Smart_Substitute   > Substitute
654
655
(a) Dismiss (+10) if enemy's HP is 50% or below
656
657
658
659
[10.24] Smart_HyperBeam   > Hyper Beam
660
661
(a) Do nothing (+0) if 25% < enemy’s HP <= 50%
662
(b) 50% to encourage (-1) if enemy's HP is 25% or below.
663
(c) If enemy’s HP is above 50%
664
    - 16%  (40/256) to do nothing (+0)
665
    - 84% (216/256) to discourage (+1), followed by a 50/50 roll to discourage (+1) a second time
666
667
668
669
[10.25] Smart_Rage   > Rage
670
671
(a) If enemy’s rage is building, do ALL of the following checks
672
    - 50% to encourage (-1) 
673
    - Encourage (-1) if enemy’s rage counter > 1
674
    - Encourage (-1) if enemy’s rage counter > 2
675
676
(b) If enemy’s rage is not building
677
    - Discourage (+1) if enemy’s HP is 50% or below
678
    - Otherwise, 50% to encourage (-1)
679
680
681
682
[10.26] Smart_Mimic   > Mimic
683
684
(a) If the player did not use any move last turn
685
    - Discourage (+1) if enemy is not faster than player
686
    - Dismiss (+10) if enemy is faster than player
687
688
(b) If player did use a move last turn
689
    - Discourage (+1) if enemy’s HP is 50% or below or if move is not very effective vs player
690
    - Otherwise, do BOTH of the following checks:
691
        : 50% to encourage (-1) if move is super effective vs player
692
        : 50% to encourage (-1) if the move was useful
693
694
695
> Useful moves 
696
697
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
698
699
700
701
[10.27] Smart_Disable   > Disable
702
703
(a) 92% (236/256) to discourage (+1) if the enemy is not faster than the player
704
(b) If the enemy is faster than the player:
705
    - 61% (156/256) to encourage (-1) if the player’s last move was useful
706
    - Else, 92% (236/256) to discourage (+1) if the player’s last move was non-damaging
707
708
709
> Useful moves 
710
711
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
712
713
714
715
[10.28] Smart_Counter   > Counter
716
717
(a) 61% (156/256) to encourage (-1) if player has used 3 or more damaging physical moves
718
(b) Discourage (+1) if player has not used any damaging physical moves
719
(c) Else, 61% (156/256) to encourage (-1) if the last move the player used was a damaging, physical move
720
721
722
723
[10.29] Smart_Encore   > Encore
724
725
(a) Greatly discourage if enemy is not faster than player (+3)
726
(b) If enemy is faster:
727
    - Dismiss (+10) if player did not use a move last turn
728
    - 73% (186/256) to greatly encourage (-2) if player’s last move was damaging and enemy is immune to it
729
    - Do nothing (+0) if player’s last move was damaging and not very effective against enemy
730
    - Otherwise
731
        : 73% (186/256) to greatly encourage (-2) if move is an encore move
732
        : Greatly discourage (+3) if move is not an encore move
733
734
735
> Encore moves
736
737
DAMAGING - Dream Eater, Super Fang, Triple Kick, Flame Wheel, Aeroblast, Powder Snow
738
739
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
740
741
742
743
[10.30] Smart_PainSplit   > Pain Split
744
745
(a) Discourage (+1) if [enemy's current HP * 2 > player's current HP].
746
747
748
749
[10.31] Smart_Snore       > Snore
750
        Smart_SleepTalk   > Sleep Talk
751
752
(a) Greatly discourage (+3) if enemy is fast asleep and will wake up this turn
753
(b) Otherwise, greatly encourage (-3)
754
755
756
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.
757
758
759
760
[10.32] Smart_Conversion2   > Conversion2
761
762
(a) 90% (231/256) to discourage (+1) if player hasn’t used a move
763
(b) 90% (231/256) to discourage (+1) if the enemy resists the player’s last move
764
(c) Do nothing (+0) if the player’s last move is of neutral effectiveness against the enemy
765
(d) 50% to encourage (-1) if the player’s last move is super effective against the enemy
766
767
768
769
[10.33] Smart_LockOn   > Lock On, Mind Reader
770
771
(a) If not already locked on to player
772
    - Discourage (+1) if enemy's HP is 25% or below
773
    - Discourage (+1) if 25% < enemy’s HP <= 50% and enemy is not faster than player
774
    - Else, 50% to greatly encourage (-2) if enemy’s accuracy stage is -3 or worse OR player’s evasion stage is +3 or better
775
    - Else, do nothing (+0) if enemy’s accuracy stage is -1 or -2 OR player’s evasion stage is +1 or +2
776
    - Else, discourage (+1) if every other enemy move is either >= 70% (180/256) accurate or not very effective vs player
777
    
778
(b) If already locked on to player, do BOTH of the following:
779
    - Greatly encourage (-2) all enemy moves that are < 70% (180/256) accurate
780
    - Dismiss (+10) moves that lock on to the player
781
782
783
784
[10.34] Smart_DestinyBond   > Destiny Bond
785
        Smart_Reversal      > Flail, Reversal
786
        Smart_SkullBash     > Skull Bash
787
788
(a) Discourage (+1) if enemy's HP is above 25%
789
790
791
792
[10.35] Smart_Spite   > Spite
793
794
(a) If the player did not use any move last turn
795
    - 50% to discourage (+1) if enemy is not faster than player
796
    - Dismiss (+10) if enemy is faster than player
797
798
(b) If the player did use a move last turn
799
    - 61% (156/256) to greatly encourage (-2) if last player move has <= 5 PP
800
    - Discourage (+1) if last player move has >= 15 PP
801
    - Otherwise, 39% (100/256) to discourage (+1)
802
803
804
805
[10.36] Smart_HealBell   > Heal Bell
806
807
(a) Dismiss (+10) if none of the Pokemon in the foe’s party is statused
808
(b) Do nothing (+0) if the enemy is the only statused Pokemon in the foe’s party
809
(c) If at least one Pokemon in the foe’s party, excluding the currently active Pokemon, is statused:
810
    - Encourage (-1) if the enemy is not statused
811
    - Do nothing (+0) if the enemy is BRN/PRZ/PSN (??)
812
    - 50% to greatly encourage (-2) if the enemy is FRZ or SLP (??)
813
814
815
816
[10.37] Smart_PriorityHit   > Quick Attack, Mach Punch, Extremespeed
817
818
(a) Do nothing (+0) if enemy is faster than player
819
(b) If enemy is not faster than player:
820
    - Dismiss (+10) if player is flying or underground
821
    - Else, greatly encourage (-3) if it can KO the player
822
823
824
NOTE - ‘Can KO’ effectively means ‘has a chance to KO, barring crits or max damage rolls’.
825
826
827
828
[10.38] Smart_Thief   > Thief
829
830
(a) Dismiss entirely (+31) (NOTE - Won’t be chosen unless it is the only move available)
831
832
833
834
[10.39] Smart_MeanLook   > Mean Look, Spider Web
835
836
(a) Discourage (+1) if enemy’s HP is 50% or below
837
(b) Else, dismiss (+10) if this is the player character’s last Pokemon
838
(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
839
(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.
840
841
842
843
[10.40] Smart_Nightmare   > Nightmare
844
845
(a) 50% to encourage (-1)
846
847
848
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.
849
850
851
852
[10.41] Smart_FlameWheel   > Flame Wheel
853
854
(a) Extremely encourage (-5) if the enemy is frozen.
855
856
857
858
[10.42] Smart_Curse   > Curse
859
860
(a) If enemy is not a ghost:
861
    - Discourage (+1) if enemy’s HP is 50% or below
862
    - Else, discourage (+1) if enemy’s attack level is +4 or higher
863
    - Else, do nothing (+0) if enemy’s attack level is +2 or +3
864
    - Else, greatly discourage (+2) if the player is a ghost type
865
    - Else, do nothing (+0) if the player is a special type
866
    - Otherwise, 78% (200/256) to greatly encourage (-2)
867
868
(b) If enemy is a ghost:
869
    - Dismiss (+10) if player is already cursed
870
    - Else, extremely discourage (+4) if this is the foe’s last Pokemon and the player character has multiple Pokemon left
871
    - Else, 50% to greatly encourage (-2) if this is the player character’s last Pokemon and the foe has multiple Pokemon left
872
    - Otherwise:
873
        : Extremely discourage (+4) if the enemy’s HP is 25% or below
874
        : Greatly discourage (+2) if 25% < enemy’s HP <= 50%
875
        : 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.)
876
        : Otherwise, 50% to greatly encourage (-2)
877
878
879
880
[10.43] Smart_Protect   > Protect, Detect
881
882
(a) If enemy’s protect counter > 0, do BOTH of the following:
883
    - Discourage (+1)
884
    - 92% (236/256) to greatly discourage (+2)
885
(b) Else, 92% (236/256) to greatly discourage (+2) if locked on to the player
886
(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
887
(d) Otherwise, 92% (236/256) to greatly discourage (+2) (NOTE - including if player is stuck in Rollout and the current Rollout count < 3)
888
889
890
891
[10.44] Smart_Foresight   > Foresight
892
893
(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
894
(b) Otherwise, 92% (236/256) to discourage (+1)
895
896
897
898
[10.45] Smart_PerishSong   > Perish Song
899
900
(a) Extremely discourage (+5) if foe has no other unfainted Pokemon
901
(b) Else, 50% to encourage (-1) if the player cannot run
902
(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.
903
904
905
906
[10.46] Smart_Sandstorm   > Sandstorm
907
908
(a) Greatly discourage (+2) if player is immune to sandstorm damage (i.e. Rock, Ground, Steel type Pokemon)
909
(b) Else, discourage (+1) if player’s HP is 50% or below
910
(c) Otherwise, 50% to encourage (-1) 
911
912
913
914
[10.47] Smart_Endure   > Endure
915
916
(a) Greatly discourage (+2) if enemy’s protect counter > 0 or if enemy is at max HP
917
(b) Else, discourage (+1) if enemy’s HP is above 25%
918
(c) Else, 78% (200/256) to greatly encourage (-3) if the enemy has Reversal or Flail
919
(d) Else, 50% to greatly encourage (-2) if player is currently locked on to enemy
920
921
922
923
[10.48] Smart_FuryCutter   > Fury Cutter
924
        Smart_Rollout      > Rollout
925
926
NOTE - ‘Continue’ means the function does not return, but instead jumps ahead to the next 'section', where further computations are performed.
927
928
929
[i.] Fury Cutter only
930
931
(a) Do ALL of the following checks IF enemy’s fury cutter count > 0
932
    - Encourage (-1)
933
    - Greatly encourage (-2) if Fury Cutter count is >= 2
934
    - Greatly encourage (-3) if Fury Cutter count is >= 3
935
    - {CONTINUE}
936
937
938
[ii.] Fury Cutter/Rollout
939
940
(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
941
(c) Otherwise, 78% (200/256) to greatly encourage (-2)
942
943
944
945
[10.49] Smart_Swagger   > Swagger
946
        Smart_Attract   > Attract
947
948
(a) 78% (200/256) to encourage (-1) during the player's first turn. (NOTE - 'First turn' clause applies.)
949
(b) Otherwise, 78% (200/256) to discourage (+1)
950
951
952
953
[10.50] Smart_Safeguard   > Safeguard
954
955
(a) 78% (200/256) to discourage (+1) if player's HP is 50% or below
956
957
958
959
[10.51] Smart_Magnitude    > Magnitude
960
        Smart_Earthquake   > Earthquake
961
962
(a) Do nothing (+0) if the player’s last move was not Dig
963
(b) If the player is currently underground, greatly encourage (-2) if the enemy is faster
964
(c) Else, 50% to encourage (-1) if the enemy is not faster than the player
965
966
967
968
[10.52] Smart_Pursuit   > Pursuit
969
970
(a) 50% to greatly encourage (-2) if player's HP is 25% or below
971
(b) Otherwise, 78% (200/256) to discourage (+1)
972
973
974
975
[10.53] Smart_RapidSpin   > Rapid Spin
976
977
(a) 78% (200/256) to greatly encourage (-2) if the enemy is trapped (Bind effect), seeded, or scattered with spikes
978
979
980
981
[10.54] Smart_HiddenPower   > Hidden Power
982
983
(a) Discourage (+1) if Hidden Power type is not very effective or its power < 50
984
(b) Encourage (-1) if Hidden Power type is super effective or its power is exactly 70
985
986
987
988
[10.55] Smart_RainDance   > Rain Dance
989
990
(a) Greatly discourage (+3) if player is a water type
991
(b) If player is a fire type:
992
    - 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.)
993
(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 
994
(d) Otherwise, 50% to encourage (-1)
995
996
997
> Useful Rain Moves
998
999
Water Gun, Hydro Pump, Surf, Bubblebeam, Thunder, Waterfall, Clamp, Bubble, Crabhammer, Octazooka, Whirlpool
1000
1001
1002
1003
[10.56] Smart_SunnyDay   > Sunny Day
1004
1005
(a) Greatly discourage (+3) if player is a fire type
1006
(b) If player is a water type:
1007
    - 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.)
1008
(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 
1009
(d) Otherwise, 50% to encourage (-1)
1010
1011
1012
> Useful Sun Moves 
1013
1014
Fire Punch, Ember, Flamethrower, Fire Spin, Fire Blast, Sacred Fire, Morning Sun, Synthesis (NOTE - Solarbeam not included for some reason)
1015
1016
1017
1018
[10.57] Smart_BellyDrum   > Belly Drum
1019
1020
(a) Extremely discourage (+5) if enemy's attack is higher than +2 or if enemy's HP is 50% or below.
1021
(b) Else, discourage (+1) if enemy's HP is not full.
1022
1023
1024
1025
[10.58] Smart_PsychUp   > Psych Up
1026
1027
(a) Greatly discourage (+2) if the sum of the player’s stat modifiers are no higher than those of the enemy
1028
(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
1029
(c) Otherwise, 78% (200/256) to encourage (-1)
1030
1031
1032
1033
[10.59] Smart_MirrorCoat   > Mirror Coat
1034
1035
(a) 61% (156/256) to encourage (-1) if player has used 3 or more damaging special moves
1036
(b) Discourage (+1) if player has not used any damaging special moves
1037
(c) Else, 61% (156/256) to encourage (-1) if the last move the player used was a damaging, special move
1038
1039
1040
1041
[10.60] Smart_Twister   > Twister
1042
        Smart_Gust      > Gust
1043
1044
(a) Do nothing (+0) if the player’s last move was not Fly
1045
(b) If the player is currently flying, greatly encourage (-2) if the enemy is faster
1046
(c) Else, 50% to encourage (-1) if the enemy is not faster than the player
1047
1048
1049
1050
[10.61] Smart_FutureSight   > Future Sight
1051
1052
(a) Greatly encourage (-2) if the player is flying or underground, and slower than the enemy.
1053
1054
1055
1056
[10.62] Smart_Stomp   > Stomp
1057
1058
(a) 78% (200/256) to encourage (-1) if the player has used Minimize.
1059
1060
1061
1062
[10.63] Smart_Solarbeam   > Solarbeam
1063
1064
(a) 78% (200/256) to greatly encourage (-2) if it's sunny.
1065
(b) 90% (231/256) to greatly discourage (+2) if it's raining.
1066
1067
1068
1069
[10.64] Smart_Thunder   > Thunder
1070
1071
(a) 90% (231/256) to discourage (+1) if it's sunny.
1072
1073
1074
1075
[10.65] Smart_Fly   > Fly, Dig
1076
1077
(a) Greatly encourage (-3) if the player is flying or underground, and slower than the enemy.