public bool Equals(TicTacToeBoard other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other.state, this.state)); }
public object Clone() { var newBoard = new TicTacToeBoard(); for (var i = 0; i < 3; i++) { for (var j = 0; j < 3; j++) { var s = this.GetValue(i, j); newBoard.SetValue(i, j, s); } } return(newBoard); }
private int ComputeUtility(TicTacToeBoard aBoard, string playerToMove) { var retVal = 0; if (aBoard.LineThroughBoard()) { if (playerToMove.Equals("X")) { retVal = -1; } else { retVal = 1; } } return(retVal); }
public TicTacToe() { var moves = new List <XYLocation>(); for (var i = 0; i < 3; i++) { for (var j = 0; j < 3; j++) { var loc = new XYLocation(i, j); moves.Add(loc); } } InitialState["moves"] = moves; InitialState["player"] = "X"; InitialState["utility"] = 0; InitialState["board"] = new TicTacToeBoard(); InitialState["level"] = 0; PresentState = InitialState; }