CartPole
CartPole
Bases: EnvType
This class represents the CartPole environment.
__init__(algo=Algo.PPO, algo_param={'policy': 'MlpPolicy', 'verbose': 0, 'device': 'cpu'}, prompt={'Goal': 'Balance a pole on a cart', 'Observation Space': 'Num Observation Min Max\n 0 Cart Position -4.8 4.8\n 1 Cart Velocity -Inf Inf\n 2 Pole Angle ~ -0.418 rad (-24°) ~ 0.418 rad (24°)\n 3 Pole Angular Velocity -Inf Inf'})
Initializes the CartPole environment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
algo
|
Algo
|
The algorithm to use for training. |
PPO
|
algo_param
|
dict
|
The parameters for the algorithm. |
{'policy': 'MlpPolicy', 'verbose': 0, 'device': 'cpu'}
|
prompt
|
dict | str
|
The prompt for the environment. |
{'Goal': 'Balance a pole on a cart', 'Observation Space': 'Num Observation Min Max\n 0 Cart Position -4.8 4.8\n 1 Cart Velocity -Inf Inf\n 2 Pole Angle ~ -0.418 rad (-24°) ~ 0.418 rad (24°)\n 3 Pole Angular Velocity -Inf Inf'}
|
__repr__()
String representation of the CartPole environment.
Returns:
Name | Type | Description |
---|---|---|
str |
String representation of the CartPole environment. |
objective_metric(states)
Objective metric for the CartPole environment. Calculates a score for the given state on a particular observation of the CartPole environment.
:param state: The state of the CartPole environment. :return: a table of tuples containing the string name of the metric and the value of the metric.
success_func(env, info)
Cartpole Evaluation Function
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env
|
gym.Env : Environment |
required | |
info
|
dict : Information from the environment |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
tuple[bool | bool]
|
True if the episode is truncated, False otherwise |