How to do it...

We will create a new class, deriving it from Board, override its parent's methods, and create new ones:

  1. Create the BoardTicTac class, deriving it from Board, and add the corresponding member variables for storing the board's values:
using UnityEngine; 
using System; 
using System.Collections; 
using System.Collections.Generic; 
 
public class BoardTicTac : Board 
{ 
    protected int[,] board; 
    protected const int ROWS = 3; 
    protected const int COLS = 3; 
} 
  1. Implement the default constructor:
public BoardTicTac(int player = 1) 
{ 
    this.player = player; 
    board = new int[ROWS, COLS]; 
    board[1,1] = 1; 
} 
  1. Define the function for retrieving the next player in turn:
private int GetNextPlayer(int p) 
{ 
    if (p == 1) 
        return 2; 
    return 1; 
}
  1. Create ...

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition 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.