Update Base5ActionRLEnv.py

Addition of action_space_type to support Discrete and Box action spaces.
This commit is contained in:
Shane 2024-05-24 21:12:56 +10:00 committed by GitHub
parent 07fba3abb0
commit dc5766fb10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,10 +24,16 @@ class Base5ActionRLEnv(BaseEnvironment):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.action_space_type = action_space_type
self.actions = Actions
def set_action_space(self):
self.action_space = spaces.Discrete(len(Actions))
if self.action_space_type == "Discrete":
self.action_space = spaces.Discrete(len(Actions))
elif self.action_space_type == "Box":
self.action_space = spaces.Box(low=-1, high=1, shape=(1,))
else:
raise ValueError(f"Unknown action space type: {self.action_space_type}")
def step(self, action: int):
"""