|
|
@@ -927,6 +927,7 @@ while True:
|
|
|
|
|
|
todo = []
|
|
|
abandonned = []
|
|
|
+
|
|
|
while player.can_act():
|
|
|
|
|
|
q = InterestQueue()
|
|
|
@@ -946,7 +947,9 @@ while True:
|
|
|
|
|
|
objective = q.get()
|
|
|
if type(objective) is Defend:
|
|
|
- if player.current_gold > Building.cost[Building.TOWER] and not objective.cell.mine_site:
|
|
|
+ if player.current_gold > Building.cost[Building.TOWER] \
|
|
|
+ and not objective.cell.mine_site \
|
|
|
+ and not objective.cell.building:
|
|
|
action = BuildTower(objective.cell)
|
|
|
|
|
|
else:
|
|
|
@@ -969,6 +972,18 @@ while True:
|
|
|
action = Train(objective.min_level, objective.cell)
|
|
|
|
|
|
log(f"priority: {action} -> {objective}")
|
|
|
+ already_there = action.cell.unit
|
|
|
+ if already_there and already_there.owned:
|
|
|
+ log(f"* needs to evacuate unit {already_there.id_} before")
|
|
|
+ evacuate = grid.get_next_move(already_there)
|
|
|
+ if evacuate:
|
|
|
+ evac_action = Move(already_there, evacuate.cell)
|
|
|
+ log(f"forced: {evac_action}")
|
|
|
+ grid.apply(evac_action)
|
|
|
+ todo.append(evac_action)
|
|
|
+ else:
|
|
|
+ log(f"<!> No move available for unit {already_there.id_}")
|
|
|
+
|
|
|
grid.apply(action)
|
|
|
todo.append(action)
|
|
|
|
|
|
@@ -982,7 +997,7 @@ while True:
|
|
|
grid.apply(action)
|
|
|
todo.append(action)
|
|
|
else:
|
|
|
- log(f"<!> No move available for {unit}")
|
|
|
+ log(f"<!> No move available for unit {already_there.id_}")
|
|
|
|
|
|
# can build mines?
|
|
|
if player.current_gold > grid.cost_for_new_mine():
|