Skip to content

Cooperative Mining

coop_mining/coop_mining is a native PettingZoo port of Melting Pot's Cooperative Mining substrate. Six players mine iron alone for reliable reward or coordinate in pairs to extract higher-value gold.

Screenshot

Cooperative Mining global state

API

See the generated Cooperative Mining API reference for signatures and public objects.

Use the family dispatcher:

from mp.coop_mining import env, parallel_env

parallel = parallel_env("coop_mining")
aec = env("coop_mining")

Or import the variant directly:

from mp.coop_mining.coop_mining import CoopMiningConfig, parallel_env

config = CoopMiningConfig()
env = parallel_env(config=config, render_mode="rgb_array")

Agents are named player_0 through player_5. Each infos[agent] includes meltingpot_player_index, preserving Melting Pot's 1-based player ID.

Actions and observations

The action space is Discrete(8):

Action Meaning
0 no-op
1 forward
2 backward
3 step left
4 step right
5 turn left
6 turn right
7 mine

Default per-agent observations are:

Key Shape Type
RGB (88, 88, 3) uint8
READY_TO_SHOOT () float64

state() and render_mode="rgb_array" return the global world RGB frame with shape (216, 216, 3).

Mechanics

Ore sites begin empty, then regrow into iron or gold. Iron is extracted by one mine beam hit and rewards the miner +1. Gold becomes partial after one miner and must be hit by a second distinct miner within the mining window; successful gold extraction rewards both miners +8.

The mine beam has cooldown 3, length 3, and no radius. Walls block beams. Gold that is not completed inside the mining window returns to raw gold.

Reward strategy and failure modes

Optimal reward comes from matching partners on gold: one miner opens a gold site and a distinct second miner completes it before the window expires, giving both players +8. Iron remains useful as fallback income, but agents that only mine iron leave the largest payoffs untouched.

Bad equilibria include risk-averse iron-only play, failed gold starts where no partner arrives in time, and crowding around the same gold site while other sites go unused. Because gold requires two distinct miners, greedy solo policies can repeatedly reset high-value opportunities without reward.

Playable notebook

Launch the playable notebook with:

uv run marimo run notebooks/coop_mining/coop_mining_mo.py

Controls:

  • WASD or arrow keys move the active player.
  • Q/E turn the active player.
  • SPACE fires the mining beam.
  • TAB switches the controlled player.
  • ESC closes the pygame window.

The notebook exposes faster ore regrowth for playability. The environment defaults remain parity-oriented.