本文整理汇总了Python中gym.RewardWrapper方法的典型用法代码示例。如果您正苦于以下问题:Python gym.RewardWrapper方法的具体用法?Python gym.RewardWrapper怎么用?Python gym.RewardWrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gym
的用法示例。
在下文中一共展示了gym.RewardWrapper方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _render
# 需要导入模块: import gym [as 别名]
# 或者: from gym import RewardWrapper [as 别名]
def _render(self, mode='human', close=False):
if close:
return
if mode == 'human':
from gym.envs.classic_control import rendering
if self.viewer is None:
self.viewer = rendering.SimpleImageViewer()
self.viewer.imshow(np.max(np.stack(self._obs_buffer), axis=0))
return np.max(np.stack(self._obs_buffer), axis=0)
else:
return np.max(np.stack(self._obs_buffer), axis=0)
# class ClipRewardEnv(gym.RewardWrapper):
# def _reward(self, reward):
# """Bin reward to {+1, 0, -1} by its sign."""
# return np.sign(reward)
示例2: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import RewardWrapper [as 别名]
def __init__(self, env):
gym.RewardWrapper.__init__(self, env)
示例3: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import RewardWrapper [as 别名]
def __init__(self, env, scale):
gym.RewardWrapper.__init__(self, env)
self.scale = scale
示例4: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import RewardWrapper [as 别名]
def __init__(self, env: gym.Env, reward_function: BaseRewardFunction):
"""
Parameters
----------
env: gym.Env
A gym environment (potentially already wrapped).
reward_function: BaseRewardFunction
The reward function to be used instead of the original reward.
"""
super(RewardWrapper, self).__init__(env)
self.reward_function = reward_function
self.current_state = None
# pylint: disable=method-hidden
示例5: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import RewardWrapper [as 别名]
def __init__(self, env):
"""
clips the reward to {+1, 0, -1} by its sign.
:param env: (Gym Environment) the environment
"""
gym.RewardWrapper.__init__(self, env)
示例6: __init__
# 需要导入模块: import gym [as 别名]
# 或者: from gym import RewardWrapper [as 别名]
def __init__(self, env):
"""
clips the reward to {+1, 0, -1} by its sign.
:param env: (Gym Environment) the environment
"""
gym.RewardWrapper.__init__(self, env)