Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.71 KB | None | 0 0
  1. import sys
  2. import math
  3.  
  4. # Auto-generated code below aims at helping you parse
  5. # the standard input according to the problem statement.
  6.  
  7. class Units:
  8.     def __init__(self, unit_id, unit_type, player, mass, radius, x, y, vx, vy, extra, extra_2):
  9.         self.unit_id = unit_id
  10.         self.unit_type = unit_type
  11.         self.x = x
  12.         self.y = y
  13.         self.vx = vx
  14.         self.vy = vy
  15.         self.water = extra
  16.         self.radius = radius
  17.  
  18. # game loop
  19.  
  20.  
  21. while True:
  22.     wreckunsort = []
  23.     wreck = []
  24.     threat = 0
  25.     my_score = int(input())
  26.     enemy_score_1 = int(input())
  27.     enemy_score_2 = int(input())
  28.     my_rage = int(input())
  29.     enemy_rage_1 = int(input())
  30.     enemy_rage_2 = int(input())
  31.     unit_count = int(input())
  32.     for i in range(unit_count):
  33.         unit_id, unit_type, player, mass, radius, x, y, vx, vy, extra, extra_2 = input().split()
  34.         unit_id = int(unit_id)
  35.         unit_type = int(unit_type)
  36.         player = int(player)
  37.         mass = float(mass)
  38.         radius = int(radius)
  39.         x = int(x)
  40.         y = int(y)
  41.         vx = int(vx)
  42.         vy = int(vy)
  43.         extra = int(extra)
  44.         extra_2 = int(extra_2)
  45.         if unit_id == 0:
  46.             reaper = Units(unit_id, unit_type, player, mass, radius, x, y, vx, vy, extra, extra_2)
  47.         if unit_id == 1:
  48.             reaper1 = Units(unit_id, unit_type, player, mass, radius, x, y, vx, vy, extra, extra_2)
  49.         if unit_id == 2:
  50.             reaper2 = Units(unit_id, unit_type, player, mass, radius, x, y, vx, vy, extra, extra_2)
  51.         elif unit_type == 4:
  52.             wreckunsort.append(Units(unit_id, unit_type, player, mass, radius, x, y, vx, vy, extra, extra_2))
  53.        
  54.         for i in wreckunsort:
  55.             dy = i.y - reaper.y
  56.             dx = i.x - reaper.x
  57.             d1x = i.x - reaper1.x
  58.             d1y = i.y - reaper1.y
  59.             d2x = i.x - reaper2.x
  60.             d2y = i.x - reaper2.y
  61.             if round(math.sqrt(abs(d1x)^2 + abs(d1y)^2)) < i.radius:
  62.                 threat +=1
  63.             if round(math.sqrt(abs(d2x)^2 + abs(d2y)^2)) < i.radius:
  64.                 threat +=1
  65.            
  66.             score = ((math.sqrt(abs(dx)^2 + abs(dy)^2))/i.water)/threat*2
  67.             i.score = score
  68.             wreck.append(i)
  69.    
  70.     wreck.sort(key=lambda x: x.score)
  71.     target = wreck[0]
  72.     dy = target.y - reaper.y
  73.     dx = target.x - reaper.x
  74.    
  75.     dist = round(math.sqrt(abs(dx)^2 + abs(dy)^2))
  76.    
  77.     if dist > target.radius:
  78.         print(target.x,target.y, 300)
  79.     else:
  80.         print(target.x,target.y, 200)
  81.  
  82.        
  83.     # Write an action using print
  84.     # To debug: print("Debug messages...", file=sys.stderr)
  85.  
  86.     print("WAIT")
  87.     print("WAIT")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement