The placement of the O was a simple random number between 1-9, then checking if that location has been taken. If not, it places the O. If yes, it'll try again. It's nothing complicated, and for the purpose of the game (a small idea), it worked fine (apart from the unfair game advantage).