fixed names and function, dirtspawn and item spawn

This commit is contained in:
Steffen Illium
2023-10-30 11:11:35 +01:00
parent ac557232a1
commit 374a38971a
16 changed files with 56 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
from .actions import BtryCharge
from .entitites import Pod, Battery
from .groups import ChargePods, Batteries
from .rules import BtryDoneAtDischarge, BatteryDecharge
from .rules import DoneAtBatteryDischarge, BatteryDecharge

View File

@@ -94,7 +94,7 @@ class BatteryDecharge(Rule):
return results
class BtryDoneAtDischarge(BatteryDecharge):
class DoneAtBatteryDischarge(BatteryDecharge):
def __init__(self, reward_discharge_done=b.REWARD_DISCHARGE_DONE, mode: str = b.SINGLE, **kwargs):
f"""

View File

@@ -30,6 +30,7 @@ class DirtPiles(PositionMixin, EnvObjects):
if not self.amount > self.max_global_amount:
amount = amount_s[idx] if isinstance(amount_s, list) else amount_s
if dirt := self.by_pos(pos):
dirt = next(dirt.iter())
new_value = dirt.amount + amount
dirt.set_new_amount(new_value)
else:
@@ -42,8 +43,8 @@ class DirtPiles(PositionMixin, EnvObjects):
return Result(identifier=f'{self.name}_spawn', validity=c.VALID, reward=0, value=spawn_counter)
def trigger_dirt_spawn(self, n, amount, state, n_var=0.2, amount_var=0.2) -> Result:
free_for_dirt = [x for x in state.entities.floorlist if len(state.entities.pos_dict[x]) == 1 or (
len(state.entities.pos_dict[x]) == 2 and isinstance(next(y for y in x), DirtPile))]
free_for_dirt = [x for x in state.entities.floorlist if len(state.entities.pos_dict[x]) == 0 or (
len(state.entities.pos_dict[x]) >= 1 and isinstance(next(y for y in x), DirtPile))]
# free_for_dirt = [x for x in state[c.FLOOR]
# if len(x.guests) == 0 or (
# len(x.guests) == 1 and

View File

@@ -27,7 +27,8 @@ class DoneOnAllDirtCleaned(Rule):
class SpawnDirt(Rule):
def __init__(self, initial_n: int, initial_amount: float, respawn_n: int, respawn_amount: float,
def __init__(self, initial_n: int = 5, initial_amount: float = 1.3,
respawn_n: int = 3, respawn_amount: float = 0.8,
n_var: float = 0.2, amount_var: float = 0.2, spawn_freq: int = 15):
"""
Defines the spawn pattern of intial and additional 'Dirt'-entitites.

View File

@@ -13,7 +13,7 @@ from marl_factory_grid.modules.destinations.entitites import Destination
class DestinationReachReward(Rule):
def __init__(self, dest_reach_reward=marl_factory_grid.modules.destinations.constants.REWARD_DEST_REACHED):
def __init__(self, dest_reach_reward=d.REWARD_DEST_REACHED):
"""
This rule introduces the basic functionality, so that targts (Destinations) can be reached and marked as such.
Additionally, rewards are reported.
@@ -50,7 +50,7 @@ class DestinationReachReward(Rule):
class DoneAtDestinationReachAll(DestinationReachReward):
def __init__(self, reward_at_done=marl_factory_grid.modules.destinations.constants.REWARD_DEST_DONE, **kwargs):
def __init__(self, reward_at_done=d.REWARD_DEST_DONE, **kwargs):
"""
This rule triggers and sets the done flag if ALL Destinations have been reached.

View File

@@ -1,4 +1,4 @@
from .actions import DoorUse
from .entitites import Door, DoorIndicator
from .groups import Doors
from .rules import DoDoorAutoClose, IndicateDoorAreaInObservation
from .rules import DoorAutoClose, IndicateDoorAreaInObservation

View File

@@ -5,7 +5,7 @@ from . import constants as d
from .entitites import DoorIndicator
class DoDoorAutoClose(Rule):
class DoorAutoClose(Rule):
def __init__(self, close_frequency: int = 10):
"""

View File

@@ -104,7 +104,7 @@ class DropOffLocations(PositionMixin, EnvObjects):
@staticmethod
def trigger_drop_off_location_spawn(state, n_locations):
empty_positions = state.entities.empty_positions()[:n_locations]
empty_positions = state.entities.empty_positions[:n_locations]
do_entites = state[i.DROP_OFF]
drop_offs = [DropOffLocation(pos) for pos in empty_positions]
do_entites.add_items(drop_offs)