@@ -50,14 +50,20 @@ def __init__(self, options=None):
50
50
self .viewradius = int (options ["viewradius2" ])
51
51
self .attackradius = int (options ["attackradius2" ])
52
52
self .spawnradius = int (options ["spawnradius2" ])
53
+ print ("Starting game with view=%s, attack=%s and spawn=%s" % (self .viewradius , self .attackradius , self .spawnradius ))
53
54
self .do_attack = self .do_attack_closest
54
55
if 'attack' in options :
55
56
if options ['attack' ] == 'occupied' :
56
57
self .do_attack = self .do_attack_occupied
57
58
elif options ['attack' ] == 'closest' :
58
59
self .do_attack = self .do_attack_closest
59
- self .render = self .render_changes
60
60
self .do_food = self .do_food_sections
61
+ if 'food' in options :
62
+ if options ['food' ] == 'none' :
63
+ self .do_food = self .do_food_none
64
+ elif options ['food' ] == 'sections' :
65
+ self .do_food = self .do_food_sections
66
+ self .render = self .render_changes
61
67
62
68
self .width = None # the map
63
69
self .height = None
@@ -154,7 +160,7 @@ def distance(self, x1, y1, x2, y2):
154
160
d_y = min (abs (y1 - y2 ), self .height - abs (y1 - y2 ))
155
161
return d_x + d_y
156
162
157
- def get_vision (self , player , radius = 96 ):
163
+ def get_vision (self , player ):
158
164
vision = [[False for col in range (self .width )] for row in range (self .height )]
159
165
squaresToCheck = deque ()
160
166
for row , col in self .player_ants (player ):
@@ -168,7 +174,7 @@ def get_vision(self, player, radius=96):
168
174
d_row = min (d_row , self .height - d_row )
169
175
d_col = abs (a_col - n_col )
170
176
d_col = min (d_col , self .width - d_col )
171
- if not vision [n_row ][n_col ] and (d_row ** 2 + d_col ** 2 ) <= radius :
177
+ if not vision [n_row ][n_col ] and (d_row ** 2 + d_col ** 2 ) <= self . viewradius :
172
178
vision [n_row ][n_col ] = True
173
179
if not self .revealed [player ][n_row ][n_col ]:
174
180
self .turn_reveal [player ].append ((n_row , n_col ))
@@ -180,8 +186,8 @@ def get_vision(self, player, radius=96):
180
186
squaresToCheck .append (((a_row ,a_col ),(n_row ,n_col )))
181
187
return vision
182
188
183
- def get_perspective (self , player , radius = 96 ):
184
- v = self .get_vision (player , radius )
189
+ def get_perspective (self , player ):
190
+ v = self .get_vision (player , self . viewradius )
185
191
#start_row = self.center[player][1] - self.height // 2
186
192
#stop_row = start_row + self.height
187
193
#start_col = self.center[player][0] - self.width // 2
@@ -350,7 +356,7 @@ def do_spawn(self):
350
356
new_ants = {}
351
357
for f_row , f_col in self .food_list [:]:
352
358
owner = None
353
- for (n_row , n_col ), n_owner in self .nearby_ants (f_row , f_col , None , 1 , 9 ):
359
+ for (n_row , n_col ), n_owner in self .nearby_ants (f_row , f_col , None , 1 , self . spawnradius ):
354
360
if owner == None :
355
361
owner = n_owner
356
362
elif owner != n_owner :
@@ -371,7 +377,7 @@ def do_attack_occupied(self):
371
377
score = [Fraction (0 , 1 ) for i in range (self .num_players )]
372
378
for (a_row , a_col ), a_owner in self .ant_list .items ():
373
379
killers = []
374
- enemies = self .nearby_ants (a_row , a_col , a_owner , 1 , 2 )
380
+ enemies = self .nearby_ants (a_row , a_col , a_owner , 1 , self . attackradius )
375
381
occupied = len (enemies )
376
382
for (e_row , e_col ), e_owner in enemies :
377
383
e_occupied = len (self .nearby_ants (e_row , e_col , e_owner , 1 , 2 ))
@@ -396,7 +402,7 @@ def find_enemy(row, col, owner, min_d, max_d):
396
402
if not (n_row , n_col ) in ant_group :
397
403
ant_group [(n_row , n_col )] = n_owner
398
404
find_enemy (n_row , n_col , n_owner , min_d , max_d )
399
- for distance in range (1 , 10 ):
405
+ for distance in range (1 , self . attackradius ):
400
406
for (a_row , a_col ), a_owner in self .ant_list .items ():
401
407
if self .map [a_row ][a_col ] != LAND :
402
408
ant_group = {(a_row , a_col ): a_owner }
@@ -496,6 +502,9 @@ def find_closest_land(self, coord):
496
502
497
503
return None
498
504
505
+ def do_food_none (self , amount = 0 ):
506
+ pass
507
+
499
508
def do_food_random (self , amount = 1 ):
500
509
"""
501
510
Place food randomly on the map
0 commit comments