Пример #1
0
 public bool Equals(TicTacToeBoard other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.state, this.state));
 }
Пример #2
0
        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);
        }
Пример #3
0
        private int ComputeUtility(TicTacToeBoard aBoard, string playerToMove)
        {
            var retVal = 0;

            if (aBoard.LineThroughBoard())
            {
                if (playerToMove.Equals("X"))
                {
                    retVal = -1;
                }
                else
                {
                    retVal = 1;
                }
            }
            return(retVal);
        }
Пример #4
0
        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;
        }