August 2018
Beginner
334 pages
10h 19m
English
We will create the base class for handling all of our main algorithms and implement the Minimax function as follows:
using UnityEngine;
using System.Collections;
public class BoardAI
{
}
public static float Minimax(
Board board,
int player,
int maxDepth,
int currentDepth,
ref Move bestMove)
{
// next steps here
}
if (board.IsGameOver() || currentDepth == maxDepth)
return board.Evaluate(player);
bestMove = null;
float bestScore = Mathf.Infinity;
if (board.GetCurrentPlayer() == player)
bestScore = Mathf.NegativeInfinity;
Read now
Unlock full access