olinox преди 6 години
родител
ревизия
65f6bae5c5
променени са 1 файла, в които са добавени 6 реда и са изтрити 11 реда
  1. 6 11
      carribean/script.py

+ 6 - 11
carribean/script.py

@@ -7,11 +7,9 @@ import sys
 
 
 # TODO:
-# * add an esquive manoeuvre / try to avoid cannonballs
 # * if an enemy is near a mine, shoot the mine instead of the ship
 # * find a way to change direction without slowing down if possible
 # * avoid getting blocked by a side-by-side with an ennemy
-# * improve the 'avoid' part of the 'fire_at_will' method
 # * use a queue to choose the best shoot instead of a strict equality
 # * why do mines explode when turning around?
 
@@ -650,7 +648,11 @@ class Ship(Entity):
                 # next pos with inertia
                 inertia = Grid.next_cell(*pos, d, repeat=speed)
                 
-                # wait (or fire or mine)
+                # wait (doubled)
+                positions[i + 1].append(Position(inertia, d, speed))
+                positions[i + 1].append(Position(inertia, d, speed))
+                
+                # fire or mine
                 positions[i + 1].append(Position(inertia, d, speed))
                 
                 # turn left
@@ -736,12 +738,6 @@ class Ship(Entity):
             else:
                 log(f"(!) broken: can not move")
                 return False
-#             if self.can_move():
-#                 
-#                 self.auto_move(*self.goto)
-#                 return True
-#             else:
-#                 return False
         elif not path:
             return False
         
@@ -764,8 +760,6 @@ class Ship(Entity):
             new_pos = self.get_next_cell(new_speed)
             new_area = self.get_area(*new_pos, new_orientation)
     
-            log([(c, self.moving_cost(*c)) for c in new_area])
-    
             # special: extra-grid cells are not consider as collisions since a part of the ship can go there
             if any((self.moving_cost(*c) >= 1000 and c in grid) for c in new_area):
                 log(f"/!\ Danger: planned move <{Ship.COMMANDS[move]}> would lead to collision")
@@ -857,6 +851,7 @@ class Ship(Entity):
             avoid += ally.mobility_zone
         
         next_positions = target.guess_next_positions(in_=4)
+        log(next_positions)
         for t, next_pos in next_positions.items():
             dist = Grid.manhattan(self.prow, next_pos)
             if dist > self.SCOPE: