Fixed agent observation and inventory init

This commit is contained in:
Steffen Illium 2023-11-20 14:59:37 +01:00
parent 467cc3f793
commit 604c0c6f57
8 changed files with 89 additions and 7 deletions

1
.gitignore vendored
View File

@ -143,7 +143,6 @@ acs-*.bib
# knitr
*-concordance.tex
# TODO Comment the next line if you want to keep your tikz graphics files
*.tikz
*-tikzDictionary

View File

@ -0,0 +1,73 @@
Agents:
Wolfgang:
Actions:
- Move8
- DoorUse
- Clean
- Noop
Observations:
- Walls
- Doors
- Other
- DirtPiles
Juergen:
Actions:
- Move8
- DoorUse
- ItemAction
- Noop
Observations:
- Walls
- Doors
- Other
- Items
- DropOffLocations
- Inventory
Entities:
DirtPiles:
coords_or_quantity: 10
initial_amount: 2
clean_amount: 1
dirt_spawn_r_var: 0.1
max_global_amount: 20
max_local_amount: 5
Doors:
DropOffLocations:
coords_or_quantity: 1
max_dropoff_storage_size: 0
Inventories: {}
Items:
coords_or_quantity: 5
General:
env_seed: 69
individual_rewards: true
level_name: rooms
pomdp_r: 3
verbose: True
tests: false
Rules:
# Environment Dynamics
EntitiesSmearDirtOnMove:
smear_ratio: 0.2
DoorAutoClose:
close_frequency: 7
# Respawn Stuff
RespawnDirt:
respawn_freq: 30
RespawnItems:
respawn_freq: 50
# Utilities
WatchCollisions:
done_at_collisions: false
# Done Conditions
DoneOnAllDirtCleaned:
DoneAtMaxStepsReached:
max_steps: 500

View File

@ -3,7 +3,7 @@ Agents:
Actions:
- Noop
- Charge
- CleanUp
- Clean
- DestAction
- DoorUse
- ItemAction

View File

@ -5,6 +5,12 @@ from marl_factory_grid.environment.groups.collection import Collection
class Agents(Collection):
_entity = Agent
@property
def obs_pairs(self):
pair_list = [(self.name, self)]
pair_list.extend([(a.name, a) for a in self])
return pair_list
@property
def spawn_rule(self):
return {}

View File

@ -1,4 +1,4 @@
from .actions import CleanUp
from .actions import Clean
from .entitites import DirtPile
from .groups import DirtPiles
from .rules import EntitiesSmearDirtOnMove, DoneOnAllDirtCleaned

View File

@ -8,7 +8,7 @@ from marl_factory_grid.modules.clean_up import constants as d, rewards as r
from marl_factory_grid.environment import constants as c
class CleanUp(Action):
class Clean(Action):
def __init__(self):
super().__init__(d.CLEAN_UP, r.CLEAN_UP_VALID, r.CLEAN_UP_FAIL)

View File

@ -51,6 +51,10 @@ class Inventory(IsBoundMixin, Collection):
def obs_tag(self):
return self.name
@property
def name(self):
return f'{self.__class__.__name__}[{self._bound_entity.name}]'
def __init__(self, agent: Agent, *args, **kwargs):
super(Inventory, self).__init__(*args, **kwargs)
self._collection = None

View File

@ -29,7 +29,7 @@ if __name__ == '__main__':
ce.save_all(run_path / 'all_out.yaml')
# Path to config File
path = Path('marl_factory_grid/configs/default_config.yaml')
path = Path('marl_factory_grid/configs/clean_and_bring.yaml')
# Env Init
factory = Factory(path)