Skip to content

Commit

Permalink
renamed action modes for agents
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim0x60 committed May 2, 2024
1 parent a5b862c commit 292f090
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions examples/mountain_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
print(1)
"""

env = gym.make('MountainCarContinuous-v0', max_episode_steps=500, render_mode='human')
env = gym.make('MountainCarContinuous-v0',
max_episode_steps=500,
render_mode='human')
program = Program(source=mountain_car_solver, language='Python')
agent = program.spawn(action_mode='continuous')
agent = program.spawn(action_mode='box')

obs, info = env.reset()
print(obs, info)
Expand Down
4 changes: 2 additions & 2 deletions programlib/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def decode_action(action, mode='auto'):
if mode == 'discrete':
return int(action)
elif mode == 'continuous':
elif mode == 'box':
try:
x = np.array(eval(action))
except SyntaxError:
Expand All @@ -18,7 +18,7 @@ def decode_action(action, mode='auto'):
try:
return decode_action(action, 'discrete')
except ValueError:
return decode_action(action, 'continuous')
return decode_action(action, 'box')
else:
raise ValueError(f'Invalid mode: {mode}')

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "programlib"
version = "11.0.2"
version = "12.0.0"
description = "Programs as Objects"
authors = ["Vadim Liventsev <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 292f090

Please sign in to comment.