mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-06-23 20:11:34 +02:00
Merge branch 'remove-tiles'
# Conflicts: # marl_factory_grid/environment/actions.py # marl_factory_grid/environment/entity/entity.py # marl_factory_grid/environment/factory.py # marl_factory_grid/modules/batteries/rules.py # marl_factory_grid/modules/clean_up/groups.py # marl_factory_grid/modules/destinations/entitites.py # marl_factory_grid/modules/destinations/groups.py # marl_factory_grid/modules/destinations/rules.py # marl_factory_grid/modules/items/rules.py # marl_factory_grid/modules/maintenance/entities.py # marl_factory_grid/utils/config_parser.py # marl_factory_grid/utils/level_parser.py # marl_factory_grid/utils/states.py
This commit is contained in:
@ -39,7 +39,8 @@ class Destination(BoundEntityMixin, Entity):
|
||||
def has_just_been_reached(self):
|
||||
if self.was_reached:
|
||||
return False
|
||||
agent_at_position = any(self.bound_entity == x for x in self.tile.guests_that_can_collide)
|
||||
agent_at_position = any(c.AGENT.lower() in x.name.lower() for x in state.entities.pos_dict[self.pos] if x.var_can_collide)
|
||||
|
||||
if self.bound_entity:
|
||||
return ((agent_at_position and not self.action_counts)
|
||||
or self._per_agent_actions[self.bound_entity.name] >= self.action_counts >= 1)
|
||||
|
@ -1,10 +1,11 @@
|
||||
from marl_factory_grid.environment.groups.env_objects import EnvObjects
|
||||
from marl_factory_grid.environment.groups.mixins import PositionMixin, HasBoundMixin
|
||||
from marl_factory_grid.environment.groups.mixins import PositionMixin
|
||||
from marl_factory_grid.modules.destinations.entitites import Destination
|
||||
from marl_factory_grid.environment import constants as c
|
||||
from marl_factory_grid.modules.destinations import constants as d
|
||||
|
||||
|
||||
class Destinations(PositionMixin, EnvObjects):
|
||||
|
||||
_entity = Destination
|
||||
is_blocking_light: bool = False
|
||||
can_collide: bool = False
|
||||
@ -14,3 +15,16 @@ class Destinations(PositionMixin, EnvObjects):
|
||||
|
||||
def __repr__(self):
|
||||
return super(Destinations, self).__repr__()
|
||||
|
||||
@staticmethod
|
||||
def trigger_destination_spawn(n_dests, state):
|
||||
coordinates = state.entities.floorlist[:n_dests]
|
||||
if destinations := [Destination(pos) for pos in coordinates]:
|
||||
state[d.DESTINATION].add_items(destinations)
|
||||
state.print(f'{n_dests} new destinations have been spawned')
|
||||
return c.VALID
|
||||
else:
|
||||
state.print('No Destiantions are spawning, limit is reached.')
|
||||
return c.NOT_VALID
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user