renom_rl.environ.env

class renom_rl.environ.env. BaseEnv ( action_shape=None , state_shape=None )

Bases: object

Base class of environment. The methods step , reset and sample must be overridden.

Example

>>> import numpy as np
>>> from renom_rl import BaseEnv
>>> class CustomEnv(BaseEnv):
...    def __init__(self):
...         action_shape = (5, )
...         state_shape = (86, 86)
...
...     def step(self, action):
...         return state, reward, terminal
...
...     def sample(self):
...         return self.step(np.random.randInt(0, 5))[0]
...
...     def reset(self):
...         return initial_state
...
step ( action )

This method must be overridden. This method must accept single action and return next state , reward and terminal . When overriding this method, don’t forget to return above data.

Returns: | – Environment’s next state. | (float): Reward gotten from the transition. | (bool): Terminal flag. |
Return type: ndarray
sample ( )

This method must be overridden. This method must return random action.

Returns: Sampled action. Its shape must be same as BaseEnv.action_shape.
Return type: (int, ndarray)
reset ( )

This method must be overridden.

Returns: Initial state. Its shape must be same as BaseEnv.state_shape.
Return type: (int, ndarray)
render ( )

Rendering method. If you want to render environment states, please override this method.