コード例 #1
0
        from comps.eng_norm.run import run_sol
    elif FLAGS.comp == "russian_norm":
        from comps.russian_norm.run import run_sol
    elif FLAGS.comp == "caesars":
        from comps.caesars.run import run_sol
    elif FLAGS.comp == "personal":
        from comps.personal.run import run_sol
    else:
        print("Unknown competion %s" % FLAGS.comp)
        assert False
    print("run competition %s solution %s" % (FLAGS.comp, FLAGS.sol))
    run_sol(FLAGS)


if __name__ == "__main__":
    try:
        import tensorflow as tf
        use_flags = "tf"
    except:
        use_flags = "arg"

    if use_flags == "tf":
        from tf_flags import FLAGS
        tf.app.run()
    else:
        from flags import get_parser
        parser = get_parser()
        args = parser.parse_args()
        FLAGS = args
        main(None)
コード例 #2
0
        min_unit = None

        enemy_id = 0
        for i in range(5, len(obs), 5):
            x = obs[i]
            y = obs[i + 1]

            if min_value > x * x + y * y:
                min_value = x * x + y * y
                min_unit = enemy_id
            enemy_id += 1

        return self.move_actions + min_unit

if __name__ == '__main__':
    args = get_parser().parse_args()
    args.unlimited_attack_range = True
    args.unlimited_vision = True

    env = StarCraftMvN(args, final_init=True)

    agent = AttackClosestAgent(env.action_space)
    agent.set_move_steps(len(env.move_steps))
    episodes = 0
    success = 0

    while episodes < 500:
        obs = env.reset()
        done = False
        total_reward = 0
        while not done: