When teaching Surf to Squirtle, if Squirtle already has four moves (i.e. didn't caught a Paras, so had to teach Dig to Squirtle), it will replace the second move, Tail Whip, leaving memory address 0x0C25 at 5 and 0x0C26 at 1. When it has learned Surf, since the teaching event has chain=true, the AI directly goes on and tries to teach Earthquake to Nidoking, but there is still one more text box ("A learned SURF!") to clear. Since the aforementioned addresses hasn't changed, the AI is tricked into thinking it is choosing the move to replace, and ends up pressing Up (to move from menu item 1 to item 0) indefinitely.
When teaching Surf to Squirtle, if Squirtle already has four moves (i.e. didn't caught a Paras, so had to teach Dig to Squirtle), it will replace the second move, Tail Whip, leaving memory address 0x0C25 at 5 and 0x0C26 at 1. When it has learned Surf, since the teaching event has chain=true, the AI directly goes on and tries to teach Earthquake to Nidoking, but there is still one more text box ("A learned SURF!") to clear. Since the aforementioned addresses hasn't changed, the AI is tricked into thinking it is choosing the move to replace, and ends up pressing Up (to move from menu item 1 to item 0) indefinitely.
Example seed: 1551333790