mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-06-22 03:31:35 +02:00
eight puzzle now available, clones now available
This commit is contained in:
@ -6,7 +6,7 @@ import numpy as np
|
||||
from marl_factory_grid.algorithms.static.utils import points_to_graph
|
||||
from marl_factory_grid.environment import constants as c
|
||||
from marl_factory_grid.environment.entity.entity import Entity
|
||||
from marl_factory_grid.environment.rules import Rule
|
||||
from marl_factory_grid.environment.rules import Rule, SpawnAgents
|
||||
from marl_factory_grid.utils.results import Result, DoneResult
|
||||
|
||||
|
||||
@ -28,18 +28,19 @@ class StepRules:
|
||||
self.rules.append(item)
|
||||
return True
|
||||
|
||||
def do_all_reset(self, state):
|
||||
for rule in self.rules:
|
||||
if rule_reset_printline := rule.on_reset(state):
|
||||
state.print(rule_reset_printline)
|
||||
return c.VALID
|
||||
|
||||
def do_all_init(self, state, lvl_map):
|
||||
for rule in self.rules:
|
||||
if rule_init_printline := rule.on_init(state, lvl_map):
|
||||
state.print(rule_init_printline)
|
||||
return c.VALID
|
||||
|
||||
def do_all_reset(self, state):
|
||||
SpawnAgents().on_reset(state)
|
||||
for rule in self.rules:
|
||||
if rule_reset_printline := rule.on_reset(state):
|
||||
state.print(rule_reset_printline)
|
||||
return c.VALID
|
||||
|
||||
def tick_step_all(self, state):
|
||||
results = list()
|
||||
for rule in self.rules:
|
||||
@ -193,7 +194,7 @@ class Gamestate(object):
|
||||
results.extend(on_check_done_result)
|
||||
return results
|
||||
|
||||
def get_all_pos_with_collisions(self) -> List[Tuple[(int, int)]]:
|
||||
def get_collision_positions(self) -> List[Tuple[(int, int)]]:
|
||||
"""
|
||||
Returns a list positions [(x, y), ... ] on which collisions occur. This does not include agents,
|
||||
that were unable to move because their target direction was blocked, also a form of collision.
|
||||
|
Reference in New Issue
Block a user