Time for action – pseu pseu pseudocode

To translate our prioritized peudocode strategy list into actual code, I propose that we turn each attempt at playing a piece into its own function. If we find a valid move, the function will return the square where the computer should play a piece. If there's no valid move, the function will return null, which is the computer code equivalent of "does not exist/totally isn't a thing".

In the ComputerTakeATurn function, let's get rid of (or comment out) the code that randomly chooses a square, which is bolded in the following code:

function ComputerTakeATurn()
{
  var square:GameObject;
  
  var aEmptySquares:List.<GameObject> = new List.<GameObject>();
  
  for(var i:int = 0; i < aSquares.Length; i++)
  {
 square ...

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.