Zones of interest:
Each mex is interesting
The closer it is to other mexes or the more metal it has, the more it is interesting (dual-mexes, triplets)
The AI should either try to kill the metal economy, the energy economy or the build power economy, dependend on the mod.
Kill constructors in EVO-RTS is useless, while killing nano towers in Zero-K and *A games is good (no wreckages, very valueable, low health, chain reacting)
The AI could use units with a low projectile speed against static targets as they are usually meant to kill statics. Against units, it can try to use the best units with HP*DPS*maxVelocity*range
- If the units not make cost, use the opposite units or choose another strategy/target.
Always try to mix units in weight classes, range, AOE, AA, etc, although there can be a dominant unit type in an army.
It should not repeat the same recent strategies if there are other strategies which it can try - except the last one was very successful (made many times cost by killing enemy stuff).
If threads belong to the same group (scouting attacking), (eco-building, unit-building) the weights between this entries could change based on success (resources spent, resources destroyed/gained).
There could be 2 scouting threads - one which tries to coordinate defense, and one which tries to find attack targets.
The more the AI is splitted into modules, the easier it will be to debug and code.
Players often make statics to defend the economy against scouts, but the AI only need statics if static defense is much better AND there are stealthy units (what does the enemy do, what does the mod provide?).
Else the AI can make anti-scout units with high speed and a good range (if there are good units for that purpose) to react to radar blips faster, than players can do it.
If there is a good point to defend, try to get static defense and units - the ratio is dependent on how good defense in this mod is and how much control points the AI need to defend.
If the control points are too far away from each other to react to radar blips properly, prefer raiding instead of defending a bit more.
If you want a human-like AI, limit the number of strategies which can be processed at once, limit the number of reactions per second to the highest priorised treats, etc.
The simpliest human-like AI contains a memory which stores relations (player => (strategy1(success%), strategy2(success%) ), (economy => (buildRadars(), defendAgainstScouts() )).
Whenever a task is running, this task calls all related tasks, whenever something is successfully, it repeats itself by a chance.
Code: Select all
// avoid infinite task instances ( generate less new instances if you already have many instances running ).
event runTask( task )
task.counter +1
if task.counter > task.instances
task.counter = 0
task.startNewInstance
end
end
event endTask( task, successRatio )
task.repeatCounter + task.repeatChance*successRatio
while task.repeatCounter > 1 // 100%, ...
task.repeatCounter -1
runTask( task )
end
end
Each watchRadar() thread starts a buildRadar() thread which fill out gaps in your los as long as you have enough builders and don't spam radars where you cannot protect them.
If watchRadar is successful ( give you important information ) it repeats or even multiply itself by an increased chance to get more watchRadar() threads and more buildRadar() threads.
buildRadars() either request an idle constructor or start a buildConstructor() thread, which increase the weight of constructors in your build queues.
If you have enough relations and good task.repeatChance settings, the most efficient thing get used most often.
Some tasks decay after a time and some tasks ends if they failed or succed with their goal.
And other tasks run only once and never end - they are there to ensure that at least some important tasks are always running from time to time.
If you want, you can let the AI forget about some least useful tasks if there are too many tasks running.