Working with the game-tree class
The game state can be represented in a lot of different ways, but you will learn how to create extendible classes to use the high-level board AI algorithms for different circumstances.
Getting ready...
It is important to be clear on object-oriented programming, specifically on inheritance and polymorphism. This is because we'll be creating generic functions that can be applied to a number of board game decisions, and then we'll be writing specific sub-classes that inherit and further specify these functions.
How to do it...
We will build two classes to represent game-tree with the help of the following steps:
- Create the abstract class
Move
:
using UnityEngine; using System.Collections; public abstract class Move { }
- Create the pseudo-abstract class
Board
:
using UnityEngine; using System.Collections; public class Board { protected int player; //next steps here }
- Define the default constructor:
public Board() { player = 1; }
- Implement...