question: public Collection < IGameMove > validMoves ( IPlayer ip , IGameState state ) { Player player = ( Player ) ip ; ArrayList < IGameMove > valids = new ArrayList < IGameMove > ( ) ; if ( state . isWin ( ) ) { return valids ; } if ( state . isDraw ( ) ) { return valids ; } TicTacToeState gameState = ( TicTacToeState ) state ; TicTacToeBoard board = gameState . board ( ) ; for ( int c = 0 ; c < board . numColumns ( ) ; c ++ ) { for ( int r = 0 ; r < board . numRows ( ) ; r ++ ) { Move move = interpretMove ( state , c , r , player ) ; if ( move != null ) { valids . add ( move ) ; } } } return valids ; }
target:  Return the valid moves at this board state for the given player. Note that this will return an empty collection if the game is over (win, lose or draw).