# Path: lcs/strategies/action_selection/EpsilonGreedy.py
# class EpsilonGreedy:
# 
#     def __init__(self, all_actions: int, **kwargs):
#         self.all_actions = all_actions
#         self.epsilon = kwargs['epsilon']
#         assert 0 <= self.epsilon <= 1
# 
#     def __call__(self, population) -> int:
#         if np.random.uniform() > self.epsilon:
#             return BestAction(all_actions=self.all_actions)(population)
#         else:
#             return RandomAction(all_actions=self.all_actions)(population)


import pytest
import lcs.agents.acs as acs
import lcs.agents.acs2 as acs2
from lcs.strategies.action_selection import EpsilonGreedy
        c2 = acs.Classifier(
            condition='1##1', action=0, effect='0###',
            quality=0.571313, reward=6.67011,
            cfg=acs_cfg
        )
        population = acs.ClassifiersList(*[c1, c2])

        # when
        eg = EpsilonGreedy(acs_cfg.number_of_possible_actions,
                           epsilon=0.0)
        best_action = eg(population)

        # then
        assert best_action == 0

    def test_should_work_with_acs2(self, acs2_cfg):
        # given
        c1 = acs2.Classifier(
            condition='1##1', action=0, effect='0###',
            quality=0.571313, reward=7.67011,
            cfg=acs2_cfg
        )
        c2 = acs2.Classifier(
            condition='1##1', action=1, effect='0###',
            quality=0.581313, reward=7.67011,
            cfg=acs2_cfg
        )
        population = acs2.ClassifiersList(*[c1, c2])

        # when

# Path: lcs/strategies/action_selection/EpsilonGreedy.py
# class EpsilonGreedy:
# 
#     def __init__(self, all_actions: int, **kwargs):
#         self.all_actions = all_actions
#         self.epsilon = kwargs['epsilon']
#         assert 0 <= self.epsilon <= 1
# 
#     def __call__(self, population) -> int:
#         if np.random.uniform() > self.epsilon:
#             return BestAction(all_actions=self.all_actions)(population)
#         else:
#             return RandomAction(all_actions=self.all_actions)(population)


# Path: tests/lcs/strategies/action_selection/test_EpsilonGreedy.py
import pytest
import lcs.agents.acs as acs
import lcs.agents.acs2 as acs2
from lcs.strategies.action_selection import EpsilonGreedy

        c2 = acs.Classifier(
            condition='1##1', action=0, effect='0###',
            quality=0.571313, reward=6.67011,
            cfg=acs_cfg
        )
        population = acs.ClassifiersList(*[c1, c2])

        # when
        eg = EpsilonGreedy(acs_cfg.number_of_possible_actions,
                           epsilon=0.0)
        best_action = eg(population)

        # then
        assert best_action == 0

    def test_should_work_with_acs2(self, acs2_cfg):
        # given
        c1 = acs2.Classifier(
            condition='1##1', action=0, effect='0###',
            quality=0.571313, reward=7.67011,
            cfg=acs2_cfg
        )
        c2 = acs2.Classifier(
            condition='1##1', action=1, effect='0###',
            quality=0.581313, reward=7.67011,
            cfg=acs2_cfg
        )
        population = acs2.ClassifiersList(*[c1, c2])

        # when

        eg = EpsilonGreedy(acs2_cfg.number_of_possible_actions,