예제 #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