ethicalgardeners¶
Ethical Gardeners: A simulation environment for ethical reinforcement learning.
The Ethical Gardeners package implements a simulation environment where agents (gardeners) interact with a grid world, planting and harvesting flowers while considering ethical considerations. This environment is designed to study and promote ethical behaviors in reinforcement learning algorithms.
Main Components:¶
GridWorld: The simulation grid representing the physical environment. It contains cells (Cell) of different types (CellType).Agent: The gardeners who act in the environment.Flower: Flowers that can be planted, grow, and reduce pollution.create_action_enum(): Function that dynamically create an enumeration of actions for agents based on the number of flower types (_ActionEnum).ActionHandler: Handles the execution of agent actions in the environment.RewardFunctions: Defines reward functions for agents based on their actions in the environment.observation: Defines how agents perceive the environment.MetricsCollector: Tracks and exports various performance metrics.renderer: Display the environment state to the user.GardenersEnv: The main environment class that integrates all components and provides the interface for interaction with RL agents.
Usage Examples:¶
import hydra
from ethicalgardeners import GardenersEnv, make_env
from ethicalgardeners.main import run_simulation, _find_config_path
@hydra.main(version_base=None, config_path=_find_config_path())
def main(config):
# Initialise the environment with the provided configuration
env = make_env(config)
env.reset()
# Main loop for the environment
run_simulation(env)
Launch¶
To run the simulation with the default configuration. After cloning the project, at the project root, use the following command:
python ethicalgardeners/main.py --config-name config
After installing the package using pip, you can also run:
python -m ethicalgardeners.main --config-name config
Configuration¶
The environment can be customized using a YAML configuration file with Hydra. The default configuration file is located at configs/config.yaml. You can override the default configuration parameters by modifying the YAML file or using command line arguments when running the script:
python -m ethicalgardeners.main grid=from_file observation=total
metrics=full
This package is designed to be used with reinforcement learning frameworks such as Gymnasium or pettingzoo and follows the API conventions of these frameworks.
For more information, see the complete documentation at the Ethical Gardeners documentation.
- members:
Modules
The action module defines the possible actions agents can take in the environment. |
|
Handles the execution of agent actions in the Ethical Gardeners simulation. |
|
Represents a gardener agent in the Ethical Gardeners simulation. |
|
Utilities to train and evaluate RL agents using Stable Baselines3 on the EthicalGardeners PettingZoo AEC environment. |
|
Constant values used throughout the Ethical Gardeners simulation. |
|
The GardenersEnv module provides the main simulation environment for the Ethical Gardeners reinforcement learning platform. |
|
The gridworld module represents the physical environment simulation grid for Ethical Gardeners. |
|
Main entry point for the Ethical Gardeners simulation environment. |
|
The MetricsCollector module provides metrics tracking and exporting capabilities for the Ethical Gardeners simulation environment. |
|
The Observation module defines how agents perceive the environment in the Ethical Gardeners simulation. |
|
The Renderer module provides visualization capabilities for the Ethical Gardeners simulation environment. |
|
Module containing reward functions for the Ethical Gardeners environment. |