Lane Data System for AI - Winds of War
Disclaimer: “Winds of War” is in active development, showcased features are not finalized.
The lane data system is a self-contained blueprint “BP_LaneManager” which offers expanded AI decision making. The core purpose of it is to keep track of combat balance: unit counts & unit power values. The lane manager has 8 distinct lanes which covers the entire playfield and several arrays (with indexes that correspond to each lane) are updated as units spawn in, change lanes, or are removed.
In the AI spawner’s behavior tree, a task is ran which calls an event from the AI controller to determine the next spawn location of units. This location determination event has a logic switch that reads from the enumeration “E_Strategy”. (Explained further later)
When units are spawned, a line trace is ran every 3 seconds on a looped timer to add their data to whichever lane they’re currently in, referencing the lane manager. They’ll add +1 to that lane’s unit count for their side (left/right) and likewise with their power value (how much damage is dealt to the enemy base when reached).
The lane’s values are then updated and balance between both sides are calculated. These balance calculations uses the right lane as reference and is mapped between 0 - 1. 0 meaning it favors the left side (blue), 1 favors the right (red), .5 is neutral (purple). The basic formula is as follows:
Gets the current sum of power values from each side for specified lane (set before this function is called). Checks if power = 0, this would occur if no units are currently in that lane - if true, then set lane power balance to .5 (neutral). If the power > 0, divide the right side’s power value by the sum of the right & left value. So, if the right side’s power was 35 and the left’s was 0, the lane power balance would be 35/35 = 1 (favors right side). If the right side’s was 50 and the left’s was 100, the lane power balance would be 50/150 = .33 (slightly favors left side).
The 3 strategies are as follows:
Random: Choose a random X value in world space (up/down) within the level’s bounds.
Random + Unit Count: If unit count balance disfavors the AI by a certain threshold within a lane ( <= .35), choose that lane to spawn units in next. If the threshold isn’t reached in any lane, choose a random location.
Random + Power Balance: If power balance disfavors the AI by a certain threshold within a lane ( <= .35), choose that lane to spawn units in next. If the threshold isn’t reached in any lane, choose a random location.
Here are 3 videos showcasing each strategy in use by the AI. The AI is spawning units from the right side and the blue line trace shows the current position of the AI spawner, with green being the player spawner:
Here’s a short video showcasing the lanes updating when a unit is manually moved between them: