Mirror Move Research
For the purposes of Mirror Move, every Pokémon X in battle keeps a short list of attacks that have targeted it. Every time Pokémon Y executes a move that targets Pokémon X, Pokémon X adds that move to the top of the list and notes that Pokémon Y was the one that used it. It doesn't matter if the move misses or fails; if it targeted Pokémon X, it goes on Pokémon X's list. If there is already a move on the list that Pokémon Y used, the older move is removed from the list. Pokémon X only cares about the last move that each other Pokémon on the field used against it. Hence, the list is at most one move long in Single Battles and at most three moves long in Double Battles. Only moves that can be replicated by Mirror Move appear on this list. Moves that cannot be replicated by Mirror Move do not replace existing moves on the list, with few exceptions. If a Pokémon Y leaves play for any reason (switches out, faints, get Roared away, etc.), its move is removed from Pokémon X's list. When a Pokémon uses Mirror Move, it executes the move at the top of its list (the most recently used one). The number of rounds that have passed since the user was targeted with the move does not matter. Replicated moves with a single target will have their target chosen randomly from the available opponents.
Here's an example:
A Pidgeot and a Ninetales face off against a Mr. Mime and a Raichu.
First round action selections:
• Pidgeot selects Tailwind.
• Ninetales selects Confuse Ray and targets its partner, Pidgeot.
• Mr. Mime selects Psychic and targets Ninetales.
• Raichu selects Thunderbolt and targets Pidgeot.
The first round begins.
• Ninetales goes first and confuses the Pidgeot. This gives the Pidgeot a 50% evasion rate due to its ability, Tangled Feet.
• Raichu targets Pidgeot with Thunderbolt, but misses.
• Mr. Mime hits Ninetales with Psychic, doing some damage.
• Pidgeot avoids hitting itself in confusion and uses Tailwind, doubling its and Ninetales' Speed.
Second round action selections:
• Pidgeot selects Mirror Move.
• Ninetales selects Safeguard.
• Mr. Mime selects Psychic and targets Ninetales again.
• Raichu selects Light Screen.
The second round begins.
• Ninetales moves first and puts up a Safeguard.
• Pidgeot goes next (due to Tailwind), avoids confusion, and uses Mirror Move. Pidgeot remembers that Raichu shot a Thunderbolt at it (it doesn't matter that it missed) and Ninetales used Confuse Ray on it (it doesn't consider Safeguard a move that targeted it). Mr. Mime hasn't targeted Pidgeot with anything yet. The Thunderbolt was more recent than the Confuse Ray, so Pidgeot replicates Thunderbolt. The target is chosen randomly and hits the Raichu, doing a small amount of damage.
• Raichu uses Light Screen and puts up a barrier.
• Mr. Mime uses Psychic on Ninetales again, dealing more damage.
Third round action selections:
• Pidgeot selects Mirror Move.
• Ninetales selects Flamethrower and targets Raichu.
• Mr. Mime selects Psychic and targets Ninetales again.
• Raichu selects Quick Attack and targets Pidgeot.
The third round begins.
• Raichu launches its Quick Attack, landing a small hit on Pidgeot.
• Ninetales hits Raichu with Flamethrower. Critical hit! Raichu is KO'd!
• Pidgeot snaps out of confusion and uses Mirror Move. The last move that targeted it was Raichu's Quick Attack, but Raichu has left the field. All memory of Raichu has been erased from Pidgeot's brain. It only knows that Ninetales has hit it with Confuse Ray and Mr. Mime has done nothing to it. So Pidgeot uses Confuse Ray. Since Mr. Mime is the only opponent available, it becomes the target and is confused by Confuse Ray.
• Mr. Mime avoids smacking itself and finishes Ninetales off with a third Psychic.
• The Tailwind peters out.
We'll say that each trainer only had two Pokémon, so no new Pokémon are brought out.
Fourth round action selections:
• Pidgeot selects Mirror Move.
• Mr. Mime selects Psychic and targets Pidgeot.
The fourth round begins.
• Mr. Mime hits itself in confusion.
• Pidgeot uses Mirror Move, but the only Pokémon on the field has yet to target it with a move (Mr. Mime could not actually execute its attack). So, Mirror Move fails.
My apologies for the lengthy example, but I hope it illustrates the mechanics well.
Note:
• As a point of clarity, if no Pokémon has targeted the Mirror Move user with a replicable move since the last time it used Mirror Move, it will simply replicate the same move again (assuming the original user of the move has not left the field).
• Moves that miss the Mirror Move user and those that do not affect it (such as a Ground move on a Flying-type user) can still be replicated by Mirror Move.
• If a Pokémon uses Protect or Detect, moves that target the user and are blocked are still stored in the target's memory and can be replicated by Mirror Move.
• If a Pokémon has a Substitute, moves that target the Substitute are still stored in target's memory and can be replicated by Mirror Move.
• Moves that the user's partner targets the user with are replicated by Mirror Move.
• Damaging attacks with multiple targets such as Discharge and Earthquake that include the Mirror Move user as one of the targets are replicated by Mirror Move.
• Rampage moves (like Thrash) and Momentum moves (like Rollout) that target the user of Mirror Move during execution are replicated by Mirror Move. The Mirror Move user will begin its own rampage or momentum normally, with the usual effects.
• For the purposes of Mirror Move, Global Effects such as Rain Dance and Hail do not 'target' any Pokémon and hence are not replicated by Mirror Move.
• For the purposes of Mirror Move, Field Effects such as Light Screen, Safeguard, Spikes, and Stealth Rock do not 'target' any Pokémon and hence are not replicated by Mirror Move.
• Mirror Move cannot replicate any move that bypasses Protect, including Acupressure, Ghost's Curse, Future Sight, Imprison, Role Play, Perish Song, Psych Up, and Transform. These moves are not added to the Mirror Move user's 'memory'.
• Encore interacts strangely with Mirror Move. It seems that Mirror Move cannot be Encored and Encore cannot be called by Mirror Move. The Mirror Move user remembers being targeted by Encore, but Mirror move fails when trying to replicate it, even when other attacks are available in its memory for replication. More on this later...
• The 'memory' of which moves were used against a Pokémon is not Baton Pass-able. Also, if a Pokémon leaves the field via Baton Pass, its moves are still erased from the memory of other Pokémon, even if the receiver of the Baton Pass knows the move(s) in question.
• Even Pokémon that do not have Mirror Move in their moveset keep this 'memory' of which moves have most recently targeted them. If a Pokémon gains Mirror Move through the use of Sketch or Mimic, it remembers moves used against it prior to gaining Mirror Move.