mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-12-12 10:30:37 +01:00
Occupation Map
This commit is contained in:
@@ -19,6 +19,8 @@ if __name__ == '__main__':
|
||||
model_name = 'A2C_ItsDirt'
|
||||
run_id = 0
|
||||
determin = True
|
||||
render=False
|
||||
record = True
|
||||
seed = 67
|
||||
n_agents = 1
|
||||
out_path = Path('study_out/e_1_Now_with_doors/no_obs/dirt/A2C_Now_with_doors/0_A2C_Now_with_doors')
|
||||
@@ -31,19 +33,21 @@ if __name__ == '__main__':
|
||||
env_kwargs['dirt_prop']['max_spawn_amount'] = gain_amount
|
||||
del env_kwargs['dirt_prop']['gain_amount']
|
||||
|
||||
env_kwargs.update(record_episodes=False)
|
||||
env_kwargs.update(record_episodes=record)
|
||||
|
||||
this_model = out_path / 'model.zip'
|
||||
|
||||
model_cls = next(val for key, val in h.MODEL_MAP.items() if key in model_name)
|
||||
models = [model_cls.load(this_model) for _ in range(n_agents)]
|
||||
|
||||
with RecorderCallback(filepath=Path() / 'recorder_out_DQN.json') as recorder:
|
||||
with RecorderCallback(filepath=Path() / 'recorder_out_DQN.json', occupation_map=True,
|
||||
entities=['Agents']) as recorder:
|
||||
# Init 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):
|
||||
recorder.read_params(env.params)
|
||||
for episode in range(200):
|
||||
env_state = env.reset()
|
||||
rew, done_bool = 0, False
|
||||
while not done_bool:
|
||||
@@ -53,14 +57,16 @@ if __name__ == '__main__':
|
||||
deterministic=determin)[0] for j, model in enumerate(models)]
|
||||
else:
|
||||
actions = models[0].predict(env_state, deterministic=determin)[0]
|
||||
if any([agent.pos in [door.pos for door in env.unwrapped[c.DOORS]]
|
||||
for agent in env.unwrapped[c.AGENT]]):
|
||||
print('On Door')
|
||||
if False:
|
||||
if any([agent.pos in [door.pos for door in env.unwrapped[c.DOORS]]
|
||||
for agent in env.unwrapped[c.AGENT]]):
|
||||
print('On Door')
|
||||
env_state, step_r, done_bool, info_obj = env.step(actions)
|
||||
|
||||
recorder.read_info(0, info_obj)
|
||||
rew += step_r
|
||||
env.render()
|
||||
if render:
|
||||
env.render()
|
||||
if done_bool:
|
||||
recorder.read_done(0, done_bool)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user