mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-22 14:56:43 +02:00
30 lines
877 B
Python
30 lines
877 B
Python
from mfg_package.environment.groups.env_objects import EnvObjects
|
|
from mfg_package.environment.groups.mixins import PositionMixin
|
|
from mfg_package.environment.entity.agent import Agent
|
|
|
|
|
|
class Agents(PositionMixin, EnvObjects):
|
|
_entity = Agent
|
|
is_blocking_light = False
|
|
can_move = True
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
|
|
@property
|
|
def obs_pairs(self):
|
|
return [(a.name, a) for a in self]
|
|
|
|
@property
|
|
def action_space(self):
|
|
from gymnasium import spaces
|
|
space = spaces.Tuple([spaces.Discrete(len(x.actions)) for x in self])
|
|
return space
|
|
|
|
@property
|
|
def named_action_space(self):
|
|
named_space = dict()
|
|
for agent in self:
|
|
named_space[agent.name] = {action.name: idx for idx, action in enumerate(agent.actions)}
|
|
return named_space
|