olinox14 преди 3 години
родител
ревизия
81bd6fed81
променени са 1 файла, в които са добавени 16 реда и са изтрити 5 реда
  1. 16 5
      fall2022/fall2022.py

+ 16 - 5
fall2022/fall2022.py

@@ -299,6 +299,8 @@ class Grid(BaseClass):
         self.index_threats = {}
         self.index_nearest_enemy = {}
 
+        self.path_cache = {}
+
     @property
     def grid(self):
         return [[self.cells[(x, y)] for x in range(self.width)] for y in range(self.height)]
@@ -756,8 +758,9 @@ class Grid(BaseClass):
         k_position_opponents = -5000
         k_position_destroy = -3000
         k_dist_to_enemy = 1000
-        k_colonize = -3000
-        k_expand = -800
+        k_colonize = -5000
+        k_consolidate = -2000
+        k_expand = -600
         k_threat = -1500
         ki = 0  # little hack to avoid the while in queue.put
 
@@ -823,11 +826,19 @@ class Grid(BaseClass):
                     priority = order.priority
                     priority += k_position_distance * dist
 
-                    if self.me.side == Player.SIDE_WEST and order.pos[0] >= unit.pos[0] \
-                            or self.me.side == Player.SIDE_EAST and order.pos[0] <= unit.pos[0]:
-                        priority += k_colonize
+                    if contig.status == Contig.CONFLICTUAL:
+                        # advance
+                        if self.me.side == Player.SIDE_WEST and order.pos[0] > unit.pos[0] \
+                                or self.me.side == Player.SIDE_EAST and order.pos[0] < unit.pos[0]:
+                            priority += k_colonize
+
+                        # consolidate the frontline
+                        if self.me.side == Player.SIDE_WEST and order.pos[0] == unit.pos[0] \
+                                or self.me.side == Player.SIDE_EAST and order.pos[0] == unit.pos[0]:
+                            priority += k_consolidate
 
                     candidate = MoveOrderCandidate(order, unit, destination)
+
                     q.put(priority, candidate)
 
             # for priority, candidate in sorted(q.items, key=lambda x: x[0])[:18]: