ethicalgardeners.algorithmsΒΆ

Utilities to train and evaluate RL agents using Stable Baselines3 on the EthicalGardeners PettingZoo AEC environment.

members:

Functions

evaluate(env, model[, algorithm_name, ...])

Evaluate a trained agent vs a random agent

get_latest_policy(algorithm_name)

Retrieve the most recently saved policy file for the given environment and algorithm.

make_SB3_env(env_fn, config)

Create a Stable Baselines3 compatible environment with action masking.

make_env_thunk(env_fn, config)

Return a thunk that creates a Stable Baselines3 compatible environment.

mask_fn(env)

Return the function that provides the action mask for the current agent.

predict_action(model, observation, action_mask)

Predict the next action using the model, considering the action mask if needed.

save_model(model, algorithm_name)

Save the trained model with a timestamped filename.

train(model[, algorithm_name, total_timesteps])

Train a given model and save it.

Classes

SB3Wrapper(env)

Wrapper to adapt a PettingZoo AEC environment to be compatible with Stable Baselines3. - Only returns the observation (without action mask) for the current agent. - the observation_space and action_space are aligned with the current agent.