Tic Tac Toe at the speed of light

Whoa... okay. The computer player plays a piece, but it does so instantly after the human clicks to place a piece. This is what happens when you play a game against a superior intellect!

To dull the game down to human-comprehensible speed, let's build in a brief pause before the computer makes a move just before the function call in the ClickSquare function.

 yield WaitForSeconds(2);
  ComputerTakeATurn();

Try the game again. There is now a nice 2-second pause before the computer makes a move, providing the illusion that the computer is "thinking" (when really, it's just randomly throwing darts at the wall). This Artificial Intelligence stuff is looking more and more like a magic trick, isn't it?

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.