Skip to main content

GridHunt

Tests Docs PyPI Python PettingZoo License: MIT

Heterogeneous, mixed-motive predator-prey environments for multi-agent reinforcement learning and human-agent teaming, with a PettingZoo ParallelEnv API. Documentation: ajuanijustus.github.io/gridhunt.

Four GridHunt scenarios played by the scripted team

  • Heterogeneous agents: capture power, vision radius, speed and terrain restrictions are set per agent.
  • Mixed-motive scenarios: stag hunts, toxic prey, risky targets, roles that only scout.
  • Human-agent teaming: gridhunt.hat runs studies with people in or on the loop: keyboard control with reaction times, AI teammates, buttons that switch teams of policies, cues only the participant sees, questionnaires and per-participant JSON Lines logs.
  • Baselines: IPPO, MAPPO and HAPPO over 20 seeds, reported as IQM with 95% bootstrap CIs (benchmark/).

Install

pip install gridhunt            # environments only (numpy, gymnasium, pettingzoo)
pip install "gridhunt[render]"  # + pygame window, rgb_array frames and the interactive GUI
pip install "gridhunt[hat]"     # + the human-agent teaming toolkit

From source:

git clone https://github.com/ajuanijustus/gridhunt.git
cd gridhunt
pip install -e ".[dev]"

Quick start

import gridhunt

env = gridhunt.make("GridHunt-ClassicStag-v0")
obs, infos = env.reset(seed=42)
while env.agents:
    actions = {agent: env.action_space(agent).sample() for agent in env.agents}
    obs, rewards, terminations, truncations, infos = env.step(actions)

gridhunt.list_envs() lists the registered environments. Any scenario setting can be overridden, for example gridhunt.make("GridHunt-ToxicStag-v0", max_steps=200, reward_mode="team"). With PettingZoo 1.27 or later, import gridhunt also registers every environment with PettingZoo, so pettingzoo.make("parallel", "GridHunt-ClassicStag-v0") works too.

Human-agent teaming

import gridhunt
from gridhunt.hat import ARROW_KEYS, HumanSession, Likert, Questionnaire, SessionLog
from gridhunt.policies import GreedyPolicy

env = gridhunt.make("GridHunt-ClassicStag-v0")
session = HumanSession(
    env,
    humans={"predator_0": ARROW_KEYS},              # the participant plays this hunter
    teammates={"predator_1": GreedyPolicy()},       # an AI teammate plays the other
    log=SessionLog("hat_logs", participant="P01"),
)
with session:
    for round_ in range(3):
        session.run_episode(seed=round_, max_steps=60)
        session.ask(Questionnaire([Likert("trust", "I trusted my AI teammate.")]))

Teammates can also be the trained benchmark agents, which run on numpy alone (no PyTorch):

from gridhunt import zoo

team = zoo.load("toxic_stag", "mappo", rank="best")   # downloaded once, then cached
env = team.make_env()                                 # the scenario as it was trained
session = HumanSession(env, humans={"predator_0": ARROW_KEYS},
                       teammates={"predator_1": team, "predator_2": team})

examples/hitl_play_with_ai.py is a complete version, and examples/hotl_policy_delegation.py is a human-on-the-loop study in which the participant chooses which AI team plays from cues only they can see. Both run headless with --dry-run.

Scenarios

Environment Grid Agents Challenge
GridHunt-ClassicStag-v0 5×5 2 Stag hunt: coordinate on the stag or settle for hares
GridHunt-ToxicStag-v0 7×7 3 Only one predator can tell whether the stag is toxic
GridHunt-Specialists-v0 10×10 2 A fast scout with full vision and a strong but short-sighted bruiser
GridHunt-Military-v0 10×10 2 A UAV that can only scout guides a slow ground vehicle through terrain
GridHunt-Raid-v0 12×12 3 Targets of rising value need more raiders and may be trapped
GridHunt-PigChase-v0 9×9 2 Two predators must reach the pig together through a maze
GridHunt-LandAndSea-v0 10×10 2 A boat and a land unit, each confined to its terrain
GridHunt-Swarm-v0 23×23 10 Ten predators, three stags and five hares; crowding onto a hare costs points

Repository layout

Path Contents
src/gridhunt/ The installable package
benchmark/ Benchmark protocol, IPPO/MAPPO/HAPPO baselines, analysis and results (not installed)
tests/ Library tests
examples/ Runnable examples
docs/ Documentation site sources (mkdocs serve to preview)

Citing

If you use GridHunt, please cite it; see CITATION.cff.

License

MIT

Metadata

Release files for gridhunt 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gridhunt 1.0.0
File Size Uploaded Provenance Actions
gridhunt-1.0.0.tar.gz 526.2 kB With provenance Details for gridhunt-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gridhunt 1.0.0
File Interpreter ABI Platform Actions
gridhunt-1.0.0-py3-none-any.whl Python 3 none any Details for gridhunt-1.0.0-py3-none-any.whl

Total release size: 931.8 kB

Release files / gridhunt-1.0.0.tar.gz

Download URL gridhunt-1.0.0.tar.gz
Size 526.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9c7e14e9a1728eecb8be483bb411d380e73d214037997d05409af4ff360a30a7
BLAKE2b-256 checksum
How to use checksums
6f0bcc07131bb15a10b27a1efb09d51f40479aba06a4173f921ca74b58f7672c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / gridhunt-1.0.0-py3-none-any.whl

Download URL gridhunt-1.0.0-py3-none-any.whl
Size 405.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b30fc1cd09de65edaa95c7d5ab4875045b96d2154259952470acb07a0fdad5e4
BLAKE2b-256 checksum
How to use checksums
f780d883c79515d8f2a4c4532f1efe00c1e01d93a3c632102ba1c4d32400dc73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for gridhunt 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gridhunt-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page