Package: pogema
Partially-Observable Grid Environment for Multiple AgentsPartially Observable Multi-Agent Pathfinding (PO-MAPF) is a challenging problem that fundamentally differs from regular MAPF. In regular MAPF, a central controller constructs a joint plan for all agents before they start execution. However, PO-MAPF is intrinsically decentralized, and decision-making, such as planning, is interleaved with execution. At each time step, an agent receives a local observation of the environment and decides which action to take. The ultimate goal for the agents is to reach their goals while avoiding collisions with each other and the static obstacles.POGEMA stands for Partially-Observable Grid Environment for Multiple Agents. It is a grid-based environment that was specifically designed to be flexible, tunable, and scalable. It can be tailored to a variety of PO-MAPF settings. Currently, the somewhat standard setting is supported, in which agents can move between the cardinal-adjacent cells of the grid, and each action (move or wait) takes one time step. No information sharing occurs between the agents. POGEMA can generate random maps and start/goal locations for the agents. It also accepts custom maps as input.InstallationJust install from PyPI:pip install pogemaUsing Examplefrompogemaimportpogema_v0,Hard8x8env=pogema_v0(grid_config=Hard8x8())obs,info=env.reset()whileTrue:# Using random policy to make actionsobs,reward,terminated,truncated,info=env.step(env.sample_actions())env.render()ifall(terminated)orall(truncated):breakEnvironmentsConfigagents densitynum agentshorizonEasy8x82.2%164Normal8x84.5%264Hard8x88.9%464ExtraHard8x817.8%864Easy16x162.2%4128Normal16x164.5%8128Hard16x168.9%16128ExtraHard16x1617.8%32128Easy32x322.2%16256Normal32x324.5%32256Hard32x328.9%64256ExtraHard32x3217.8%128256Easy64x642.2%64512Normal64x644.5%128512Hard64x648.9%256512ExtraHard64x6417.8%512512BaselinesThebaseline implementationsare available as a separate repository.InterfacesPogema provides integrations with a range of MARL frameworks: PettingZoo, PyMARL and SampleFactory.PettingZoofrompogemaimportpogema_v0,GridConfig# Create Pogema environment with PettingZoo interfaceenv=pogema_v0(GridConfig(integration="PettingZoo"))PyMARLfrompogemaimportpogema_v0,GridConfigenv=pogema_v0(GridConfig(integration="PyMARL"))SampleFactoryfrompogemaimportpogema_v0,GridConfigenv=pogema_v0(GridConfig(integration="SampleFactory"))GymnasiumPogema is fully capable for single-agent pathfinding tasks.importgymnasiumasgymimportpogema# This interface provides experience only for agent with id=0,# other agents will take random actions.env=gym.make("Pogema-v0")Example of trainingstable-baselines3DQN to solve single-agent pathfinding tasks:CustomizationRandom mapsfrompogemaimportpogema_v0,GridConfig# Define random configurationgrid_config=GridConfig(num_agents=4,# number of agentssize=8,# size of the griddensity=0.4,# obstacle densityseed=1,# set to None for random# obstacles, agents and targets# positions at each resetmax_episode_steps=128,# horizonobs_radius=3,# defines field of view)env=pogema_v0(grid_config=grid_config)env.reset()env.render()Custom mapsfrompogemaimportpogema_v0,GridConfiggrid=""".....#..........#.....................#..........#.....#.####..........###.##.....#..........#.....................#....."""# Define new configuration with 8 randomly placed agentsgrid_config=GridConfig(map=grid,num_agents=8)# Create custom Pogema environmentenv=pogema_v0(grid_config=grid_config)CitationIf you use this repository in your research or wish to cite it, please make a reference to our paper:@misc{https://doi.org/10.48550/arxiv.2206.10944,
  doi = {10.48550/ARXIV.2206.10944},  
  url = {https://arxiv.org/abs/2206.10944},
  author = {Skrynnik, Alexey and Andreychuk, Anton and Yakovlev, Konstantin and Panov, Aleksandr I.},
  keywords = {Machine Learning (cs.LG), Artificial Intelligence (cs.AI), Multiagent Systems (cs.MA), FOS: Computer and information sciences, FOS: Computer and information sciences},
  title = {POGEMA: Partially Observable Grid Environment for Multiple Agents},
  publisher = {arXiv},
  year = {2022},
  copyright = {arXiv.org perpetual, non-exclusive license}
}