Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import math
- import random
- def odleglosc(x1, y1, x2, y2):
- return math.sqrt((x2-x1)**2 + (y2-y1)**2)
- # Send your busters out into the fog to trap ghosts and bring them home!
- busters_per_player = int(input()) # the amount of busters you control
- ghost_count = int(input()) # the amount of ghosts on the map
- 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
- # game loop
- while True:
- busters = []
- ghosts=[]
- enemies=[]
- entities = int(input()) # the number of busters and ghosts visible to you
- for i in range(entities):
- # entity_id: buster id or ghost id
- # y: position of this buster / ghost
- # entity_type: the team id if it is a buster, -1 if it is a ghost.
- # state: For busters: 0=idle, 1=carrying a ghost.
- # value: For busters: Ghost id being carried. For ghosts: number of busters attempting to trap this ghost.
- entity_id, x, y, entity_type, state, value = [int(j) for j in input().split()]
- if entity_type==-1: # DODAJE WIDOCZNEGO DUCHA DO GURPY DUCHÓW
- ghosts.append({'id': entity_id, 'x': x, 'y': y, 'value': value})
- elif entity_type==my_team_id: # DODAJE MOJEGO GRACZA DO MOICH GRACZY
- busters.append({'id': entity_id, 'x': x, 'y': y, 'value': value, 'state': state})
- else: # DODAJE WROGA DO GRUPY WRÓG
- enemies.append({'id': entity_id, 'x': x, 'y': y, 'value': value, 'state': state})
- if my_team_id ==0: # OKREŚLA POŁOŻENIE BAZY
- baza_x=0
- baza_y=0
- elif my_team_id==1:
- baza_x=16000
- baza_y=9000
- for i in busters:
- if i["state"]==1: #JEŻELI NIESIE DUCHA TO:
- if odleglosc(i["x"], i["y"], baza_x, baza_y) <= 1600: #STOI BLISKO BAZY TO WYRZUCA DUCHA
- print("RELEASE")
- i["state"]=0 #ZMIENIA STATUS NA WOLNY, MOŻE NIEŚĆ
- else:
- print ("MOVE {} {}".format (baza_x, baza_y)) # INACZEJ IDZIE W KIERUNKU BAZY
- elif i["state"]==0:
- if len(ghosts) > 0: # JEŻELI WIDZI DUCHY
- dystans = 16000
- cel_odleglosc=0
- for g in ghosts: #SPRAWDZA DYSTANS DO KAŻDEGO WIDZIANEGO DUCHA
- nowy_dystans = odleglosc(i["x"], i["y"], g["x"], g["y"])
- if nowy_dystans < dystans:
- cel=g #AKTUALIZUJE NAJBLIŻSZEGO DUCHA
- cel_odleglosc=nowy_dystans
- if cel_odleglosc>=900 and cel_odleglosc<=1760: #JEŻELI MOŻE TO ŁAPIE DUCHA
- print("BUST", cel["id"])
- i["state"]=1 #ZMIENIA STATUS ZA ZAJĘTY
- elif cel_odleglosc>1760:
- print ("MOVE {} {}".format (cel["x"],cel["y"]))
- else:
- print ("MOVE {} {}".format (random.randint(0, 16000), random.randint(0, 9000)))
- #print ("MOVE {} {}".format (random.randint(0, 16000), random.randint(0, 9000)))
- # Write an action using print
- # To debug: print("Debug messages...", file=sys.stderr)
- # MOVE x y | BUST id | RELEASE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement