Up to this point, Project Nightfall’s computer-controlled opponent could gather resources, build up its base, and train an army — but it had no idea what to do with that army once it existed. Milestone 25 changes that: the AI can now fight.
Three questions, asked every second
Once per second, the AI’s decision-making runs through a simple priority order: retreat first, then defense, then offense.
- Retreat — any combat unit whose health drops below a set threshold pulls back toward home, unless it’s already close enough to home that retreating would just mean fleeing in place. In that case it stands and fights instead.
- Defense — if an enemy is spotted near the AI’s base, every idle unit in that radius, wounded or not, moves to intercept the nearest threat. While danger is present at home, the AI won’t simultaneously send units off on an attack.
- Offense — once the AI has enough healthy, idle units to clear a per-profile attack threshold, it groups them and sends the whole group toward the nearest enemy it can actually see, or a fallback rally point if nothing is visible yet.
Target selection uses the same fog-of-war visibility rules a human player is bound by, so the AI’s attacks are informed by what it can actually see, never by omniscient knowledge of the map.
Reusing what already worked
This milestone required no changes to the underlying combat, ordering, or visibility systems at all. The order type that auto-chases a target while still holding a destination — rather than committing to a fixed, fire-and-forget engagement — already existed from earlier combat milestones, fully wired and fog-gated. The AI simply issues the same commands a human player would, through the same channel. Using that reevaluating order type everywhere means units continually reassess their situation instead of getting locked into a doomed chase. It also means a hero unit fights, retreats, and defends exactly like any other unit — no special-cased “hero AI” was written, since the AI simply treats whatever units it owns the same way.
What playtesting caught
The first hands-on test didn’t go well for the human player: the AI’s starting force already met its attack threshold at the very first opportunity, and it stormed across the map before there was any time to observe the new behavior. The fix wasn’t to change the AI’s logic — it was behaving correctly — but to rebalance the test scenario itself, giving the AI a smaller starting force so it has to build up through its own economy first, mirroring the pacing of the previous economy milestone. On the second pass, the AI’s full loop — grow, mass an army, attack, defend, retreat when hurt — played out as intended.
This is still a basic combat AI: it fights only other units, not buildings, and once a unit retreats there’s no healing to bring it back into the fight. Both are natural next steps as the broader game systems mature.