コード例 #1
0
ファイル: cellrider.py プロジェクト: humm/goals
    def next_goal(self):

        target_cell = None
        dice = random.random()

        if dice < self.cfg.effect.random_explo:
            target_cell = random.sample(self.celltree.active_cells, 1)[0]

        # elif dice < self.cfg.effect.random_explo + self.cfg.effect.unknown_explo:
        #     target_cell = self._priority_choice()

        if target_cell is None:
            target_cell = self._priority_choice()

        if target_cell is None:
            cell_uid = [cell.uid for cell in self.celltree.active_cells]
            interests = [cell.interest() for cell in self.celltree.active_cells]
            if sum(interests) > 0:
                idx = toolbox.roulette_wheel(interests)
                priority_uid = [cell.uid for cell in self.celltree.active_cells]
                target_cell = self.celltree.cells[priority_uid[idx]]

        if target_cell is not None:
            return target_cell.random_point()
        else:
            return None
コード例 #2
0
ファイル: cellrider.py プロジェクト: benureau/goals
    def next_goal(self):

        target_cell = None
        dice = random.random()

        if dice < self.cfg.effect.random_explo:
            target_cell = random.sample(self.celltree.active_cells, 1)[0]

        # elif dice < self.cfg.effect.random_explo + self.cfg.effect.unknown_explo:
        #     target_cell = self._priority_choice()

        if target_cell is None:
            target_cell = self._priority_choice()

        if target_cell is None:
            cell_uid = [cell.uid for cell in self.celltree.active_cells]
            interests = [
                cell.interest() for cell in self.celltree.active_cells
            ]
            if sum(interests) > 0:
                idx = toolbox.roulette_wheel(interests)
                priority_uid = [
                    cell.uid for cell in self.celltree.active_cells
                ]
                target_cell = self.celltree.cells[priority_uid[idx]]

        if target_cell is not None:
            return target_cell.random_point()
        else:
            return None
コード例 #3
0
ファイル: static.py プロジェクト: benureau/goals
 def next_goal(self):
     # choose an area proportionally to its interest
     index = toolbox.roulette_wheel(
         [cell.interest() for cell in self.cells])
     # choose a random goal in it.
     goal = self.cells[index].random_point()
     return goal
コード例 #4
0
ファイル: bias.py プロジェクト: benureau/l2l
 def _compute_order_bias(self):
     self.order_bias = []
     weights_cpy = list(self.weights)
     assert all(w > 0.0 for w in weights_cpy)
     for _ in xrange(len(self.orders)):
         idx = toolbox.roulette_wheel(weights_cpy)
         weights_cpy[idx] = 0.0
         self.order_bias.append(self.orders[idx])
コード例 #5
0
ファイル: bias.py プロジェクト: humm/l2l
 def _compute_order_bias(self):
     self.order_bias = []
     weights_cpy = list(self.weights)
     assert all(w > 0.0 for w in weights_cpy)
     for _ in xrange(len(self.orders)):
         idx = toolbox.roulette_wheel(weights_cpy)
         weights_cpy[idx] = 0.0
         self.order_bias.append(self.orders[idx])
コード例 #6
0
ファイル: cellrider.py プロジェクト: humm/goals
    def _priority_choice(self):
        target_cell = None
        priority_uid = [cell.uid for cell in self.celltree.active_cells]
        priorities   = [self._priority(cell) for cell in self.celltree.active_cells]
        if sum(priorities) > 0:
            idx = toolbox.roulette_wheel(priorities)
            target_cell = self.celltree.cells[priority_uid[idx]]

        return target_cell
コード例 #7
0
ファイル: cellrider.py プロジェクト: benureau/goals
    def _priority_choice(self):
        target_cell = None
        priority_uid = [cell.uid for cell in self.celltree.active_cells]
        priorities = [
            self._priority(cell) for cell in self.celltree.active_cells
        ]
        if sum(priorities) > 0:
            idx = toolbox.roulette_wheel(priorities)
            target_cell = self.celltree.cells[priority_uid[idx]]

        return target_cell
コード例 #8
0
ファイル: grid.py プロジェクト: humm/goals
    def next_goal(self):
        """Generate a new goal"""
        # decide between trying a virgin available cell
        # or an interesting cell
        dice = random.random()
        if dice < self.cfg.effect.random_explo:
            idx = random.randint(0, len(self.cells) - 1)
        # elif dice < self.cfg.random_explo + self.cfg.unknown_explo:
        #     explo_interest = [cell.exploration_interest() for cell in self.cells]
        #     if sum(explo_interest) > 0:
        #         idx = toolbox.roulette_wheel(explo_interest)
        #     else:
        #         idx = toolbox.roulette_wheel([cell.interests[-1] for cell in self.cells])
        else:
            idx = toolbox.roulette_wheel([cell.interest() for cell in self.cells])

        return self.cells[idx].random_point()
コード例 #9
0
ファイル: grid.py プロジェクト: benureau/goals
    def next_goal(self):
        """Generate a new goal"""
        # decide between trying a virgin available cell
        # or an interesting cell
        dice = random.random()
        if dice < self.cfg.effect.random_explo:
            idx = random.randint(0, len(self.cells) - 1)
        # elif dice < self.cfg.random_explo + self.cfg.unknown_explo:
        #     explo_interest = [cell.exploration_interest() for cell in self.cells]
        #     if sum(explo_interest) > 0:
        #         idx = toolbox.roulette_wheel(explo_interest)
        #     else:
        #         idx = toolbox.roulette_wheel([cell.interests[-1] for cell in self.cells])
        else:
            idx = toolbox.roulette_wheel(
                [cell.interest() for cell in self.cells])

        return self.cells[idx].random_point()
コード例 #10
0
ファイル: static.py プロジェクト: humm/goals
 def next_goal(self):
     # choose an area proportionally to its interest
     index = toolbox.roulette_wheel([cell.interest() for cell in self.cells])
     # choose a random goal in it.
     goal = self.cells[index].random_point()
     return goal