CBAI Issues
I decided to actually take a look at the CBAI code and sort of figured out some of what is causing bad behavior.
1: Constructors going in circles.
The IsTargetReachable function produces a bunch of intermediate waypoints to the build site which very often end up in nonsensical locations (for example in the opposite direction). This leads to units moving between two waypoints without ever going to a job. I can't figure out how those waypoints get added to the order array, however, so I don't know how to safely remove them. I assume that telling the constructor to move directly to the build site would use normal unit pathing AI, and should work fine, but I don't know that to be a fact.
2: Constructors mobbing on jobs. For example, if you have 2 cons and queue a mex and a solar right next to each other, you still get both cons mobbing on the solar or mex instead of assigning 1 cons to each.
The way jobs are assigned is kind of silly, but also kind of smart. Each reachable job is more or less given a priority relative to the selected worker and then the highest prio job is chosen. Workers already assigned to a given job are also accounted for, but the way priorities are determined is kind of derp. A more straightforward approach would be to give each job a weight equal to:
distance to job * (number of workers already assigned to that job + 1)
then choose the job with the lowest weight. I think the complexity of that would be about the same as it is now, too.
3: Constructors won't get assigned to new jobs once they're already assigned to a job, even if the newly added job is (much) closer.
Note that the general complexity of job assignment is num.workers * num.jobs, so you have to limit the rate at which constructors are reassigned so as to avoid pathological performance. I can see that there's already been an attempt to make some compensation for this, but it fails to account for common cases (ie queueing a job right next to a mob of workers that want to run across the map to some other job). Jobs need to be re-weighted more frequently, somehow or other.
4: Workers suiciding into enemy units/porc.
I haven't had any real trouble with this, but I did find out after looking at the code that it's supposed to automagically remove jobs that fall into enemy-controlled territory. However, I've never seen it actually do this, probably because either the radius is set too small for it, or the %enemy threshold is set too high. This one is harder to test, but easy to adjust. It might also be good to test that code in general and make sure it's actually working properly.
What is CBAI?
I think he means CAI.
No, Central Build AI.
https://github.com/ZeroK-RTS/Zero-K/blob/master/LuaUI/Widgets/unit_central_build_AI.lua http://zero-k.info/Battles/Detail/319067
1: Constructors going in circles.
Constructors running in circles even with direct build command (tested with C++ AI). Possibly an engine bug or a game bug elsewhere.
2: Constructors mobbing on jobs.
More mobbing = faster construction. Mobbing is good, but should be constrained (also) by something like target_cost/used_build_power ratio.
Is anybody tweaking this widget right now? If not, I'm going to try the following:
-
Test possible fix for "Worker suiciding into porc" (issue 4) existing code couldn't understand porc line, so any order behind enemy porc will not be removed and never set to lower priority. I want to try a cheapest solution by imitating ant: if outgoing worker died then the build order get low priority. This is less complex solution than making "heatmap".
-
Figure out if worker can be automatically reassigned to closer job it sound good that worker should stop walking to distant job and go to vacant nearest job instead.
3)Evaluate mobbing whether mobbing is that not that bad or is fixed by no.2 or I really need to implement the suggested stuff.
Progress: finished coding, will try on real game before doing Pull Request
almost finish (not commit yet). Final added feature should be:
- cons can reassign job between job and while constructing
- not much mobing, but still mob for expensive building
- add 4 state to display: "queu, help, busy, idle" (instead of just "cb, busy, idle")
- will keep queue of unfinished nanoframe (so Cons can return and finish it)
Some cleanup of code. Will try to not make regression (create more bad/deletion of behaviour than addition)
- cons can reassign job between job and while constructing
Awesome, but make absolutely certain that it doesn't override player commands!
- not much mobing, but still mob for expensive building
I thought of that, but I don't think building cost would scale well with distance numerically. I think it might be better to leave that to manual micro when needed, which isn't often anyway. Expensive jobs also tend to get mobbed simply because they outlive other jobs, too.
- add 4 state to display: "queu, help, busy, idle" (instead of just "cb, busy, idle")
Awesome.
- will keep queue of unfinished nanoframe (so Cons can return and finish it)
This would fix at least one issue that I do run into fairly regularly. Helps a lot if you have to interrupt your cons for something, like raiders.
Two other things I've thought of that are fairly important. One is that area reclaim doesn't get split up and added to the que like other things. You have to directly tell workers to reclaim, which sucks. The other thing, which is related, is that I think area reclaim and area mex should automatically get split up and added to the queue even if shift is not held. For those things direct orders produce bad behavior anyway, and I think it would save hassle overall.
hello! the change was merged in current stable, thanks for your suggestion :)
I also think that a widget shouldn't override user command, I have tested and tweaked CBA to make sure it didn't override user's command (hopefully!).
i'm closing this Issue now so that other issue can be attended to. (it is not deleted and can referenced again later)
Also I think we must keep SHIFT with Area-mex because we need to respect the functionality provided by Area-mex widget, and the idea about Area-reclaim split will be for different widget.
Thank you!