12. From one forager to multiple agents
Part 2 exposes one GAMA forager through Gymnasium. This part introduces the GAMA-PettingZoo package and PettingZoo's Parallel API, where a step accepts actions and returns observations, rewards and episode flags as mappings keyed by agent identifier.
At package revision 8cf01c3, the README documents a GamaMultiAgent interface, but the Python wrapper reads a PetzAgent and the shipped Prison Escape example uses that same PetzAgent interface. Their field names and result keys differ. The following steps describe the wrapper and shipped example; check the package sources for changes before adapting the interface to another model.
Parallel interaction​
The Python environment returns one entry per agent in each mapping:
observations, infos = env.reset()
actions = {
agent_id: policy(agent_id, observation)
for agent_id, observation in observations.items()
}
observations, rewards, terminations, truncations, infos = env.step(actions)
Build each action mapping from the observations returned by the current step. Keep termination and truncation separate: they represent different episode outcomes. This excerpt assumes that env is a configured GamaParallelEnv and policy returns an action accepted by that agent's action space; a policy can use the agent identifier to select agent-specific parameters. The next step shows the model-side fields used by the package wrapper.