initial n steps

This commit is contained in:
Steffen Illium
2023-11-23 17:32:32 +01:00
parent 2f29ef703c
commit 0ec260f6a2
8 changed files with 92 additions and 24 deletions

View File

@ -105,10 +105,10 @@ class SpawnDestinationsPerAgent(Rule):
!!! This rule does not introduce any reward or done condition.
:param coords_or_quantity: Please provide a dictionary with agent names as keys; and a list of possible
destination coords as value. Example: {Wolfgang: [(0, 0), (1, 1), ...]}
:param coords_or_quantity: Please provide a dictionary with agent names as keys; and a list of possible
destination coords as value. Example: {Wolfgang: [(0, 0), (1, 1), ...]}
"""
super(Rule, self).__init__()
super().__init__()
self.per_agent_positions = dict()
for agent_name, value in coords_or_quantity.items():
if isinstance(value, int):
@ -143,3 +143,25 @@ class SpawnDestinationsPerAgent(Rule):
continue
state[d.DESTINATION].add_item(destination)
pass
class SpawnDestinationOnAgent(Rule):
def __init__(self):
"""
Special rule which spawns a single destination bound to a single agent just `below` him. Usefull for
the `N-Puzzle` configurations.
!!! This rule does not introduce any reward or done condition.
:param coords_or_quantity: Please provide a dictionary with agent names as keys; and a list of possible
destination coords as value. Example: {Wolfgang: [(0, 0), (1, 1), ...]}
"""
super().__init__()
def on_reset(self, state: Gamestate):
state.print("Spawn Desitnations")
for agent in state[c.AGENT]:
destination = Destination(agent.pos, bind_to=agent)
state[d.DESTINATION].add_item(destination)
assert len(state[d.DESTINATION].by_pos(agent.pos)) == 1
pass