Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Level Sum Heuristic
def h_levelsum(self) -> int:
'''The sum of the level costs of the individual goals (admissible if goals independent)
:return: int
level_sum = 0
# TODO implement
# for each goal in the problem, determine the level cost, then add them together
for goal in self.problem.goal:
levels = [level for level in range(len(self.s_levels)) for state in self.s_levels[level] if goal == state.literal]
level_sum = reduce(operator.add, levels, level_sum)
return level_sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment