public Set<Move> validMoves(PlayerType player) {
        if (player == PlayerType.WHITE && null != this.whiteMoves) {
            return this.whiteMoves;
        }
        if (player == PlayerType.BLACK && null != this.blackMoves) {
            return this.blackMoves;
        }
        Set<Move> validMoves = new HashSet<Move>();
        for (int y = 0; y < BOARD_SIZE; y++) {
            for (int x = 0; x < BOARD_SIZE; x++) {
                if (validMove(x, y, player)) {
                    validMoves.add(new Move(x, y));
                }
            }
        }
        switch (player) {
        case WHITE:
            this.whiteMoves = validMoves;
            break;
        case BLACK:
            this.blackMoves = validMoves;
            break;
        }
        return validMoves;
    }