Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.69 KB | None | 0 0
  1. import sys
  2. import math
  3. import random
  4.  
  5. def odleglosc(x1, y1, x2, y2):
  6.     return math.sqrt((x2-x1)**2 + (y2-y1)**2)
  7.  
  8. # Send your busters out into the fog to trap ghosts and bring them home!
  9.  
  10. busters_per_player = int(input())  # the amount of busters you control
  11. ghost_count = int(input())  # the amount of ghosts on the map
  12. 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
  13.  
  14. # game loop
  15. while True:
  16.     busters = []
  17.     ghosts=[]
  18.     enemies=[]
  19.     entities = int(input())  # the number of busters and ghosts visible to you
  20.     for i in range(entities):
  21.         # entity_id: buster id or ghost id
  22.         # y: position of this buster / ghost
  23.         # entity_type: the team id if it is a buster, -1 if it is a ghost.
  24.         # state: For busters: 0=idle, 1=carrying a ghost.
  25.         # value: For busters: Ghost id being carried. For ghosts: number of busters attempting to trap this ghost.
  26.         entity_id, x, y, entity_type, state, value = [int(j) for j in input().split()]
  27.         if entity_type==-1:                                                  # DODAJE WIDOCZNEGO DUCHA DO GURPY DUCHÓW
  28.             ghosts.append({'id': entity_id, 'x': x, 'y': y, 'value': value})
  29.         elif entity_type==my_team_id:                                        # DODAJE MOJEGO GRACZA DO MOICH GRACZY
  30.             busters.append({'id': entity_id, 'x': x, 'y': y, 'value': value, 'state': state})
  31.         else:                                                                # DODAJE WROGA DO GRUPY WRÓG
  32.             enemies.append({'id': entity_id, 'x': x, 'y': y, 'value': value, 'state': state})
  33.            
  34.     if my_team_id ==0:              # OKREŚLA POŁOŻENIE BAZY
  35.         baza_x=0
  36.         baza_y=0
  37.     elif my_team_id==1:
  38.         baza_x=16000
  39.         baza_y=9000
  40.        
  41.     for i in busters:
  42.         if i["state"]==1:                                                   #JEŻELI NIESIE DUCHA TO:
  43.             if odleglosc(i["x"], i["y"], baza_x, baza_y) <= 1600:           #STOI BLISKO BAZY TO WYRZUCA DUCHA
  44.                 print("RELEASE")
  45.                 i["state"]=0                                                #ZMIENIA STATUS NA WOLNY, MOŻE NIEŚĆ
  46.             else:
  47.                 print ("MOVE {} {}".format (baza_x, baza_y))                # INACZEJ IDZIE W KIERUNKU BAZY
  48.         elif i["state"]==0:
  49.             if len(ghosts) > 0:                                             # JEŻELI WIDZI DUCHY
  50.  
  51.                 dystans = 16000
  52.                 cel_odleglosc=0
  53.                 for g in ghosts:                                            #SPRAWDZA DYSTANS DO KAŻDEGO WIDZIANEGO DUCHA
  54.                     nowy_dystans = odleglosc(i["x"], i["y"], g["x"], g["y"])
  55.                     if nowy_dystans < dystans:
  56.                         cel=g                                               #AKTUALIZUJE NAJBLIŻSZEGO DUCHA
  57.                         cel_odleglosc=nowy_dystans
  58.                 if cel_odleglosc>=900 and cel_odleglosc<=1760:              #JEŻELI MOŻE TO ŁAPIE DUCHA
  59.                     print("BUST", cel["id"])
  60.                     i["state"]=1                                            #ZMIENIA STATUS ZA ZAJĘTY
  61.                 elif cel_odleglosc>1760:
  62.                     print ("MOVE {} {}".format (cel["x"],cel["y"]))
  63.             else:
  64.                 print ("MOVE {} {}".format (random.randint(0, 16000), random.randint(0, 9000)))
  65.                    
  66.                
  67.            
  68.  
  69.             #print ("MOVE {} {}".format (random.randint(0, 16000), random.randint(0, 9000)))
  70.  
  71.         # Write an action using print
  72.         # To debug: print("Debug messages...", file=sys.stderr)
  73.  
  74.         # MOVE x y | BUST id | RELEASE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement