The code updates x and y, then trains the model, and then makes a prediction. “Fair” code would make a prediction, then update x and y and train the model
This explains the behavior mentioned in the comments where the computer gets an impressive early lead due to the players next move being one of only a few datapoints it learns from, then backs off to a more plausible advantage as the leaked data is diluted by past data.