|
|
@@ -355,14 +355,14 @@ class Grid(BaseClass):
|
|
|
k0_position = 50
|
|
|
k_position_distance = 10
|
|
|
k_position_heat = -2
|
|
|
- k_position_danger = 5
|
|
|
+ k_position_danger = 10
|
|
|
k_position_advantage = 10
|
|
|
|
|
|
cult_leader = self.cult_leader()
|
|
|
opponent_cult_leader = self.opponent_cult_leader()
|
|
|
|
|
|
- log(self.obstacles + [u.pos for u in self.allied_cultists()])
|
|
|
- log([n.pos for n in self.neutrals()])
|
|
|
+ # log(self.obstacles + [u.pos for u in self.allied_cultists()])
|
|
|
+ # log([n.pos for n in self.neutrals()])
|
|
|
|
|
|
# compute conversion paths
|
|
|
conversion_path = []
|
|
|
@@ -372,11 +372,12 @@ class Grid(BaseClass):
|
|
|
key=(lambda pos: pos in self.index and self.index[pos].neutral),
|
|
|
limit=min(4, len(self.neutrals()))
|
|
|
)
|
|
|
- log(conversion_path)
|
|
|
+ # log(conversion_path)
|
|
|
|
|
|
# Conversion des neutres
|
|
|
if cult_leader and conversion_path:
|
|
|
path = conversion_path.next_candidate()
|
|
|
+ log(path)
|
|
|
if path:
|
|
|
targets = [self.index[c] for c in path[-1].candidates]
|
|
|
|
|
|
@@ -401,6 +402,7 @@ class Grid(BaseClass):
|
|
|
for a in self.allied_cultists():
|
|
|
for u in targets:
|
|
|
shooting_distance = self.shooting_distance(a.pos, u.pos)
|
|
|
+ log(f"{a.id} - {u.id} - {self.line(a.pos, u.pos)[1:]}")
|
|
|
if shooting_distance and shooting_distance < u.SHOOTING_RANGE:
|
|
|
action = ActionShoot(a, u)
|
|
|
|
|
|
@@ -414,19 +416,20 @@ class Grid(BaseClass):
|
|
|
# on garde les trois points les plus chauds
|
|
|
hot_spots = sorted(self.heat_map.items(), key=lambda p: p[1], reverse=True)[:3]
|
|
|
|
|
|
- # results = self.discover(a.pos, key=lambda x: x in [s[0] for s in hot_spots])
|
|
|
+ results = self.discover(a, key=lambda x: x in [s[0] for s in hot_spots], limit=3)
|
|
|
|
|
|
- # for path, target_pos in results:
|
|
|
- # if not path:
|
|
|
- # break
|
|
|
+ for path, target_pos in results:
|
|
|
+ if not path:
|
|
|
+ break
|
|
|
+
|
|
|
+ heat = self.heat_map[target_pos]
|
|
|
|
|
|
- for spot_pos, heat in hot_spots:
|
|
|
priority = k0_position
|
|
|
priority += k_position_heat * heat
|
|
|
- priority += k_position_distance * self.manhattan(a.pos, spot_pos)
|
|
|
- priority += k_position_danger * self.threat[spot_pos]
|
|
|
+ priority += k_position_distance * len(path)
|
|
|
+ priority += k_position_danger * sum(self.threat[p] for p in path)
|
|
|
|
|
|
- action = ActionMove(a, spot_pos, f'pos on {spot_pos}')
|
|
|
+ action = ActionMove(a, path[0], f'go for hotspot {target_pos} by {path}')
|
|
|
|
|
|
actions.put(priority, action)
|
|
|
|
|
|
@@ -520,7 +523,7 @@ class Grid(BaseClass):
|
|
|
result.append((y_, x_) if vertically_oriented else (x_, y_))
|
|
|
|
|
|
offset += alpha
|
|
|
- if offset > 0.5:
|
|
|
+ if offset > 0.51:
|
|
|
y_ += step
|
|
|
offset -= 1.0
|
|
|
|
|
|
@@ -599,8 +602,8 @@ class Grid(BaseClass):
|
|
|
log(f"<!> discovery broke, {len(paths)} results")
|
|
|
return paths
|
|
|
|
|
|
- if key(pos):
|
|
|
- path = current.ancestors[:-1:-1] + [current] # reverse ancestors after having removed the start
|
|
|
+ if current != unit.pos and key(pos):
|
|
|
+ path = current.ancestors[1:] + [current]
|
|
|
paths.append((path, pos))
|
|
|
|
|
|
if len(paths) >= limit:
|
|
|
@@ -613,7 +616,7 @@ class Grid(BaseClass):
|
|
|
if not self.can_move_on(unit, pos):
|
|
|
continue
|
|
|
|
|
|
- node = DiscoveryNode(*pos, current.ancestors + [current])
|
|
|
+ node = DiscoveryNode(*pos, 0, current.ancestors + [current])
|
|
|
nodes.append(node)
|
|
|
return paths
|
|
|
|
|
|
@@ -711,6 +714,7 @@ GRID.obstacles = [(x, y) for y, row in enumerate(obstacles_input) for x, val in
|
|
|
GRID.pre_compute()
|
|
|
|
|
|
while 1:
|
|
|
+ # TODO: le bresenham est à revoir pour les tirs...
|
|
|
# TODO : en cas de choix entre plusieurs neutres à convertir, privilégier un neutre se trouvant entre un ennemi et le leader
|
|
|
# TODO: Laisser l'algo de découverte des cibles à convertir passer outre les alliés, ajouter une action "dégager le passage" pour ces unités
|
|
|
# (prévoir le cas où cet allié ne peut pas se dégager). Le fait de passer outre un allié doit augmenter le coût de mouvement de 1
|
|
|
@@ -744,6 +748,4 @@ while 1:
|
|
|
log(f"exec : {action}")
|
|
|
|
|
|
action.exec()
|
|
|
- GRID.round += 1
|
|
|
-
|
|
|
-
|
|
|
+ GRID.round += 1
|