Skip to content

Commit

Permalink
Warn instead of raising on invalid action
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschneider committed May 4, 2016
1 parent 618c7fd commit 4519a6f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gym/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
logger = logging.getLogger(__name__)

import numpy as np

from gym import error, monitoring
Expand Down Expand Up @@ -79,7 +81,8 @@ def step(self, action):
info (dict): contains auxiliary diagnostic information (helpful for debugging, and sometimes learning)
"""
if not self.action_space.contains(action):
raise error.InvalidAction('Invalid action selected: {}'.format(action))
hint = self.action_space.sample()
logger.warn("Action '{}' is not contained within action space '{}'. HINT: Try using a value like '{}' instead.".format(action, self.action_space, hint))

self.monitor._before_step(action)
observation, reward, done, info = self._step(action)
Expand Down

0 comments on commit 4519a6f

Please sign in to comment.