4
4
from itertools import dropwhile
5
5
from sets import Set
6
6
from Image import open as PIL_open
7
- from Image import ANTIALIAS
7
+ from Image import ANTIALIAS
8
8
from StringIO import StringIO
9
9
from collections import defaultdict
10
10
@@ -31,7 +31,7 @@ def handleUnitInitEvent(self,event,replay):
31
31
if event .unit_type_name in ["CreepTumor" , "Hatchery" ,"NydusCanal" ] :
32
32
self .creepTracker .add_to_list (event .control_pid ,event .unit_id ,\
33
33
(event .x , event .y ), event .unit_type_name ,event .second )
34
-
34
+
35
35
def handleUnitBornEvent (self ,event ,replay ):
36
36
if event .unit_type_name == "Hatchery" :
37
37
self .creepTracker .add_to_list (event .control_pid , event .unit_id ,\
@@ -51,12 +51,12 @@ def handleEndGame(self, event, replay):
51
51
## Else statement is for players with no creep spread(ie: not Zerg)
52
52
player .max_creep_spread = 0
53
53
54
- ## The class used to used to calculate the creep spread
54
+ ## The class used to used to calculate the creep spread
55
55
class creep_tracker ():
56
56
def __init__ (self ,replay ):
57
57
#if the debug option is selected, minimaps will be printed to a file
58
- ##and a stringIO containing the minimap image will be saved for
59
- ##every minite in the game and the minimap with creep highlighted
58
+ ##and a stringIO containing the minimap image will be saved for
59
+ ##every minite in the game and the minimap with creep highlighted
60
60
## will be printed out.
61
61
self .debug = replay .opt .debug
62
62
##This list contains creep spread area for each player
@@ -76,7 +76,7 @@ def __init__(self,replay):
76
76
for x in self .unit_name_to_radius :
77
77
self .radius_to_coordinates [self .unit_name_to_radius [x ]] = \
78
78
self .radius_to_map_positions (self .unit_name_to_radius [x ])
79
-
79
+
80
80
#Get map information
81
81
replayMap = replay .map
82
82
# extract image from replay package
@@ -89,7 +89,7 @@ def __init__(self,replay):
89
89
# resize height to MAPHEIGHT, and compute new width that
90
90
# would preserve aspect ratio
91
91
self .map_width = int (cropsize [0 ] * (float (self .map_height ) / cropsize [1 ]))
92
- self .mapSize = self .map_height * self .map_width
92
+ self .mapSize = self .map_height * self .map_width
93
93
## the following parameters are only needed if minimaps have to be printed
94
94
minimapSize = ( self .map_width ,int (self .map_height ) )
95
95
self .minimap_image = cropped .resize (minimapSize , ANTIALIAS )
@@ -100,10 +100,10 @@ def __init__(self,replay):
100
100
imageCenter = [(self .map_width / 2 ), self .map_height / 2 ]
101
101
# this is the scaling factor to go from the SC2 coordinate
102
102
# system to pixel coordinates
103
- self .image_scale = float (self .map_height ) / cropsize [0 ]
103
+ self .image_scale = float (self .map_height ) / cropsize [0 ]
104
104
self .transX = imageCenter [0 ] + self .image_scale * (mapCenter [0 ])
105
105
self .transY = imageCenter [1 ] + self .image_scale * (mapCenter [1 ])
106
-
106
+
107
107
def radius_to_map_positions (self ,radius ):
108
108
## this function converts all radius into map coordinates
109
109
## centred around the origin that the creep can exist
@@ -142,7 +142,7 @@ def add_to_list(self,player_id,unit_id,unit_location,unit_type,event_time):
142
142
def remove_from_list (self ,unit_id ,time_frame ):
143
143
## This function searches is given a unit ID for every unit who died
144
144
## the unit id will be searched in cgu_gen_units for matches
145
- ## if there are any, that unit will be removed from active CGUs
145
+ ## if there are any, that unit will be removed from active CGUs
146
146
## and appended as a new time frame
147
147
for player_id in self .creep_gen_units :
148
148
length_cgu_list = len (self .creep_gen_units [player_id ])
@@ -179,12 +179,12 @@ def reduce_cgu_per_minute(self,player_id):
179
179
cgu_time_per_player_new .append (self .creep_gen_units_times [player_id ][cgu_max_in_min_index ])
180
180
last_minute_found = cgu_time / 60
181
181
cgu_last_minute_list = list ()
182
-
182
+
183
183
self .creep_gen_units [player_id ] = cgu_per_player_new
184
184
self .creep_gen_units_times [player_id ] = cgu_time_per_player_new
185
185
186
186
def get_creep_spread_area (self ,player_id ):
187
- ## iterates through all cgus and and calculate the area
187
+ ## iterates through all cgus and and calculate the area
188
188
for index ,cgu_per_player in enumerate (self .creep_gen_units [player_id ]):
189
189
# convert cgu list into centre of circles and radius
190
190
cgu_radius = map (lambda x : (x [1 ], self .unit_name_to_radius [x [2 ]]),\
@@ -209,7 +209,7 @@ def cgu_radius_to_map_positions(self,cgu_radius,radius_to_coordinates):
209
209
point = cgu [0 ]
210
210
radius = cgu [1 ]
211
211
## subtract all radius_to_coordinates with centre of
212
- ## cgu radius to change centre of circle
212
+ ## cgu radius to change centre of circle
213
213
cgu_map_position = map ( lambda x :(x [0 ]+ point [0 ],x [1 ]+ point [1 ])\
214
214
,self .radius_to_coordinates [radius ])
215
215
total_points_on_map = total_points_on_map | Set (cgu_map_position )
0 commit comments