Example #1
0
    def try_or_random_conditions(self):
        if "conditions" in self.params.keys():
            return self.params["conditions"]

        # create conditions equal to a random amount between 0 and 3
        amount = int(1 / random.random() - 1) % 4
        # TO TEST: check if the entity should be self or target
        return [
            Condition.generate_condition(self.target, {"target": self.target})
            for _ in range(amount)
        ]
Example #2
0
 def random_branch(self, depth=1.):
     width = 1.
     branch = []
     while random.random() < 1 / width:
         width += 1
         if random.random() < 1 / depth:
             branch.append([
                 Condition.generate_condition(self, {}),
                 self.random_branch(depth + 1)
             ])
         else:
             branch.append(Action({}))
     return branch