Example #1
0
 def attack_transfer(self):
     '''
     Method to attack another region or transfer troops to allied regions.
     
     Currently checks whether a region has more than six troops placed to attack,
     or transfers if more than 1 unit is available.
     '''
     attack_transfers = []
     
     owned_regions = self.map.get_owned_regions(self.settings['your_bot'])
     
     for region in owned_regions:
         neighbours = list(region.neighbours)
         while len(neighbours) > 0:
             target_region = neighbours[Random.randrange(0, len(neighbours))]
             if region.owner != target_region.owner and region.troop_count > 6:
                 attack_transfers.append([region.id, target_region.id, 5])
                 region.troop_count -= 5
             elif region.owner == target_region.owner and region.troop_count > 1:
                 attack_transfers.append([region.id, target_region.id, region.troop_count - 1])
                 region.troop_count = 1
             else:
                 neighbours.remove(target_region)
     
     if len(attack_transfers) == 0:
         return 'No moves'
     
     return ', '.join(['%s attack/transfer %s %s %s' % (self.settings['your_bot'], attack_transfer[0],
         attack_transfer[1], attack_transfer[2]) for attack_transfer in attack_transfers])
Example #2
0
 def pick_starting_region(self, options):
     '''
     Method to select our initial starting region.
     
     Currently selects a random region from the list.
     '''
     i = Random.randrange(0,len(options)-1)
     
     return options[i]