mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-12-12 10:30:37 +01:00
experiment 1 running
This commit is contained in:
@@ -2,9 +2,9 @@ import warnings
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
from natsort import natsorted
|
||||
from environments import helpers as h
|
||||
|
||||
from environments import helpers as h
|
||||
from environments.factory.factory_dirt import DirtFactory
|
||||
from environments.factory.factory_dirt_item import DirtItemFactory
|
||||
from environments.logging.recorder import RecorderCallback
|
||||
|
||||
@@ -17,21 +17,23 @@ if __name__ == '__main__':
|
||||
model_name = 'PPO_1631187073'
|
||||
run_id = 0
|
||||
seed = 69
|
||||
out_path = Path(__file__).parent / 'study_out' / 'e_1_1631709932'/ 'no_obs' / 'itemdirt'/'A2C_1631709932' / '0_A2C_1631709932'
|
||||
out_path = Path(__file__).parent / 'study_out' / 'e_1_1631709932' / 'no_obs' / 'dirt' / 'A2C_1631709932' / '0_A2C_1631709932'
|
||||
model_path = out_path / model_name
|
||||
|
||||
with (out_path / f'env_params.json').open('r') as f:
|
||||
env_kwargs = yaml.load(f, Loader=yaml.FullLoader)
|
||||
env_kwargs.update(verbose=False, env_seed=seed, record_episodes=True)
|
||||
env_kwargs.update(additional_agent_placeholder=None)
|
||||
# env_kwargs.update(verbose=False, env_seed=seed, record_episodes=True, parse_doors=True)
|
||||
|
||||
this_model = out_path / 'model.zip'
|
||||
|
||||
model_cls = next(val for key, val in h.MODEL_MAP.items() if key in model_name)
|
||||
model = model_cls.load(this_model)
|
||||
|
||||
with RecorderCallback(filepath=Path() / 'recorder_out.json') as recorder:
|
||||
with RecorderCallback(filepath=Path() / 'recorder_out_doors.json') as recorder:
|
||||
# Init Env
|
||||
with DirtItemFactory(**env_kwargs) as env:
|
||||
with DirtFactory(**env_kwargs) as env:
|
||||
obs_shape = env.observation_space.shape
|
||||
# Evaluation Loop for i in range(n Episodes)
|
||||
for episode in range(5):
|
||||
obs = env.reset()
|
||||
@@ -41,6 +43,7 @@ if __name__ == '__main__':
|
||||
env_state, step_r, done_bool, info_obj = env.step(action[0])
|
||||
recorder.read_info(0, info_obj)
|
||||
rew += step_r
|
||||
env.render()
|
||||
if done_bool:
|
||||
recorder.read_done(0, done_bool)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user