Example: Roxanne's Nosepass on its first turn, with 39/39 HP Mudkip Code checks in order: 1. Kill range 2. Rock Tomb speed drop effect 3. Harden (setup move) 4. Damaging moves 1. Kill range - Is Mudkip in kill range? Since no, skip this step 2. Rock Tomb speed drop effect - Is Mudkip faster than Nosepass? Since yes, roll a number between 1 and 100 > If number is 1-70, +2 to Rock Tomb > If number is 71-100, +0 to Rock Tomb 3. Harden (setup move) - Is this Nosepass' first turn? Since yes, roll a number between 1 and 100 > If number is 1-80, +2 to Harden > If number is 81-100, +0 to Harden 4. Most damaging move - Use the damage formula to calculate rolls for each move (example: Rock Tomb 13, Rock Throw 14, Tackle 6) > Give +2 to the move(s) that do the most damage Use the move with the highest priority (for example, if check #2 rolls 50, check #3 rolls 50, and check #4 rolls 14/14/6 dmg, Rock Tomb would always be used because it has +4, Harden has +2, Rock Throw has +2 and Tackle has 0) MANUAL TEST (save states): Harden 19/50 Rock Tomb 28/50 Rock Throw 3/50 ----- SOURCES: - https://github.com/pret/pokeruby/blob/master/data/trainers.s - https://github.com/pret/pokeruby/blob/master/data/battle_ai_scripts.s