Esempio n. 1
0
        public List<Move> GetPossibleMoves()
        {
            var possibleMoves = new List<Move>();

            for (int x = 0; x < Board.X_SIZE; x++)
                for (int y = 0; y < Board.Y_SIZE; y++)
                {
                    var move = new Move(x, y);
                    if (IsMoveValid(move))
                        possibleMoves.Add(move);
                }

            return possibleMoves;
        }
        public void Test_Player_DiagonalAsc_Row1(IPlayer player, int value)
        {
            var board = new Board();
            board.AddMove(new Move(0, 2), 1);
            board.AddMove(new Move(2, 0), 1);
            board.AddMove(new Move(0, 1), 2);
            board.AddMove(new Move(1, 2), 2);

            player.Board = board;
            player.Value = value;

            var expectedMove = new Move(1, 1);
            for (int i = 0; i < AMOUNT_OF_ASSERTIONS; i++)
            {
                var move = player.Move();
                Assert.AreEqual(expectedMove, move);
                Thread.Sleep(1);
            }
        }
Esempio n. 3
0
 public bool IsMoveValid(Move move)
 {
     return _board[move.X][move.Y] == 0;
 }
Esempio n. 4
0
 public void AddMove(Move move, int player)
 {
     if (this._board[move.X][move.Y] != 0)
         throw new InvalidOperationException("Position [" + move.X + "," + move.Y + "] is already used: " + this._board[move.X][move.Y]);
     this._board[move.X][move.Y] = player;
 }