Example #1
0
 def __init__(self, actions):
     for i, a in enumerate(actions):
         for a2 in actions[i + 1:]:
             assert a is not a2
             assert a2 not in a.mutex
             assert a not in a2.mutex
     self.actions = actions
     self.must_bits = BitMask.all_union([a.must_bits for a in actions])
     self.then_bits = BitMask.all_union([a.then_bits for a in actions])
Example #2
0
    def score_accomplishment_pool(self, pool, goal, start):
        """Scores an ActionPool, given a goal and initial state.

        This returns a tuple, with each item being a different tie-breaker"""
        remaining = goal.unset_from_action(pool.then_bits)
        requirement = pool.must_bits
        union = BitMask.all_union([remaining, requirement])
        if start:
            start_score = start.difference(union).count_set()
        else:
            start_score = 0
        if hasattr(pool, "action_count"):
            count_score = pool.action_count()
        else:
            count_score = 0
        score = (remaining.count_set(), union.count_set(), start_score, count_score)
        return score