Skip to content

Instantly share code, notes, and snippets.

@JamWils
Created April 23, 2017 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamWils/3d88d82ad66371139c9765f24200f5e0 to your computer and use it in GitHub Desktop.
Save JamWils/3d88d82ad66371139c9765f24200f5e0 to your computer and use it in GitHub Desktop.
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