def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) #game_state.suppress_warnings(True) #Uncomment this line to suppress warnings. #self.starter_strategy(game_state) firewall_locations = [[2, 13], [3, 13], [4, 13], [5, 13], [12, 13], [13, 13], [14, 13], [15, 13], [22, 13], [23, 13], [24, 13], [25, 13]] for location in firewall_locations: if game_state.can_spawn(FILTER, location): game_state.attempt_spawn(FILTER, location) attack_locations = [[9, 4], [10, 3], [17, 3], [11, 2], [16, 2]] for location in attack_locations: if game_state.can_spawn(PING, location): game_state.attempt_spawn(PING, location) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) # Comment or remove this line to enable warnings. game_state.suppress_warnings(True) # self.starter_strategy(game_state) self.build_the_wall(game_state) # Add extra destructors in corners if hit self.build_reactive_defense(game_state) # Fortify with extra encryptors and destructors at the mouth self.fortify_the_wall(game_state) self.randomAttack(game_state) gamelib.debug_write("Destructor Heatmap...") self.print_enemy_heatmap(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state, self.turret_locations, self.wall_locations, self.support_locations) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) game_state.suppress_warnings( True) # Comment or remove this line to enable warnings. game_state.update_loc(TURRET) game_state.update_loc(WALL) game_state.update_loc(SUPPORT) self.starter_strategy(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) #game_state.suppress_warnings(True) #Uncomment this line to suppress warnings. player_state = self.get_player_state(game_state) enemy_state = self.pred_enemy_state(game_state) strats = self.generate_strategies(player_state, enemy_state) if (len(strats) != 0): best_strat = strats[0] best_score = self.evaluate(best_strat, player_state, enemy_state) for strat in strats[1:]: score = self.evaluate(best_strat, player_state, enemy_state) if (score > best_score): best_score = score best_strat = strat self.execute_strat(best_strat) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) gamelib.debug_write('{} to build defenses with'.format( game_state.get_resource(game_state.CORES))) gamelib.debug_write('{} to build army with'.format( game_state.get_resource(game_state.BITS))) #game_state.suppress_warnings(True) #Uncomment this line to suppress warnings. #always try to build walls self.buildWalls(game_state) if game_state.get_resource(game_state.BITS) >= 12: self.deployShockTroops(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ self.turnNum += 1 game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) game_state.suppress_warnings( True) #Comment or remove this line to enable warnings. self.sentEMP = False self.placeWall(game_state) self.placeDefense(game_state) self.placeEnc(game_state) self.pingAttacks(game_state) self.placeScram(game_state) # self.empAttack(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ if not len(self.scored_on_locations) == 0: for k in self.scored_on_locations: gamelib.debug_write( f'My edge at {k} for {self.scored_on_locations[k]} dmg') #self.scored_on_locations = dict() if not len(self.damaged_on_locations) == 0: for k in self.damaged_on_locations: dmg = self.damaged_on_locations[k] if dmg > 0: gamelib.debug_write(f'My wall at {k} for {dmg} dmg') #self.damaged_on_locations = dict() game_state = gamelib.GameState(self.config, turn_state) #gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) #game_state.suppress_warnings(True) #Comment or remove this line to enable warnings. self.cores = game_state.get_resource(game_state.CORES) self.bits = game_state.get_resource(game_state.BITS) #self.starter_strategy(game_state) self.basic_strategy(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) game_state.suppress_warnings( True) #Comment or remove this line to enable warnings. self.starter_strategy(game_state) self.bits_spent = self.my_previous_bits - game_state.get_resource( game_state.BITS, 0) enemy_health_lost = self.previous_enemy_health - self.current_enemy_health self.previous_enemy_health = self.current_enemy_health self.current_enemy_health = game_state.enemy_health if enemy_health_lost == 0 and self.threshold < self.bits_spent: self.threshold = self.bits_spent gamelib.debug_write(self.threshold) game_state.submit_turn()
def on_turn(self, turn_state): game_state = gamelib.GameState(self.config, turn_state) game_state.enable_warnings = False gamelib.debug_write('Performing turn {} of RL bot'.format( game_state.turn_number)) game_json = json.loads(game_state.serialized_string) processed_game_state = self.get_processed_game_state( game_json, game_state) # action_vector = [0] * (len(self.ATTACK_OPTIONS) + # len(self.DEFENSE_OPTIONS)) # # pick action here by going thru every combination of actions and argmaxing (can maybe pick numerical action and we convert to binary string to encode actions) # random_action = random.randint(0, NUM_ACTIONS - 1) # random_action = action_to_vector(random_action) # assert len(random_action) == 6 # # can add how much money to spend later # action_num = 59 # action_vector = action_to_vector(action_num) # for i in range(len(action_vector)-2, len(action_vector)): # action_vector[i] = random.randint(0, 1) action_num = self.agent.pick_action(processed_game_state) action_vector = action_to_vector(action_num) reward = 0 # arbitrary multiplier so we spend more when we are dying do_action(action_vector, game_state, game_json) if TRAINING: self.agent.train_on_memory() # gamelib.debug_write("INSIDE algo strategy" + # str(self.agent.NN.model.layers[-1].get_weights()[0][0])) # choose action and see reward game_state.submit_turn() return processed_game_state, action_num, reward
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) game_state.suppress_warnings( True) #Comment or remove this line to enable warnings. # update enemy_state first self.enemy_state = enemy_info.EnemyState(game_state) self.enemy_state.scan_def_units() self._enemy_channal(self.enemy_state) # check if they have channal gamelib.debug_write("@@@@ {0} {1}".format( self.has_enemy_left_channal, self.has_enemy_right_channal)) self.starter_strategy(game_state) self.prev_game_state = copy.deepcopy(game_state) game_state.submit_turn()
def on_turn(self, turn_state): #____LOOP______ #____NEEDED____ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) game_state.suppress_warnings(True) #______________ FILTER_DEPLOY_LOCATION = [[ 4, 12],[ 23, 12],[ 4, 11],[ 5, 11],[ 6, 11],[ 21, 11],[ 22, 11],[ 23, 11],[ 7, 9],[ 20, 9],[ 7, 8],[ 8, 8],[ 9, 8],[ 18, 8],[ 19, 8],[ 20, 8],[ 10, 6],[ 17, 6],[ 10, 5],[ 11, 5],[ 12, 5],[ 15, 5],[ 16, 5],[ 17, 5],[ 13, 3],[ 14, 3]] ENCRYPTOR_DEPLOY_LOCATION = [[ 4, 13],[ 23, 13],[ 7, 10],[ 20, 10],[ 10, 7],[ 17, 7],[ 13, 4],[ 14, 4],[ 13, 2],[ 14, 2]] DESTRUCTOR_DEPLOY_LOCATION = [[ 3, 13],[ 24, 13],[ 6, 10],[ 21, 10],[ 9, 7],[ 18, 7],[ 12, 4],[ 15, 4],[ 13, 2],[ 14, 2]] if game_state.turn_number % 2: self.deploy_information(game_state, [13, 0], PING, 5 ) else: self.deploy_information(game_state, [14, 0], PING, 5 ) self.deploy_fireWall(game_state, DESTRUCTOR_DEPLOY_LOCATION, DESTRUCTOR) self.deploy_fireWall(game_state, FILTER_DEPLOY_LOCATION, FILTER) self.deploy_fireWall(game_state, ENCRYPTOR_DEPLOY_LOCATION, ENCRYPTOR) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) game_state.suppress_warnings(True) #Comment or remove this line to enable warnings. self.history_gamestate.append(game_state) self.enemy_map = np.zeros((28,28)) self.passes = [self.evaluate_board, self.get_stats, self.create_strategy] while len(self.passes)>0: f = self.passes[0] f(self.history_gamestate[-1], self.passes, self.plan) self.passes = self.passes[1:] if len(self.history_gamestate) > self.history_cap: self.history_gamestate = self.history_gamestate[1:] self.history_map_stationary = self.history_map_stationary[1:] assert len(self.history_gamestate) == len(self.history_map_stationary) # self.plan = { "aggression": self.plan.aggression, "attack_waves": self.plan.attack_waves } self.history_gamestate[-1].submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) game_state.suppress_warnings(True) #Comment or remove this line to enable warnings. if game_state.turn_number > 0: #self.find_side_attacked(game_state, True) num_destructor = len(self.destructor_locations) for idx in range(num_destructor): if [self.destructor_locations[idx][0], self.destructor_locations[idx][1]-1] not in self.destructor_locations and game_state.can_spawn(DESTRUCTOR, [self.destructor_locations[idx][0], self.destructor_locations[idx][1]-1]) and not game_state.contains_stationary_unit(self.destructor_locations[idx]): self.destructors_nextturn.append([self.destructor_locations[idx][0], self.destructor_locations[idx][1]-1]) elif [self.destructor_locations[idx][0]+1, self.destructor_locations[idx][1]] not in self.destructor_locations and game_state.can_spawn(DESTRUCTOR, [self.destructor_locations[idx][0]+1, self.destructor_locations[idx][1]]) and not game_state.contains_stationary_unit(self.destructor_locations[idx]): self.destructors_nextturn.append([self.destructor_locations[idx][0]+1, self.destructor_locations[idx][1]]) elif [self.destructor_locations[idx][0]-1, self.destructor_locations[idx][1]] not in self.destructor_locations and game_state.can_spawn(DESTRUCTOR, [self.destructor_locations[idx][0]-1, self.destructor_locations[idx][1]]) and not game_state.contains_stationary_unit(self.destructor_locations[idx]): self.destructors_nextturn.append([self.destructor_locations[idx][0]-1, self.destructor_locations[idx][1]]) #gamelib.debug_write('sides: {}'.format(self.sidesAttacked)) self.DenizStrat(game_state) #self.find_side_attacked(game_state, False) #gamelib.debug_write('sides_after: {}'.format(self.sidesAttacked)) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) game_state.suppress_warnings( True) #Comment or remove this line to enable warnings. if (game_state.turn_number < 3): self.init_defense(game_state) else: self.adaptive_defense(game_state) self.attack_finish(game_state) self.attack_action(game_state) self.attack_prepare(game_state) self.add_encryptor(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) #gamelib.debug_write('Performing turn {} of the Genetic-agent strategy'.format(game_state.turn_number)) game_state.suppress_warnings(True) #Comment or remove this line to enable warnings. board_state, game_data = self.parse_serialized_string(turn_state) last_state, last_data = None, None if self.last_board is None: last_state = np.copy(board_state) last_data = np.copy(game_data) else: last_state = self.last_board[0] last_data = self.last_board[1] board_state = torch.FloatTensor(board_state) game_data = torch.FloatTensor(game_data) last_state = torch.FloatTensor(last_state) last_data = torch.FloatTensor(last_data) conv_input = torch.cat((board_state, last_state), 0) linear_input = torch.cat((game_data, last_data), 0) conv_input = conv_input.permute(2, 1, 0).unsqueeze(0) conv_input = conv_input.float() network_output = self.model.forward(conv_input, linear_input) game_state = self.perform_action_using_output(network_output.numpy(), game_state) game_state.submit_turn()
def on_turn(self, turn_state): game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write('Performing turn %d of your custom algo strategy' % game_state.turn_number) self.starterstrategy(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) if game_state.turn_number == 0: while game_state.can_spawn(PING, self.firstTurnTroopCoord): game_state.attempt_spawn(PING, self.firstTurnTroopCoord) # no building this turn else: #if shock troops aren't successful, go with the bruisers if game_state.get_resource(game_state.BITS) >= 8: self.attackedLastTurn = True #while (len(gamelib.advanced_game_state.AdvancedGameState.get_attackers(game_state, self.troopDeploymentCoords, 0)) > 0): # self.moveDeploymentAway() self.deployRammingTroops(game_state) self.deployTroops(game_state) self.buildWalls(game_state) # this doesn't work yet! #self.markForRefund(game_state) game_state.submit_turn()
def on_turn(self, turn_state): game_state = gamelib.GameState(self.config, turn_state) game_state.enable_warnings = False self.defense(game_state) self.attack(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) # game_state.attempt_spawn(DEMOLISHER, [24, 10], 3) gamelib.debug_write( 'Performing turn {} of your custom algo strategy'.format( game_state.turn_number)) game_state.suppress_warnings( True) #Comment or remove this line to enable warnings. # self.starter_strategy(game_state) # if (game_state.turn_number == 0): # turn 1 : prioritize building the wall and a factory and a few scouts # Inner wall: (5,13) to (13, 5), (14, 5) to (22, 13) wall_locations = [[5, 13], [6, 12], [7, 11], [8, 10], [9, 9], [10, 8], [11, 7], [12, 6], [13, 5], [14, 5], [15, 6], [16, 7], [17, 8], [18, 9], [19, 10], [20, 11], [21, 12], [22, 13]] # use up all our structure points extra_wall_locations = [[1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 3], [11, 2], [12, 1], [15, 1], [16, 2], [17, 3], [18, 4], [19, 5], [20, 6], [21, 7], [22, 8], [23, 9], [24, 10], [25, 11], [26, 12]] # if game_state.can_spawn(WALL, wall_locations): game_state.attempt_spawn(WALL, wall_locations, len(wall_locations)) game_state.attempt_spawn(WALL, extra_wall_locations, len(extra_wall_locations)) factory_locations = [[13, 4]] # if game_state(can_spawn(FACTORY, factory_locations)): game_state.attempt_spawn(FACTORY, factory_locations, len(factory_locations)) scout_spawn_location_options = [[0, 13], [13, 0], [14, 0], [27, 13]] i = 0 while (game_state.can_spawn(SCOUT, scout_spawn_location_options[i], 1)): game_state.attempt_spawn(SCOUT, scout_spawn_location_options[i], 1) i += 1 i %= len(scout_spawn_location_options) # elif (): # # turn 2 - 7 : maintain wall, add one factory/turn, add demolisher on right and left # elif (): # # turn 7 - 20 : maintain wall, replenish factories, demolisher + scouts # else: # 21 --------------------------add turrets, game_state.submit_turn()
def on_turn(self, turn_state): game_state = gamelib.GameState(self.config, turn_state) game_state.enable_warnings = False gamelib.debug_write('Performing turn {} of do nothing bot'.format( game_state.turn_number)) self.spawn_defenses(game_state) game_state.submit_turn()
def on_turn(self, turn_state): game_state = gamelib.GameState(self.config, turn_state) game_state.suppress_warnings( True) #Comment or remove this line to enable warnings. self.watchme_strategy(game_state) game_state.submit_turn()
def on_turn(self, turn_state): game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) # game_state.suppress_warnings(True) #Uncomment this line to suppress warnings. self.starter_strategy(game_state) game_state.submit_turn()
def on_action_frame(self, turn_state): action_frame = gamelib.GameState(self.config, turn_state) breach_locations = action_frame.get_breach_locations() for location in breach_locations: if location[1] < self.quadrant_analyzer.half_area: self.scoring_locations['enemy'].append(location) else: self.scoring_locations['me'].append(location)
def on_turn(self, turn_state): """ game_state = gives you state of arena this executes every turn --> starter_strategy is used every turn """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) game_state.suppress_warnings(True) #Comment or remove this line to enable warnings. self.starter_strategy(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write(f'Performing turn {game_state.turn_number} of ' 'your custom algo strategy') # Call our strategy function to perform our moves self.battle_strategy(game_state) game_state.submit_turn()
def on_turn(self, cmd): ''' This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. ''' game_state = gamelib.GameState(self.config, cmd) gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) self.starter_strategy(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) game_state.suppress_warnings(True) #Comment this line to show warnings. self.emp_line_strategy(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ game_state = gamelib.GameState(self.config, turn_state) #game_state.suppress_warnings(True) #Uncomment this line to suppress warnings. # consider an attack successful if it did a large amount of structure damage (>5) if self.attackedLastTurn and game_state.enemy_health == self.lastEnemyHealth: #our last attack was not successful! change strategies self.useShockTroops = not self.useShockTroops gamelib.debug_write( 'our last attack was not successful! Changing strategies.') self.attackedLastTurn = False elif self.attackedLastTurn: gamelib.debug_write( 'Our last attacked worked! We did {} damage'.format( self.lastEnemyHealth - game_state.enemy_health)) self.lastEnemyHealth = game_state.enemy_health self.attackedLastTurn = False #if shock troops aren't successful, go with the bruisers if game_state.get_resource(game_state.BITS) >= 12: self.attackedLastTurn = True while (len( gamelib. advanced_game_state.AdvancedGameState.get_attackers( game_state, self.troopDeploymentCoords, 0)) > 0): self.moveDeploymentAway() if self.useShockTroops: self.deployShockTroops(game_state) else: self.deployBruisers(game_state) #always try to build walls # consider reinforcing weak areas? # may need to retreat from front-line self.buildWalls(game_state) game_state.submit_turn()
def on_turn(self, turn_state): """ This function is called every turn with the game state wrapper as an argument. The wrapper stores the state of the arena and has methods for querying its state, allocating your current resources as planned unit deployments, and transmitting your intended deployments to the game engine. """ start_time = time.time() game_state = gamelib.GameState(self.config, turn_state) gamelib.debug_write('Performing turn {} of your custom algo strategy'.format(game_state.turn_number)) game_state.suppress_warnings(True) # Comment or remove this line to enable warnings. self.evaluate_self_defence(game_state) self.evaluate_enemy_defence(game_state) self.populate_defense(game_state, [13], start_time) self.__place__attackers__(game_state, start_time) game_state.submit_turn()
def on_action_frame(self, turn_string): """ This is the action frame of the game. This function could be called hundreds of times per turn and could slow the algo down so avoid putting slow code here. Processing the action frames is complicated so we only suggest it if you have time and experience. Full doc on format of a game frame at in json-docs.html in the root of the Starterkit. """ # Let's record at what position we get scored on state = json.loads(turn_string) events = state["events"] breaches = events["breach"] spawns = events["spawn"] damages = events["damage"] deaths = events["death"] game_state = gamelib.GameState(self.config, turn_string) for death in deaths: if death[1] in [0, 1, 2] and death[3] == 1 and not death[4]: self.destroyed_locations.append(death[0])