mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-26 00:07:41 +00:00
15 lines
408 B
Python
15 lines
408 B
Python
![]() |
import numpy as np
|
||
|
|
||
|
from gym import ActionWrapper
|
||
|
from gym.spaces import Box
|
||
|
|
||
|
|
||
|
class ClipAction(ActionWrapper):
|
||
|
r"""Clip the continuous action within the valid bound. """
|
||
|
def __init__(self, env):
|
||
|
assert isinstance(env.action_space, Box)
|
||
|
super(ClipAction, self).__init__(env)
|
||
|
|
||
|
def action(self, action):
|
||
|
return np.clip(action, self.action_space.low, self.action_space.high)
|