Bug with following code logic

I have a problem with my project at Berkeley BJC Tic-tac-toe by 28hcastada | Snap! Build Your Own Blocks; when I run it by itself the computer player (O) seems to place an X when forced to play in the bottom right square

The top three squares from left to right are 1, 2, 3, and the other rows are the same (4, 5, 6, and 7, 8, 9).
The computer is coded to prioritize winning moves, then moves that block player wins, then the center, then any square that is in an empty line containing one O and no Xs, then squares 1, 3, 7, 9, 2, 4, 6, 8 (in that order).

This game specifically had X1, O5, X2, O3, X7, O4, X6, (O?X?)9 #tie
Similar games go X6, O5, X3, (O?X?)9 #X and X1, O5, X7, O4, X5, O3, X2, (O?X?)9 #tie.

The only way I’ve managed to fix it is by going into the code, turning on stepping, running the project, and inspecting the ‘move in this square’ block before the computer moves. I think this forces the computer to double check the value of the variable X’s turn?, which should flip for every turn - if the player places, it becomes false, then when the computer places, it should become true.
I think that the fact that it runs properly in every case as long as stepping is on and the function definition is visible is proof that it’s not a problem with my code, because it runs properly when it tangibly runs through the code, and I’ve run through the logic with a partner to ensure any problems with it. Maybe we missed something, but we didn’t find anything.

I don’t really know why this happens, so I wanted to report it as a bug just in case. If it is actually a problem with my code, that’s my bad.

Remember, don’t do their homework for them, just teach them helpful things.