Skip to content

Multi-agent gym prototype #5481

Closed
vincentpierre wants to merge 20 commits into
mainfrom
exp-ma-gym
Closed

Multi-agent gym prototype #5481
vincentpierre wants to merge 20 commits into
mainfrom
exp-ma-gym

Conversation

@vincentpierre

@vincentpierre vincentpierre commented Jul 27, 2021

Copy link
Copy Markdown
Contributor

Proposed change(s)

Trying out a multi agent multi behavior multi observation multi action gym interface

Example of usage :

import gym
import gym_unity

env = gym.make("GridWorld-v0", action_space_seed=42)
print(str(env.active))
_ = env.reset()
print(env.active.behavior)
for i in range(10):
  obs, reward, done, _ = env.step(env.action_space.sample())

env.side_channel["EngineConfigurationChannel"].set_configuration_parameters(width = 5, height=5)
for i in range(100):
  print(env.active.agent)
  obs, reward, done, _ = env.step(env.action_space.sample())

env.side_channel["EngineConfigurationChannel"].set_configuration_parameters(width = 500, height=500)
for i in range(100):
  obs, reward, done, _ = env.step(env.action_space.sample())

env.close()

Note that since there are multiple agents, the user must use env.active.agent to get the id of the agent currently in need of an action. There is no guarantee that the next_obs received after a env.step are from the same agent.
Note that step does not actually step the environment but only sets the action of an agent. When all agents selected their action, then the environment is stepped.

@vincentpierre vincentpierre self-assigned this Jul 27, 2021
@vincentpierre vincentpierre changed the title Exp ma gym Multi-agent gym prototype Jul 27, 2021
@vincentpierre vincentpierre marked this pull request as ready for review July 30, 2021 18:10
@montplaisir

Copy link
Copy Markdown
Contributor

Thank you for your submission!

Since the gym-unity package has been removed, and also since we are migrating from gym to gymnasium (#6309), we will not merge this PR.

For multi-agents, you can use the PettingZoo wrapper.

@montplaisir montplaisir closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants