Skip to content

Commit 5f90eb2

Browse files
Resolves #74 (#93)
* feat(issue-74): Create base class for strategy * test(issue-74): Add unit tests for strategy base * feat(issue-74): Create base class for strategy * test(issue-74): Add unit tests for strategy base * feat(issue-74): Remove Strategy class and unit test #93 * feat(issue-74): Add choose_action method to Agent class #93
1 parent 07bc819 commit 5f90eb2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/units/agents/test_agent_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ def test_abstract_methods(self):
4242

4343
# WHEN
4444
step_return = fake_agent.step()
45+
choose_action_return = fake_agent.choose_action(FakeActionSpace())
4546

4647
# THEN
4748
assert isinstance(AgentBase, ABCMeta)
4849
assert step_return is None
50+
assert choose_action_return is None
4951

5052
def test_reset(self):
5153
# GIVEN

urnai/agents/agent_base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from abc import ABC, abstractmethod
22

3+
from urnai.actions.action_base import ActionBase
34
from urnai.actions.action_space_base import ActionSpaceBase
45
from urnai.models.model_base import ModelBase
56
from urnai.states.state_base import StateBase
@@ -27,6 +28,13 @@ def __init__(self, action_space : ActionSpaceBase,
2728
def step(self) -> None:
2829
...
2930

31+
@abstractmethod
32+
def choose_action(self, action_space : ActionSpaceBase) -> ActionBase:
33+
"""
34+
Method that contains the agent's strategy for choosing actions
35+
"""
36+
...
37+
3038
def reset(self, episode=0) -> None:
3139
"""
3240
Resets some Agent class variables, such as previous_action

0 commit comments

Comments
 (0)