async def Creep_Control(self): #Control the tumors that queens lay for creep in self.units(CREEPTUMORBURROWED).idle: abilities = await self.get_available_abilities( creep) #Check if expandable if AbilityId.BUILD_CREEPTUMOR_TUMOR in abilities: #expand randomly !!!!!!!!!!!!!!!!Change to be smart CreepPos = creep.position #if self.state.creep #await self.do(creep(BUILD_CREEPTUMOR_TUMOR, pos)) BestPosition = [] BestLength = 10000 MaxRange = 13 Positions = [] for PossibleCreepPositionX in range(MaxRange): for PossibleCreepPositionY in range(MaxRange): Positions.append( position.Point2( position.Pointlike( (PossibleCreepPositionX + CreepPos[0] - int(MaxRange / 2), PossibleCreepPositionY + CreepPos[1] - int(MaxRange / 2))))) random.shuffle(Positions) Length = 0 pos = self.enemy_start_locations[0].position for position1 in Positions: #for OtherCreep in self.units(CREEPTUMORBURROWED): Length = math.sqrt(((position1[0] - pos[0]) * (position1[0] - pos[0])) + ((position1[1] - pos[1]) * (position1[1] - pos[1]))) LengthActual = math.sqrt(((position1[0] - CreepPos[0]) * (position1[0] - CreepPos[0])) + ((position1[1] - CreepPos[1]) * (position1[1] - CreepPos[1]))) print(BestLength) if ((Length < BestLength and Length != 0) and position1 not in self.UnCreepable and abs(LengthActual <= MaxRange)): BestLength = Length print(BestLength) BestPosition = position1 if (BestPosition != []): err = await self.do( creep( BUILD_CREEPTUMOR_TUMOR, position.Point2( position.Pointlike( (BestPosition[0], BestPosition[1]))))) print(err) if (err == ActionResult.CantSeeBuildLocation): self.RequestVisibilty.append(BestPosition) elif (err): self.UnCreepable.append(BestPosition)
def random_location_variance(self, enemy_start_location): x = enemy_start_location[0] # print('\n x: \n', x) # 161.5 # print('\n type(x): \n', type(x)) # <class 'float'> y = enemy_start_location[1] # print('\n y: \n', y) # 21.5 # print('\n type(y): \n', type(y)) # <class 'float'> # FIXED THIS x += ((random.randrange(-20, 20)) / 100) * self.game_info.map_size[0] # print('\n x: \n', x) # 145.5 # print('\n type(x): \n', type(x)) # <class 'float'> y += ((random.randrange(-20, 20)) / 100) * self.game_info.map_size[1] # print('\n y: \n', y) # 47.9 # print('\n type(y): \n', type(y)) # <class 'float'> if x < 0: print("x below") x = 0 if y < 0: print("y below") y = 0 if x > self.game_info.map_size[0]: print("x above") x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: print("y above") y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x, y))) # print('\n go_to: \n', go_to) # (145.5, 47.9) # print('\n type(go_to): \n', type(go_to)) # <class 'sc2.position.Point2'> return go_to
async def buildPylon(self): #check to make sure probes exist. if len(self.game.units(PROBE)) == 0: return False #no probes! #first check to see if we have a pylon near the current defensive position. goto = self.game.buildingList.nextPylonLoc # if not goto and not self.check_pylon_loc(self.game.defensive_pos): # goto = self.game.defensive_pos if not goto: #check to see if we can get a free position from a nexus. goto = self.game.buildingList.nextFreePylonLoc if not goto: nexus = self.game.units(NEXUS).furthest_to(self.game.start_location) #find all the minerals near the nexus and place the pylons on the opposite side. if self.game.state.mineral_field.closer_than(15, nexus).exists: mf = self.game.state.mineral_field.closer_than(15, nexus).random xnew = nexus.position[0] + (nexus.position[0] - mf.position[0]) ynew = nexus.position[1] + (nexus.position[1] - mf.position[1]) goto = position.Point2(position.Pointlike((xnew,ynew))) else: return False #find placement and select worker. if goto: #worker = self.game.select_build_worker(goto.position, force=True) worker = await self.game.select_closest_worker(goto.position) if worker: placement = await self.game.find_placement(PYLON, goto) if placement: if _print_building: print ("Building Pylon") self.game.combinedActions.append(worker.build(PYLON, placement.position)) self.last_build = 2 return True return False
async def map_array(self, game): self.game = game map_size = self.game.game_info.map_size map_rams = self.game.game_info.map_ramps map = np.zeros((map_size[0], map_size[1], 3)) height = [] for i in range(0, map_size[0]): for j in range(0, map_size[1]): temp = self.game.get_terrain_height( position.Point2(position.Pointlike((i, j)))) map[i][j][0] = temp / 255.0 map[i][j][1] = temp / 255.0 map[i][j][2] = temp / 255.0 for cnt in range(0, len(map_rams)): ramps = list(map_rams[cnt]._points) for i, j in ramps: map[i][j][0] = 255 map[i][j][1] = 255 map[i][j][2] = 255 cv2.imshow("Map", map) cv2.waitKey(1)
async def attack(self): centers = self.units(COMMANDCENTER)[-1] army_units = { MARINE: [30, 10], ## group units (attack/def) MARAUDER: [15, 4], MEDIVAC: [3, 0] } for UNIT in army_units: ## Attack group if self.units(UNIT).amount > army_units[UNIT][0] and self.units( UNIT).amount > army_units[UNIT][1]: for s in self.units(UNIT).idle: await self.do(s.attack(self.find_target(self.state))) elif self.units(UNIT).amount > army_units[UNIT][ 1]: ## Defend & gather until enough to attack if len(self.known_enemy_units) > 0: for s in self.units(UNIT).idle: await self.do( s.attack(random.choice(self.known_enemy_units))) elif self.units(UNIT).amount < army_units[UNIT][0]: if len(self.known_enemy_units) < 0: for s in self.units(UNIT).idle: center = self.game_info.map_center move_unit = position.Point2(position.Pointlike(center)) await self.do(s.move(move_unit))
def random_location_variance(self, location): x = location[0] y = location[1] ############################### # FIXED THIS x += random.randrange(-5, 5) y += random.randrange(-5, 5) ############################### if x < 0: print("x below") x = 0 if y < 0: print("y below") y = 0 if x > self.game_info.map_size[0]: print("x above") x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: print("y above") y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x, y))) return go_to
def random_location_variance(self, enemy_start_location): x = enemy_start_location[0] * self.randDelta(.2) y = enemy_start_location[1] * self.randDelta(.2) x = self.bound(x, 0, self.game_info.map_size[0]) y = self.bound(y, 0, self.game_info.map_size[1]) go_to = position.Point2(position.Pointlike((x,y))) return go_to
def vary_loc(self, location): x = location[0] + random.randrange(-10, 10) y = location[1] + random.randrange(-10, 10) x = min(self.game_info.map_size[0], max(x, 0)) y = min(self.game_info.map_size[1], max(y, 0)) return position.Point2(position.Pointlike((x,y)))
def random_location_variance(self, enemy_start_location): x = enemy_start_location[0] y = enemy_start_location[1] x += ((random.randrange(-20, 20)) / 100) * enemy_start_location[0] y += ((random.randrange(-20, 20)) / 100) * enemy_start_location[1] x = min(max(0, x), self.game_info.map_size[0]) y = min(max(0, y), self.game_info.map_size[1]) return position.Point2(position.Pointlike((x, y)))
def random_location_variance(self, enemy_start_location): x = enemy_start_location[0] * self.randDelta( .2 ) #this doesnt make sense, variance should not change based on random start location y = enemy_start_location[1] * self.randDelta(.2) x = self.bound(x, 0, self.game_info.map_size[0]) y = self.bound(y, 0, self.game_info.map_size[1]) go_to = position.Point2(position.Pointlike((x, y))) return go_to
def random_location_variance(location, x_max, y_max) -> position.Point2: """ return a random position near enemy start location; used for scouting """ x = location[0] + random.randrange(-5, 5) y = location[1] + random.randrange(-5, 5) # make the out-of-map positions valid x = max([x, 0]) y = max([y, 0]) x = min([x, x_max]) y = min([y, y_max]) return position.Point2(position.Pointlike((x, y)))
def random_location_variance(self, enemy_start_location): x = enemy_start_location[0] y = enemy_start_location[1] x += ((random.randrange(-20, 20))/100) * enemy_start_location[0] y += ((random.randrange(-20, 20))/100) * enemy_start_location[1] if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x,y))) return go_to
def random_location_variance(self, enemy_start_location): # x = enemy_start_location[0] # y = enemy_start_location[1] # x *= ((random.randrange(-20, 20))/100) + 1 # y *= ((random.randrange(-20, 20))/100) + 1 # x = 0 if x < 0 else x # x = self.game_info.map_size[0] if x > self.game_info.map_size[0] else x # y = 0 if y < 0 else y # y = self.game_info.map_size[1] if y > self.game_info.map_size[1] else y x = num_float_in(enemy_start_location[0], 0.2, 0, self.game_info.map_size[0]) y = num_float_in(enemy_start_location[1], 0.2, 0, self.game_info.map_size[1]) go_to = position.Point2(position.Pointlike((x, y))) return go_to
async def location_variance(self, location): x = location[0] y = location[1] x += random.randrange(-15,15) y += random.randrange(-15,15) if x <0: x = 0 if y < 0: y =0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x,y))) # must be a special position 2d pointlike object return go_to
def buildfaraway(self, distance): x = distance[0] y = distance[1] # FIXED THIS x += random.randrange(-5, 5) y += random.randrange(-5, 5) if x < 0: print("x below") x = 0 if y < 0: print("y below") y = 0 go_to = position.Point2(position.Pointlike((x, y))) return go_to
def random_location_variance(self, location): x = location[0] y = location[1] x += random.randrange(-5, 5) y += random.randrange(-5, 5) if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x, y))) return go_to
def get_scout_location(self, base_loc): x = base_loc[0] y = base_loc[1] x += ((random.randrange(-20, 20)) / 100) * x y += ((random.randrange(-20, 20)) / 100) * y if x < 0: x = 0 elif x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y < 0: y = 0 elif y > self.game_info.map_size[1]: y = self.game_info.map_size[1] return position.Point2(position.Pointlike((x, y)))
def random_location_variance(self, enemy_start_location): # 这里用硬编码,移动到位置附近的5的范围内 x = enemy_start_location[0] y = enemy_start_location[1] x += random.randrange(-5, 5) y += random.randrange(-5, 5) if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x, y))) return go_to
def random_location_variance( self, OrigionalLocation, Offset ): #take in location and output location randomly offset from it x = OrigionalLocation[0] y = OrigionalLocation[1] x += ((random.randrange(-Offset, Offset))) y += ((random.randrange(-Offset, Offset))) if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x, y))) return go_to
def random_location_variance(self, location): x = location[0] y = location[1] x += random.randrange(-5, 5) y += random.randrange(-5, 5) if x < 0: x = 0 # Because we can't have negative coordinates or we get happy errors if x > self.game_info.map_size[0]: x = self.game_info.map_size[ 0] # Beacause we have to stay on the map or we get happy errors if y < 0: y = 0 if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x, y))) return go_to
def interpolate_location(self, base_location, current_location, t): x0 = base_location[0] y0 = base_location[1] x1 = current_location[0] y1 = current_location[1] x = x1 + (x0 - x1) * t y = y1 + (y0 - y1) * t if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] send_to = position.Point2(position.Pointlike((x, y))) return send_to
def random_location(self, enemy_start_location): # start locations is a list of points x = enemy_start_location[0] y = enemy_start_location[1] # generates random coordinates around the enemy start location x += ((random.randrange(-20, 20)) / 100) * enemy_start_location[0] y += ((random.randrange(-20, 20)) / 100) * enemy_start_location[1] # keeps coordinates in side map coordinates if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] new_location = position.Point2(position.Pointlike((x, y))) return new_location
def random_location_variance(self, enemy_start_location): """ 随机给出敌方主矿附近的侦查坐标 :param enemy_start_location: 敌方出生点 :return: 侦查坐标 """ x = enemy_start_location[0] y = enemy_start_location[1] x += ((random.randrange(-20, 20)) / 100) * enemy_start_location[0] y += ((random.randrange(-20, 20)) / 100) * enemy_start_location[1] if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] # 无法直接返回xy二维坐标,大概因为游戏是三维的原因。需要用sc2的position转换坐标 注意传入的是tuple go_to = position.Point2(position.Pointlike((x, y))) return go_to
def random_location_variance(self, enemy_start_location): """ :param enemy_start_location: Enenmy initial set up base postion :return: """ x = enemy_start_location[0] y = enemy_start_location[1] x += ((random.randrange(-30, 30)) / 100) * enemy_start_location[0] y += ((random.randrange(-30, 30)) / 100) * enemy_start_location[1] if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x, y))) return go_to
def find_highground_centroids(self, highground_tiles) -> np.array: # using db index, find the optimal number of clusters for kmeans range_of_k = range(4, 22) # store all the davies-bouldin index values dbindexes = [] for k in range_of_k: # try kmeans for each k value kmeans = KMeans(n_clusters=k, random_state=42).fit(highground_tiles) dbindexes.append( self.davis_bouldin_index(highground_tiles, kmeans.labels_, k)) kmeans = KMeans(n_clusters=np.argmin(dbindexes) + 4, random_state=42).fit(highground_tiles) ol_spots: List[Point2] = [ Point2(position.Pointlike((pos[0], pos[1]))) for pos in kmeans.cluster_centers_ ] # each clusters centroid is the overlord positions return ol_spots
def random_location_variance(self, enemy_start_location): # Цель найти координаты ВРАГА и отправить СКАУТА! # Определили начальные координаты ВРАГА x = enemy_start_location[0] # print('\n x: \n', x) # 161.5 # print('\n type(x): \n', type(x)) # <class 'float'> y = enemy_start_location[1] # print('\n y: \n', y) # 21.5 # print('\n type(y): \n', type(y)) # <class 'float'> # Мы не можем посылать разведчика прямо в центр базы ВРАГА, по этому # Задаем отклонение X и Y x += ((random.randrange(-20, 20)) / 100) * enemy_start_location[0] # print('\n x: \n', x) # 142.12 # print('\n type(x): \n', type(x)) # <class 'float'> y += ((random.randrange(-20, 20)) / 100) * enemy_start_location[1] # print('\n y: \n', y) # 17.63 # print('\n type(y): \n', type(y)) # <class 'float'> # Координаты с учетом отклонения могут уйти за пределы игровой карты, для этого ставим проверки if x < 0: x = 0 if y < 0: y = 0 if x > self.game_info.map_size[0]: x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: y = self.game_info.map_size[1] # Используем полученные координаты с учетом проверок и отправляем СКАУТА к базе врага go_to = position.Point2(position.Pointlike( (x, y))) # КЛЮЧЕВЫЕ ФУНКЦИИ ДВИЖЕНИЯ # print('\n go_to: \n', go_to) # (142.12, 17.63) # print('\n type(go_to): \n', type(go_to)) # <class 'sc2.position.Point2'> return go_to
def random_location_variance(self, enemy_start_location): x = enemy_start_location[0] y = enemy_start_location[1] # FIXED THIS x += ((random.randrange(-20, 20)) / 100) * self.game_info.map_size[0] y += ((random.randrange(-20, 20)) / 100) * self.game_info.map_size[1] if x < 0: print("x below") x = 0 if y < 0: print("y below") y = 0 if x > self.game_info.map_size[0]: print("x above") x = self.game_info.map_size[0] if y > self.game_info.map_size[1]: print("y above") y = self.game_info.map_size[1] go_to = position.Point2(position.Pointlike((x, y))) return go_to
async def offensive_force_buildings(self): if self.units(SUPPLYDEPOT).ready.exists: supply_depot = self.units(SUPPLYDEPOT).ready.random if len(self.units(BARRACKS)) < ( (self.iteration / self.ITERATIONS_PER_MINUTE) / 2): if self.can_afford( BARRACKS) and not self.already_pending(BARRACKS): await self.build(BARRACKS, near=supply_depot) if self.units(BARRACKS).ready.exists and not self.units(FACTORY): if self.can_afford( FACTORY) and not self.already_pending(FACTORY): # print("Main Comamnd center position: {}".format(self.main_command_center.position)) # print("Main Comamnd center position x: {}".format(self.main_command_center.position.x)) # print("Main Comamnd center position y: {}".format(self.main_command_center.position.y)) can_place_factory = False can_place_addon = False while (can_place_factory == False or can_place_addon == False): random_xpos = random.randrange(5, 15) random_ypos = random.randrange(-10, 10) if self.main_command_center.position.x < 100: factory_position = position.Point2( position.Pointlike( (self.main_command_center.position.x + random_xpos, self.main_command_center.position.y + random_ypos))) else: factory_position = position.Point2( position.Pointlike( (self.main_command_center.position.x - random_xpos, self.main_command_center.position.y + random_ypos))) addon_pos = position.Point2( position.Pointlike( (factory_position.x + 5, factory_position.y))) can_place_factory = await self.can_place( FACTORY, factory_position) can_place_addon = await self.can_place( SUPPLYDEPOT, addon_pos) # print("Factory Position {}".format(factory_position)) # print("Add On Position {}".format(addon_pos)) # print("Can place Factory {}".format(can_place_factory)) # print("Can place add on {}".format(can_place_addon)) await self.build(FACTORY, factory_position) for factory in self.units(FACTORY).ready.noqueue: #if self.can_afford(FACTORYTECHLAB) and not factory.has_add_on and not self.already_pending(FACTORYTECHLAB): #minerals 50 #vespene 25 #if self.can_afford(FACTORYTECHLAB): if self.minerals >= 50 and self.vespene >= 25: if not factory.has_add_on and not self.already_pending( FACTORYTECHLAB): await self.do(factory.train(FACTORYTECHLAB)) if self.units(FACTORY).ready.exists and not self.units(STARPORT): if self.can_afford( STARPORT) and not self.already_pending(STARPORT): can_place_starport = False can_place_addon = False while (can_place_starport == False or can_place_addon == False): random_xpos = random.randrange(7, 15) random_ypos = random.randrange(-10, 10) if self.main_command_center.position.x < 100: starport_position = position.Point2( position.Pointlike( (self.main_command_center.position.x + random_xpos, self.main_command_center.position.y + random_ypos))) else: starport_position = position.Point2( position.Pointlike( (self.main_command_center.position.x - random_xpos, self.main_command_center.position.y + random_ypos))) addon_pos = position.Point2( position.Pointlike((starport_position.x + 5, starport_position.y))) can_place_starport = await self.can_place( STARPORT, starport_position) can_place_addon = await self.can_place( SUPPLYDEPOT, addon_pos) await self.build(STARPORT, starport_position) #await self.build(STARPORT, near=supply_depot) for starport in self.units(STARPORT).ready.noqueue: if self.minerals >= 50 and self.vespene >= 25: if not starport.has_add_on and not self.already_pending( STARPORTREACTOR): await self.do(starport.train(STARPORTREACTOR))
async def intel(self): ''' just simply iterate units. outline fighters in white possibly? draw pending units with more alpha ''' game_data = np.zeros( (self.game_info.map_size[1], self.game_info.map_size[0], 3), np.uint8) for unit in self.units().ready: pos = unit.position cv2.circle(game_data, (int(pos[0]), int(pos[1])), int(unit.radius * 8), (255, 255, 255), math.ceil(int(unit.radius * 0.5))) for unit in self.known_enemy_units: pos = unit.position cv2.circle(game_data, (int(pos[0]), int(pos[1])), int(unit.radius * 8), (125, 125, 125), math.ceil(int(unit.radius * 0.5))) try: line_max = 50 mineral_ratio = self.minerals / 1500 if mineral_ratio > 1.0: mineral_ratio = 1.0 vespene_ratio = self.vespene / 1500 if vespene_ratio > 1.0: vespene_ratio = 1.0 population_ratio = self.supply_left / self.supply_cap if population_ratio > 1.0: population_ratio = 1.0 plausible_supply = self.supply_cap / 200.0 worker_weight = len( self.units(PROBE)) / (self.supply_cap - self.supply_left) if worker_weight > 1.0: worker_weight = 1.0 cv2.line(game_data, (0, 19), (int(line_max * worker_weight), 19), (250, 250, 200), 3) # worker/supply ratio cv2.line(game_data, (0, 15), (int(line_max * plausible_supply), 15), (220, 200, 200), 3) # plausible supply (supply/200.0) cv2.line(game_data, (0, 11), (int(line_max * population_ratio), 11), (150, 150, 150), 3) # population ratio (supply_left/supply) cv2.line(game_data, (0, 7), (int(line_max * vespene_ratio), 7), (210, 200, 0), 3) # gas / 1500 cv2.line(game_data, (0, 3), (int(line_max * mineral_ratio), 3), (0, 255, 25), 3) # minerals minerals/1500 map = np.zeros( (self.game_info.map_size[0], self.game_info.map_size[1])) for i in range(0, self.game_info.map_size[0]): for j in range(0, self.game_info.map_size[1]): map[i][j] = self.get_terrain_height( position.Point2(position.Pointlike((i, j)))) print(map) except Exception as e: print(str(e)) # flip horizontally to make our final fix in visual representation: grayed = cv2.cvtColor(game_data, cv2.COLOR_BGR2GRAY) self.flipped = cv2.flip(grayed, 0) #print(self.flipped) resized = cv2.resize(self.flipped, dsize=None, fx=2, fy=2) if not HEADLESS: if self.use_model: cv2.imshow(str(self.title), resized) cv2.waitKey(1) else: cv2.imshow(str(self.title), resized) cv2.waitKey(1)
async def attack_choise(self): array_choise = np.zeros(4) # current_choise = random.randint(0,3) target = False if self.units(MARAUDER).ready or self.units(MARINE).ready or self.units(HELLION).ready\ or self.units(BANSHEE).ready: if self.time > self.do_smth_after: if self.use_model: prediction = self.model.predict( [self.flipped.reshape([-1, 176, 200, 1])]) current_choise = np.argmax(prediction[0]) print('prediction: ', current_choise) else: current_choise = random.randint(0, 3) if current_choise == 0: # array_choise[current_choise] = 1 self.do_smth_after = self.time + 0.2 print('\n\t The choice is:\t Nothing') # print('\n\t Array: {}'.format(array_choise)) elif current_choise == 1: # array_choise[current_choise] = 1 if len(self.known_enemy_units) > 0: target = self.known_enemy_units.random.position print('\n\t The choice is:\t Attack known enemy units') elif current_choise == 2: if self.flag == False: target = position.Point2(position.Pointlike((93, 70))) self.do_smth_after = self.time + 0.2 self.flag = True print( '\n\t The choice is:\t On the way to the Center') else: target = self.enemy_start_locations[0].position print('\n\t The choice is:\t Attack Enemy Location') elif current_choise == 3: # array_choise[current_choise] = 1 for h in self.units(HELLION).idle: await self.do( h.attack(self.state.mineral_field.random.position)) print('\n\t The choice is:\t Explore Map') if target: print('TRUE') if self.units(BANSHEE).ready: for b in self.units(BANSHEE).idle: await self.do(b.attack(target)) if self.units(MARAUDER).ready: for m in self.units(MARAUDER).idle: await self.do(m.attack(target)) if self.units(MARINE).ready: for mn in self.units(MARINE).idle: await self.do(mn.attack(target)) if self.units(HELLION).ready: for mn in self.units(HELLION).idle: await self.do(mn.attack(target)) # NOTES: # Both values: [[array_choise, self.flipped]] -- should be in Numpy format # Also you should be saving in Numpy format self.train_data.append([array_choise, self.flipped])