Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.98 KB | None | 0 0
  1. import sys
  2. import math
  3.  
  4. # Send your busters out into the fog to trap ghosts and bring them home!
  5.  
  6. busters_per_player = int(input())  # the amount of busters you control
  7. ghost_count = int(input())  # the amount of ghosts on the map
  8. my_team_id = int(input())  # if this is 0, your base is on the top left of the map, if it is one, on the bottom right
  9.  
  10. def find_closest(x, y, ghosts, bid):
  11.     dist=18000
  12.     tx,ty,tid=0,0,0
  13.     for a in ghosts:
  14.         temp=sqrt((x-a[0])**2+(y-a[1])**2)
  15.         if temp<dist:
  16.             dist=temp
  17.             tx=a[0]
  18.             ty=a[1]
  19.             tid=a[2]
  20.     if dist<1760:
  21.         print("BUST "+tid)
  22.     else:
  23.         print("MOVE "+tx+" "+ty)
  24.  
  25.  
  26.  
  27. # game loop
  28. while True:
  29.     entities = int(input())  # the number of busters and ghosts visible to you
  30.     ghosts = [[]]
  31.     for i in range(entities):
  32.         # entity_id: buster id or ghost id
  33.         # y: position of this buster / ghost
  34.         # entity_type: the team id if it is a buster, -1 if it is a ghost.
  35.         # state: For busters: 0=idle, 1=carrying a ghost.
  36.         # value: For busters: Ghost id being carried. For ghosts: number of busters attempting to trap this ghost.
  37.         entity_id, x, y, entity_type, state, value = [int(j) for j in input().split()]
  38.         if entity_type==-1:
  39.             ghosts+=[x,y,entity_id]
  40.            
  41.     for i in range(entities):
  42.         # entity_id: buster id or ghost id
  43.         # y: position of this buster / ghost
  44.         # entity_type: the team id if it is a buster, -1 if it is a ghost.
  45.         # state: For busters: 0=idle, 1=carrying a ghost.
  46.         # value: For busters: Ghost id being carried. For ghosts: number of busters attempting to trap this ghost.
  47.         entity_id, x, y, entity_type, state, value = [int(j) for j in input().split()]
  48.         if entity_type==my_team_id:
  49.             if ghosts:
  50.                 find_closest(x, y, ghosts, bid)
  51.             else:
  52.                print("MOVE 8000 4500")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement