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()
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()
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()
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)
def get_power(self): self.add_unit(T.Marine(), 5) self.add_building(T.Commandcenter(), 1) self.add_building(T.Supplydepot(), 5) self.add_building(T.Barracks(), 2)