Notes for putting this in your level
1. This COMPLETELY REPLACES the first version of Infected AI. It's definitely not recommended to use them both in the same level.
2. This AI will control as many factions as you want it to. You don't need to paste multiple copies of the code or anything like that - the ability to control multiple empires and have them fight the player and each other is a key feature of the new version. All you need to do to have multiple AIv2 factions in your level, is to create asteroids for players 2, 3, 4, 5, etc (whichever ones you want), and give their asteroids some seeds and/or dyson trees. If an asteroid belongs to one of these empires and has at least 10 seeds or 1 dyson tree on it, the AI will start controlling it. See the discussion near the bottom of the first page of this thread for more details.
3. The AI should notice if under attack from a player mine. (untested) However, mines for all other factions are currently ignored. AIv2 does not currently handle its own flowers or mines in any way.
4. Currently the AI engine constantly renames all of the asteroids on the map to whatever the metric number of that asteroid is. The metric number is what is used to determine the path seedlings should take to get where they are needed. Being able to see at a glance what metric a particular asteroid has is a huge help with troubleshooting the AI engine, so I decided to leave this in for the beta version.
- Partitions with only fully-built friendly neighbours but no enemy neighbours or blank neighbours, keep all their asteroids on metric 500, rather than grouping their seeds up or shuffling them around somehow. This is somewhat of an issue on maps with moving asteroids.
- EFFICIENCY: Regarding the code for sending the seeds to the next lowest metric. Currently, the check to see if this is a player asteroid is nested deep inside the For loops. This is inefficient; a better way would be to carry out the check right at the start of the "Send Seeds To Next Lowest Metric" code, and simply not bother running any of the code if checkedroid.owner == 1 or 0. - EFFICIENCY: As above, but for the "launch attack" code. It might be easiest to simply include a giant If Statement that rules out any actions being carried out if checkedroid is a player asteroid. This is conceptually the easiest way to understand it as well, and would remove some detail from the complicated For loops inside the actions section.
EFFICIENCY: Found some erroneous code that doesn't need to be there. It talks about "gatherpointsallowed" and carries out some checks to set a variable of the same name. However, the variable is never used, so this just represents precious clock cycles going to waste.
Treeless asteroids belonging to player 0 are eroneously considered "friendly" asteroids even when there are actually greys present at the asteroid. The naive AI sends his 10 colonising seeds there, and they get slaughtered. :P
Adjacent single-asteroid partitions belonging to different empires both become gather points, and can reach a situation where one reaches the spawncap, but does not attack because the other orphan asteroid has almost as many seedlings. I need a special trap for this situation to get the orphans to attack when they reach their spawn cap.
After capturing an asteroid, its gather metric is reset to 500. I have seen some cases where this causes seedlings on the newly captured planet to instantly fly back to the gather point (which has metric 200). A better solution would be to set newly captured asteroids to a metric of 200. This would cause them to become gather points, meaning the seed army would stick around. If they aren't valid as gather points they will be changed anyway on the next cycle. By removing the OnAsteroidTaken, set metric to 500 code, now when asteroids are taken they start with a metric of 0. Nearby seeds will flood in to reinforce. 0 will be re-evaluated shortly thereafter and reset.
- In very action-packed games, the AI will wander about responding to attacks of 50 seedlings with a swarm of 2000. This is excessive - the AI should make better use of these.
- Ability to detect seedlings in flight
- When sending seeds to a neighbour, ability to tell if another (enemy) asteroid is in the way, whose seeds might snipe the travellers on the flyby.
Ability to detect flowers, and plant them to make super seedlings and/or mines.
- Detect enemy AI mines as well as player mines
It would be nice if the AI could recognise when he is already attacking, and send the reinforcements as they arrive at the gather point.