def main(): '''Simple function to bootstrap a game. Use this as an example to set up your training env. ''' # Print all possible environments in the Pommerman registry print(pommerman.REGISTRY) # Create a set of agents (exactly four) agent_list = [ agents.DockerAgent("b3c934102b5b", port=12345), agents.FrankfurtAgent(), agents.DockerAgent("b3c934102b5b", port=12346), agents.FrankfurtAgent(), # agents.DockerAgent("pommerman/simple-agent", port=12345), ] # Make the "Free-For-All" environment using the agent list env = pommerman.make('PommeTeamCompetition-v0', agent_list) # Run the episodes just like OpenAI Gym for i_episode in range(1): state = env.reset(9999) done = False while not done: env.render() #record_json_dir='/tmp/' actions = env.act(state) state, reward, done, info = env.step(actions) #time.sleep(0.1) print(info) print('Episode {} finished'.format(i_episode)) env.close()
def main(): """Simple function to bootstrap a game""" # Print all possible environments in the Pommerman registry print(pommerman.REGISTRY) # Create a set of agents (exactly four) agent_list = [ agents.SimpleAgent(), agents.DockerAgent("ccc", port=12345), agents.SimpleAgent(), agents.DockerAgent("ccc", port=12345), ] # Make the "Free-For-All" environment using the agent list env = pommerman.make('PommeTeamCompetition-v0', agent_list) #env = pommerman.make(''PommeTeamCompetition-v1'', agent_list) # Run the episodes just like OpenAI Gym for i_episode in range(1): state = env.reset() done = False while not done: env.render() actions = env.act(state) state, reward, done, info = env.step(actions) print('Episode {} finished'.format(i_episode)) env.close()
def main(): '''Simple function to bootstrap a game. Use this as an example to set up your training env. ''' # Print all possible environments in the Pommerman registry print(pommerman.REGISTRY) # Create a set of agents (exactly four) agent_list = [ agents.SimpleAgent(), agents.SimpleAgent(), #agents.SimpleAgent(), #agents.SimpleAgent(), agents.DockerAgent("pommerman/rl_agent", port=12367), agents.DockerAgent("pommerman/rl_agent", port=12397), ] # Make the "Free-For-All" environment using the agent list env = pommerman.make('PommeRadio-v2', agent_list) # Run the episodes just like OpenAI Gym for i_episode in range(1): state = env.reset() done = False while not done: env.render() actions = env.act(state) state, reward, done, info = env.step(actions) print('Episode {} finished'.format(i_episode)) env.close()
def main(): '''Simple function to bootstrap a game. Use this as an example to set up your training env. ''' # Print all possible environments in the Pommerman registry print(pommerman.REGISTRY) # Create a set of agents (exactly four) agent_list = [ agents.SimpleAgent(), agents.RandomAgent(), agents.RandomAgent(), #agents.DockerAgent("multiagentlearning/hakozakijunctions", port=12345), #agents.DockerAgent("multiagentlearning/eisenach", port=12345), agents.DockerAgent("multiagentlearning/skynet955", port=12345), ] # Make the "Free-For-All" environment using the agent list env = pommerman.make('PommeTeamCompetition-v1', agent_list) # Run the episodes just like OpenAI Gym for i_episode in range(1): state = env.reset() done = False while not done: env.render() actions = env.act(state) state, reward, done, info = env.step(actions) print('Episode {} finished'.format(i_episode)) print("Final Result: ", info) env.close()
def main(): # Print all possible environments in the Pommerman registry print(pommerman.registry) # Create a set of agents (exactly four) agent_list = [ agents.SimpleAgent(), agents.SimpleAgent(), agents.SimpleAgent(), # agents.RandomAgent(), agents.DockerAgent("pommerman/agent47agent", port=10080), ] # Make the "Free-For-All" environment using the agent list env = pommerman.make('PommeFFACompetition-v0', agent_list) # Run the episodes just like OpenAI Gym for i_episode in range(1): state = env.reset() done = False while not done: env.render() actions = env.act(state) state, reward, done, info = env.step(actions) print('Episode {} finished'.format(i_episode)) env.close()
def main(agent_names, competition="comp1", render=False, interactive=False, record_json_dir=None): # List of four agents agent_list = [ agents.DockerAgent(competition + "/" + agent_names[i], port=12345 + i) for i in range(4) ] # Environment config = 'PommeFFACompetition-v0' env = pommerman.make(config, agent_list) # Run state = env.reset() done = False step = 0 if record_json_dir is not None: suffix = '%d.json' % step info = env.get_json_info() with open(os.path.join(record_json_dir, suffix), 'w') as f: f.write(json.dumps(info, sort_keys=True, indent=4)) while not done: step += 1 if render: env.render() actions = env.act(state) state, reward, done, info = env.step(actions) if record_json_dir is not None: suffix = '%d.json' % step info = env.get_json_info() with open(os.path.join(record_json_dir, suffix), 'w') as f: f.write(json.dumps(info, sort_keys=True, indent=4)) if interactive: sys.stdin.readline() env.close() return reward
def main(): '''Simple function to bootstrap a game. Use this as an example to set up your training env. ''' # Print all possible environments in the Pommerman registry print(pommerman.REGISTRY) ############## sess = tf.InteractiveSession() params = joblib.load('parametersepoch8') # Create a set of agents (exactly four) agent_list = [ agents.SimpleAgent(), # agents.DockerAgent("pommerman/brain-agent", port=12345), agents.SimpleAgent(), agents.SimpleAgent(), agents.DockerAgent("pommerman/simple-agent", port=10080), # convNetwork(sess,params) # agents.PlayerAgent(), #TODO 建立一个镜像 ] # Make the "Free-For-All" environment using the agent list env = pommerman.make('PommeTeamCompetition-v0', agent_list) # Run the episodes just like OpenAI Gym for i_episode in range(1): state = env.reset() done = False while not done: actions = env.act(state) state, reward, done, info = env.step(actions) print(done) print('Episode {} finished'.format(i_episode)) print(reward) env.close()
def main(): '''Simple function to bootstrap a game. Use this as an example to set up your training env. ''' # Print all possible environments in the Pommerman registry print(pommerman.REGISTRY) # Create a set of agents (exactly four) agent_list = [ agents.DockerAgent("70ab248bd109", port=12345), #Eisenach agents.DockerAgent("0d29bcb35603", port=12347), #Frankfurt agents.DockerAgent("70ab248bd109", port=12346), agents.DockerAgent("0d29bcb35603", port=12348), # agents.DockerAgent("pommerman/simple-agent", port=12345), ] # Make the "Free-For-All" environment using the agent list env = pommerman.make('PommeRadio-v2', agent_list) wins = 0 ties = 0 survived_agents = [] nof_plays = 1 # Run the episodes just like OpenAI Gym for i_episode in range(nof_plays): print("Game " + str(i_episode)) state = env.reset(i_episode) done = False while not done: #env.render() actions = env.act(state) state, reward, done, info = env.step(actions) print(info) if info['result'] == pommerman.constants.Result.Tie: ties += 1 elif info['winners'] == [1, 3]: wins += 1 else: print(info['result']) print(info['winners']) print("Lost with seed: " + str(i_episode)) print('Episode {} finished'.format(i_episode)) survived_agents.extend(state[0]['alive']) env.close() survived_team_0 = survived_agents.count(10) + survived_agents.count(12) survived_team_1 = survived_agents.count(11) + survived_agents.count(13) kills = nof_plays * 2 - survived_team_0 death = nof_plays * 2 - survived_team_1 print("kills / death / ratio: ", kills, " / ", death, " / ", kills / max(0.1, death)) winRatio = str(wins / max(1, (nof_plays - ties))) print("wins: " + str(wins) + "/" + str(nof_plays - ties) + " = " + winRatio) file = open("/tmp/hypertune_result_winrate.txt", "w") file.write(winRatio) file.close() file = open("/tmp/hypertune_result_killdeath_diff.txt", "w") file.write(str(kills - death)) file.close()