IsValidMove() public method

Determines whether the given move is valid for the next turn
public IsValidMove ( int row, int col ) : bool
row int
col int
return bool
Exemplo n.º 1
0
        // returns an array of valid next moves for the given board
        private List <Move> ValidMovesForBoard(GameBoardViewModel viewModel)
        {
            List <Move> moves = new List <Move>();

            for (int row = 0; row < 8; row++)
            {
                for (int col = 0; col < 8; col++)
                {
                    if (viewModel.IsValidMove(row, col))
                    {
                        moves.Add(new Move()
                        {
                            Row    = row,
                            Column = col
                        });
                    }
                }
            }

            return(moves);
        }
        // returns an array of valid next moves for the given board
        private List<Move> ValidMovesForBoard(GameBoardViewModel viewModel)
        {
            List<Move> moves = new List<Move>();

              for (int row = 0; row < 8; row++)
              {
            for (int col = 0; col < 8; col++)
            {
              if (viewModel.IsValidMove(row, col))
              {
            moves.Add(new Move()
            {
              Row = row,
              Column = col
            });
              }
            }
              }

              return moves;
        }