Skip to main content

A reinforcement learning environment for sheep herding simulation with PPO, SAC, and TD3 algorithms

Project description

Sheep Herding RL

A reinforcement learning environment for sheep herding simulation with multiple agent implementations including PPO, SAC, and TD3 algorithms.

Description

This package provides a pygame-based simulation environment where agents (dogs and wolves) interact with sheep in a herding scenario. The environment supports both local ego-centric and global observation modes, making it suitable for various reinforcement learning experiments.

Features

  • Multi-Agent Environment: Supports dog (herder) and wolf (predator) agents
  • Multiple RL Algorithms: Implementations of PPO, SAC, and TD3
  • Flexible Observation Modes:
    • Local ego-centric grid observations
    • Global state observations
  • Configurable Parameters: Easy-to-modify configuration system
  • Visualization: Real-time rendering with debug modes
  • Training Framework: Built-in trainers for on-policy and off-policy algorithms

Installation

From Source

git clone https://github.com/dzijo/ferit-hackathon.git
cd ferit-hackathon
pip install -e .

With Development Dependencies

pip install -e ".[dev]"

Dependencies

  • Python >= 3.8
  • PyTorch >= 2.0.0
  • pygame
  • numpy
  • pillow
  • scipy
  • pyyaml
  • matplotlib

Project Structure

sheep-herding-rl/
├── agents/              # Base agent classes
├── algorithms/          # RL algorithm implementations
│   ├── ppo/            # Proximal Policy Optimization
│   ├── sac/            # Soft Actor-Critic
│   └── td3/            # Twin Delayed DDPG
├── sim/                # Simulation environment
│   ├── environment.py  # Main environment class
│   ├── dog.py          # Dog agent
│   ├── wolf.py         # Wolf agent
│   └── sheep.py        # Sheep entities
├── trainers/           # Training utilities
├── utils/              # Helper utilities
├── config.py           # Configuration parameters
├── simulator.py        # Main simulator class
└── actions.py          # Action definitions

Quick Start

from sheep_herding_rl import Simulator
from sheep_herding_rl import config

# Create a simulator instance
sim = Simulator()

# Run a step
state = sim.get_state()
dog_obs = sim.get_dog_observation()
wolf_obs = sim.get_wolf_observation()

# Take actions
dog_action = [0.5, 0.0]  # [forward_speed, turn_rate]
wolf_action = [0.3, 0.1]
sim.step(dog_action, wolf_action)

# Get rewards
dog_reward = sim.get_dog_reward()
wolf_reward = sim.get_wolf_reward()

Configuration

All simulation parameters can be modified in config.py:

  • Observation parameters: Grid size, range, channels
  • Screen dimensions: Width, height
  • Debug modes: Visualization options
  • Splatting methods: Gaussian, bilinear, or discrete

Training

The package includes trainers for different algorithm types:

from trainers.on_policy_trainer import OnPolicyTrainer
from algorithms.ppo.agent import PPOAgent

# Create and train an agent
agent = PPOAgent(obs_dim, action_dim)
trainer = OnPolicyTrainer(agent, sim)
trainer.train(num_episodes=1000)

Algorithms

PPO (Proximal Policy Optimization)

On-policy algorithm with clipped objective for stable training.

SAC (Soft Actor-Critic)

Off-policy algorithm with entropy regularization for exploration.

TD3 (Twin Delayed DDPG)

Off-policy algorithm with twin critics and delayed policy updates.

License

MIT License - See LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Citation

If you use this package in your research, please cite:

@software{sheep_herding_rl,
  title = {Sheep Herding RL: A Multi-Agent Reinforcement Learning Environment},
  author = {ferip},
  year = {2025},
  url = {https://github.com/dzijo/ferit-hackathon}
}

Acknowledgments

Created for the FERIT Hackathon 2025.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sheep_herding_rl-1.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sheep_herding_rl-1.0-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file sheep_herding_rl-1.0.tar.gz.

File metadata

  • Download URL: sheep_herding_rl-1.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for sheep_herding_rl-1.0.tar.gz
Algorithm Hash digest
SHA256 ddf782c5bc9c2e37604ce9ea5bea9f064ed37d69e85d0ea307dee9b7e68336aa
MD5 5252c9d164f0d440d033917e62609126
BLAKE2b-256 0f7dca9840a6490c5a095f8b853cbe4923aecc84ed837814557f1103ab8b4cf3

See more details on using hashes here.

File details

Details for the file sheep_herding_rl-1.0-py3-none-any.whl.

File metadata

  • Download URL: sheep_herding_rl-1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for sheep_herding_rl-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9439d8abad85c83627c34c4592d9e295cc542cab79311fed69bad93893ca7281
MD5 99b658008bc438136ad4b05343ab4515
BLAKE2b-256 f116589e269bf1f42fec24a77d036264f439cefda864ea57f85b82a3e0689ac6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page