Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import math
- class Site:
- def __init__(self, site_id, x, y, radius):
- self.site_id = site_id
- self.x = x
- self.y = y
- self.radius = radius
- def setAtt(self, ignore_1, ignore_2, structure_type, owner, param_1, param_2):
- self.ignore_1 = ignore_1
- self.ignore_2 = ignore_2
- self.structure_type = structure_type
- self.owner = owner
- self.param_1 = param_1
- self.param_2 = param_2
- class Unit:
- def __init__(self, x, y, owner, unit_type, health):
- self.x = x
- self.y = y
- def dis(gun, target):
- return math.sqrt((target.y-gun.y)**2+(target.x-gun.x)**2)
- def build():
- #print(sites.items())
- sorted_closet_site = sorted(sites, key=lambda x: dis(my_queen, sites[x]))
- for site in sorted_closet_site:
- if sites[site].structure_type == -1:
- print("BUILD {} BARRACKS-{}".format(site, 'KNIGHT'))
- return
- def train():
- global gold
- id_to_train = []
- for site in sites:
- if sites[site].owner == 0 and gold>=80:
- id_to_train.append(site)
- gold-=80
- if len(id_to_train)>0:
- print('TRAIN', ' '.join(map(str,id_to_train)))
- else:
- print('TRAIN')
- num_sites = int(input())
- sites = {}
- for i in range(num_sites):
- site_id, x, y, radius = [int(j) for j in input().split()]
- sites[site_id] = Site(site_id, x, y, radius)
- my_queen = None
- op_queen = None
- gold=0
- while True:
- # touched_site: -1 if none
- gold, touched_site = [int(i) for i in input().split()]
- for i in range(num_sites):
- # ignore_1: used in future leagues
- # ignore_2: used in future leagues
- # structure_type: -1 = No structure, 2 = Barracks
- # owner: -1 = No structure, 0 = Friendly, 1 = Enemy
- site_id, ignore_1, ignore_2, structure_type, owner, param_1, param_2 = [int(j) for j in input().split()]
- sites[site_id].setAtt(ignore_1, ignore_2, structure_type, owner, param_1, param_2)
- num_units = int(input())
- for i in range(num_units):
- # unit_type: -1 = QUEEN, 0 = KNIGHT, 1 = ARCHER
- x, y, owner, unit_type, health = [int(j) for j in input().split()]
- if unit_type == -1:
- if owner == 0:
- my_queen=Unit(x, y, owner, unit_type, health)
- if owner == 1:
- op_queen=Unit(x, y, owner, unit_type, health)
- build()
- train()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement