示例#1
0
def battle_test():
    red_agent = Protoss()
    blue_agent = Terran()
    red_agent.add_unit(P.Zealot(), 12)
    blue_agent.add_unit(T.Marine(), 1)
    blue_agent.add_building(T.Commandcenter(), 1)
    blue_agent.add_building(T.Supplydepot(), 5)
    blue_agent.add_building(T.Barracks(), 2)
    bf = BattleField(red_agent=red_agent, blue_agent=blue_agent)
    for i in range(10):
        bf.battle()
示例#2
0
def net_test():
    config = tf.ConfigProto(
        allow_soft_placement=True,
        log_device_placement=False,
    )
    config.gpu_options.allow_growth = True
    sess = tf.Session(config=config)
    now = datetime.now()
    model_path = "./model/" + now.strftime("%Y%m%d-%H%M%S") + "_mini/"
    mini_net = MiniNetwork(sess,
                           ppo_load_path=model_path,
                           ppo_save_path=model_path)
    mini_net.initialize()

    red_agent = Protoss()
    red_agent.set_net(mini_net)

    blue_agent = Dummy()
    blue_agent.add_unit(T.Marine(), 5)
    blue_agent.add_building(T.Commandcenter(), 1)
    blue_agent.add_building(T.Supplydepot(), 3)
    blue_agent.add_building(T.Barracks(), 1)

    env = SimulatePlatform(red_agent=red_agent,
                           blue_agent=blue_agent,
                           distance=5,
                           max_steps=100)
    env.init()
    # env.simulate()
    red_agent.play_with_rl()
示例#3
0
def test():
    red_agent = Protoss()

    blue_agent = Dummy()
    blue_agent.add_unit(T.Marine(), 0)
    blue_agent.add_building(T.Commandcenter(), 1)
    blue_agent.add_building(T.Supplydepot(), 3)
    blue_agent.add_building(T.Barracks(), 1)

    env = SimulatePlatform(red_agent=red_agent,
                           blue_agent=blue_agent,
                           distance=5,
                           max_steps=100)
    env.init()
    env.simulate()
示例#4
0
def Init_brain_strategy_model(mini_net=None):
    strategy_agent = None
    if FLAGS.agent_race == 'P':
        strategy_agent = Protoss(net=mini_net, restore_model=True)
    elif FLAGS.agent_race == 'T':
        strategy_agent = Terran(net=mini_net, restore_model=True)
    elif FLAGS.agent_race == 'Z':
        strategy_agent = Zerg(net=mini_net, restore_model=True)

    blue_agent = None
    blue_agent = Dummy()
    if FLAGS.bot_race == 'T':
        blue_agent.get_power()

    mini_env = SimulatePlatform(red_agent=strategy_agent,
                                blue_agent=blue_agent,
                                distance=5,
                                max_steps=100)
    mini_env.init()
    strategy_agent.set_env(mini_env)
    strategy_agent.init_network()
    return strategy_agent
示例#5
0
def net_test():
    red_agent = Protoss()
    max_actions = ProtossAction.All.value
    red_agent.set_mpc(MPC(max_actions))
    blue_agent = Dummy()
    blue_agent.add_unit(T.Marine(), 5)
    blue_agent.add_building(T.Commandcenter(), 1)
    blue_agent.add_building(T.Supplydepot(), 3)
    blue_agent.add_building(T.Barracks(), 1)

    env = SimulatePlatform(red_agent=red_agent,
                           blue_agent=blue_agent,
                           distance=5,
                           max_steps=100)
    env.init()
    # env.simulate()
    red_agent.play_with_mpc(verbose=False)