def fitness(individual, problem):
    """
    Score the fitness of an indivdual based on a MAXSAT problem.
    :param individual: An "individual" represented as an array
    :param problem: MAXSAT problem to compute fitness in ref to, usually
    stored as global MAXSAT_PROBLEM
    :return: An int representation of individuals fitness - higher is better
    """
    fit_score = 0
    for clause in problem["clauses"]:
        check = False
        for literal in clause:
            if literal > 0:
                check = check or individual[literal - 1]
            else:
                check = check or not individual[abs(literal) - 1]
        if check:
            fit_score += 1
    return fit_score