Beispiel #1
0
  def test_move_to_beacon(self):
    with sc2_env.SC2Env(
        "MoveToBeacon",
        step_mul=self.step_mul,
        game_steps_per_episode=self.steps * self.step_mul) as env:
      agent = scripted_agent.MoveToBeacon()
      run_loop.run_loop([agent], env, self.steps)

    # Get some points
    self.assertLessEqual(agent.episodes, agent.reward)
    self.assertEqual(agent.steps, self.steps)
  def test_move_to_beacon(self):
    with sc2_env.SC2Env(
        map_name="MoveToBeacon",
        agent_interface_format=sc2_env.AgentInterfaceFormat(
            feature_dimensions=sc2_env.Dimensions(
                screen=84,
                minimap=64)),
        step_mul=self.step_mul,
        game_steps_per_episode=self.steps * self.step_mul) as env:
      agent = scripted_agent.MoveToBeacon()
      run_loop.run_loop([agent], env, self.steps)

    # Get some points
    self.assertLessEqual(agent.episodes, agent.reward)
    self.assertEqual(agent.steps, self.steps)
def evaluate_scripted_agent(n_episodes=100, max_steps=120):

    game_params = dict(
        feature_screen=16,  # screen resolution in pixel
        feature_minimap=
        16,  # minimap resolution in pixel (smaller or equal to screen)
        action_space="FEATURES"
    )  # either FEATURES or RGB - suggested: FEATURES

    performance = []
    env = init_game(game_params, max_steps)
    agent = scripted_agent.MoveToBeacon()
    for e in range(n_episodes):
        if (e + 1) % 10 == 0:
            print("Episode %d / %d" % (e + 1, n_episodes))
        rewards = play_episode(agent, env, max_steps)
        performance.append(np.sum(rewards))
    performance = np.array(performance)
    return performance.mean(), performance.std(), performance