@splitice
1 - Re % of an AI's time taken on different areas, It will vary depending on the AI and the approach taken, although at a high level I'd expect pathfinding to take up a lot of time at the start of game, and build conditions to take up minimal time throughout the game.
For example with pathfinding, for a while my AI would calculate if it could path somewhere as and when it needed to (and then record the result so it could refer to later), but more recently it will do the calculations up-front, which is consistent with the approach of the other AI I'm aware. Times taken can vary dramatically - e.g. when Balthazar was testing their pathfinding logic, I think the slowest time they came across was on Alaska (which I'm guessing was an 81km map) where it took more than 5m. Softles mentioned their pathfinding after optimisation is down to 0.4s on smallest maps. Map size has a big impact though, since an 81x81km map is 262 times the size of a 5km map, so if you do things to the same level of accuracy the time taken will skyrocket.
Therefore pathfinding is largely a 1-off cost at the start of the game (where it's more acceptable to have a slight delay before the game actually starts), although there'll still be some overhead later on (e.g. if trying to calculate a safe path to use - I dont use this logic at the moment so can't comment on how much time it takes).
The most useful function for working out the CPU performance impact is GetSystemTimeSecondsOnlyForProfileUse()
If you compare the result before and after a 'heavy duty' function you can get an indication of how long that function takes (although the figure isn't that reliable).
In the latest version I'm working on I'll be including lots of comments and profiler outputs from some profiling I did of my own AI in an effort to improve its CPU performance, and the code for this as well as code Softles recently helpfully shared on the AI discord for profiling will be included as part of the AI.
As a very rough guide though, anything that is running >10k times in a single tick needs to be streamlined to avoid a performance impact. Simple checks like if a variable is true or false take up no noticeable time (you'd need to be checking millions of times in a tick I'd have thought to impact things), while more involved checks such as getting all units of a particular category within a certain distance of a point on the map will take far longer.
Examples of things that can end up overloading a tick could be carrying out logic on every part of the map (e.g. calculating reclaim), or recursive logic (e.g. in v14 and earlier I'd recursively look for units around an existing unit, and then units around those, and so on, in order to group them into an 'army' to be dealt with).
To give a rough idea of the relative weightings for M27 (other AI will be different) for different aspects of the AI, the following benchmarks are for the total time taken in the first 10m of a 3v3 M27AI game on a 10km map (WIP v15):
- Determining pathing at the start of the game c.4.5s
- telling platoons what to do 8.5s
- threat detection logic (identify enemy threats, selecting units to deal with the threat) 3.7s
- checking reclaim on the map 3.3s
- managing air units 2.6s
- managing engineers (build conditions and orders including reclaim) 1.7s
- Deciding what to build for factories 0.1s.
As part of this, I have a function called 200k times that took 0.000s in total, and another function called 165 times that took 0.36s.
The times are a relative guide, not absolute, as the GetSystemTimeSecondsOnlyForProfileUse() isn't that accurate, and depending on how its used it won't factor in time taken by the wider game engine as a consequence of the AI's code.
2 - Not in the immediate future, but probably once I've achieved some other goals. I think Softles may be planning an AI tournament with norush at some point so that might prompt me to have a look at it!