-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathPlayer.py
77 lines (47 loc) · 1.69 KB
/
Player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import sys
from operator import attrgetter
class Point:
def __init__(self, x=-1, y=-1):
self.x, self.y = x, y
def __str__(self):
return "%d %d" % (self.x, self.y)
class Player:
def __init__(self, nbr_drones, id=-1):
self.drones = [Drone() for i in xrange(nbr_drones)]
self.id = id
class Drone:
nbr_instances = 0
point = None
def __init__(self):
Drone.nbr_instances += 1
def __del__(self):
Drone.nbr_instances -= 1
class Zone:
def __init__(self, centre=None, dominant=None):
self.centre, self.dominant = centre, dominant
players = drones = zones = nbr_drones = None
my_id = None
# Read init information from standard input
def init():
global players, drones, zones, my_id, nbr_drones
nbr_players, id, nbr_drones, nbr_zones = [int(x) for x in raw_input().split()]
my_id = id
#create a sorted list of players, so that the player's index is the id
players = sorted([Player(nbr_drones, i) for i in xrange(nbr_players)], key=attrgetter('id'))
#create zones
zones = [Zone(Point(*[int(x) for x in raw_input().split()])) for i in xrange(nbr_zones)]
init()
while 1:
for i in xrange(len(zones)):
id = int(raw_input())
if id == -1:
#...
else:
zones[i].dominant = players[i]
for i in xrange(len(players)):
for j in xrange(nbr_drones):
players[i].drones[j].point = Point(*[int(x) for x in raw_input().split()])
# Compute logic here
# print >> sys.stderr, "Debug messages..."
# Write action to standard output
print "3999 1799"