Skip to content
Snippets Groups Projects
Commit b6c6e170 authored by Siddhartha Laghuvarapu's avatar Siddhartha Laghuvarapu
Browse files

Add tqdm bar to rollout.py

parent c766f1b8
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,8 @@ from config import LocalEvaluationConfig ...@@ -13,6 +13,8 @@ from config import LocalEvaluationConfig
import random import random
import copy import copy
from tqdm import tqdm
class ProxyEnv(Env): class ProxyEnv(Env):
def step(self, actions, preprocess=set(), omitDead=True): def step(self, actions, preprocess=set(), omitDead=True):
...@@ -75,6 +77,7 @@ def assign_agents(player_agent, opponent_agents): ...@@ -75,6 +77,7 @@ def assign_agents(player_agent, opponent_agents):
def run_episode(player_index, agents, N_TIME_STEPS): def run_episode(player_index, agents, N_TIME_STEPS):
config = projekt.config.CompetitionRound1() config = projekt.config.CompetitionRound1()
config.RENDER = True
env = ProxyEnv(config) env = ProxyEnv(config)
n_steps = 0 n_steps = 0
neural_agents = set() neural_agents = set()
...@@ -92,9 +95,9 @@ def run_episode(player_index, agents, N_TIME_STEPS): ...@@ -92,9 +95,9 @@ def run_episode(player_index, agents, N_TIME_STEPS):
for entid in entids: for entid in entids:
actions[entid] = agents[entid_agent_map[entid]].register_reset(obs[entid]) actions[entid] = agents[entid_agent_map[entid]].register_reset(obs[entid])
alive_agents = list(obs.keys()) alive_agents = list(obs.keys())
pbar = tqdm(total = N_TIME_STEPS)
while len(obs.keys()) > 0 and n_steps < N_TIME_STEPS: while len(obs.keys()) > 0 and n_steps < N_TIME_STEPS:
pbar.update(n=1)
for entid in actions: for entid in actions:
if entid not in neural_agents: if entid not in neural_agents:
realm = env.realm realm = env.realm
...@@ -157,7 +160,7 @@ if __name__ == "__main__": ...@@ -157,7 +160,7 @@ if __name__ == "__main__":
player_agent, opponent_agents = load_agents(LocalEvaluationConfig) player_agent, opponent_agents = load_agents(LocalEvaluationConfig)
player_agent = player_agent[0] player_agent = player_agent[0]
N_EPISODES = 2 N_EPISODES = 2
N_TIME_STEPS = 10 N_TIME_STEPS = 1024
for episode in range(N_EPISODES): for episode in range(N_EPISODES):
agents, player_index = assign_agents(player_agent, opponent_agents) agents, player_index = assign_agents(player_agent, opponent_agents)
statistics = run_episode(player_index, agents, N_TIME_STEPS) statistics = run_episode(player_index, agents, N_TIME_STEPS)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment