mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-12-14 03:00:37 +01:00
State of repo for ISOLA paper
This commit is contained in:
34
env_examples/run_default.py
Normal file
34
env_examples/run_default.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from pathlib import Path
|
||||
from tqdm import trange
|
||||
from marl_factory_grid.algorithms.static.TSP_coin_agent import TSPCoinAgent
|
||||
from marl_factory_grid.algorithms.static.TSP_dirt_agent import TSPDirtAgent
|
||||
from marl_factory_grid.environment.factory import Factory
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
run_path = Path('../study_out')
|
||||
render = True
|
||||
monitor = True
|
||||
record = True
|
||||
|
||||
# Path to config File
|
||||
path = Path('../marl_factory_grid/configs/default_config.yaml')
|
||||
|
||||
# Env Init
|
||||
factory = Factory(path)
|
||||
|
||||
for episode in trange(10):
|
||||
_ = factory.reset()
|
||||
done = False
|
||||
if render:
|
||||
factory.render()
|
||||
action_spaces = factory.action_space
|
||||
agents = [TSPDirtAgent(factory, 0), TSPCoinAgent(factory, 1)]
|
||||
while not done:
|
||||
a = [x.predict() for x in agents]
|
||||
obs_type, _, _, done, info = factory.step(a)
|
||||
if render:
|
||||
factory.render()
|
||||
if done:
|
||||
print(f'Episode {episode} done...')
|
||||
break
|
||||
33
env_examples/run_test.py
Normal file
33
env_examples/run_test.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from pathlib import Path
|
||||
from tqdm import trange
|
||||
from marl_factory_grid.algorithms.static.TSP_item_agent import TSPItemAgent
|
||||
from marl_factory_grid.environment.factory import Factory
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
run_path = Path('../study_out')
|
||||
render = True
|
||||
monitor = True
|
||||
record = True
|
||||
|
||||
# Path to config File
|
||||
path = Path('../marl_factory_grid/configs/test_config.yaml')
|
||||
|
||||
# Env Init
|
||||
factory = Factory(path)
|
||||
|
||||
for episode in trange(10):
|
||||
_ = factory.reset()
|
||||
done = False
|
||||
if render:
|
||||
factory.render()
|
||||
action_spaces = factory.action_space
|
||||
agents = [TSPItemAgent(factory, 0)]
|
||||
while not done:
|
||||
a = [x.predict() for x in agents]
|
||||
obs_type, _, _, done, info = factory.step(a)
|
||||
if render:
|
||||
factory.render()
|
||||
if done:
|
||||
print(f'Episode {episode} done...')
|
||||
break
|
||||
Reference in New Issue
Block a user