Browse Source

minor fix

olinox 6 năm trước cách đây
mục cha
commit
0821cca8ba
1 tập tin đã thay đổi với 8 bổ sung8 xóa
  1. 8 8
      carribean/script.py

+ 8 - 8
carribean/script.py

@@ -8,15 +8,11 @@ import sys
 
 # TODO:
 # * add an esquive manoeuvre / try to avoid cannonballs
-# * compute first and second target instead of only one to anticipate the next move
 # * if an enemy is near a mine, shoot the mine instead of the ship
-# * compute the probabilities of presence of an ennemy on different coords at next turn
 # * find a way to change direction without slowing down if possible
 # * avoid getting blocked by a side-by-side with an ennemy
 # * priorize targetting blocked ennemies
 
-# * Fix shooting_spot() method
-
 debug = True
 
 def log(*msg):
@@ -267,13 +263,17 @@ class Grid(Base):
             
             # avoid cells too close from borders
             if not (3 <= x <= (self.w - 3) and 3 <= y < (self.h - 3)):
-                interest += 10
+                interest += 30
+            
+            diff = Grid.direction_to(*ship.prow, x, y)
+            interest += 10 * abs(diff)
             
             # priorize spots at distance 5 from active ship
-            interest -= 20 * abs(5 - self.manhattan((x, y), ship.pos))
+            interest += (10 * abs(5 - self.manhattan((x, y), ship.pos)))
             
             shooting_spots.put((x, y), interest)
-
+            
+        log(shooting_spots.items)
         return shooting_spots.get()
     
     # geometrical algorithms
@@ -944,7 +944,7 @@ while True:
                 after_that.put(obj)
                 
             if after_that:
-                s.objective_next = after_that.get()
+                ship.objective_next = after_that.get()
             
                 ship.path += grid.path(ship.goto, 
                                        ship.path[-1].orientation,