Blake said:
I have done so.
Btw I seem to recall I forgot to answer a question from you amoungst all the spam on difficulty levels...
If you wish to offer ideas on how to improve the AI, on what they should do to utilize certain game features and so on, then you are welcome to. Even if something is "obvious", I may not have thought of it.
For example two of my more recent improvements were a result of posts by a player in my original thread at poly:
Hi, Blake.
I had noticed that you used the basic idea to improve something that was first suggested by kniteowl (I'm also following your thread on Apolyton and just noticed that you started another one. Still have to read that one.). I just didn't know in how far you would like suggestions. Before the above post, there weren't many suggestions for improvement of the AI. After the above post, you seem to have gotten a lot of them. I hope that you can handle the speed of this thread. It has already grown bigger than your thread(s) on Apolyton.
When I read that you are thinking about improving the combat AI, I thought I would like to present to you my vision on the subject. I hope that it can be of use. It's going to be a lengthy post and it might be too hard to implement. It's only a vision. It's not a perfect strategy because I try to consider the 'thinking' limits of the AI.
First of all, I would like to distinguish combat tactics and combat strategy. The first is about questions like, should I attack or not (unit A vs unit B), and principles like using hills and forests when approaching an enemy city and using catapults to weaken a large enemy stack. The second is about questions like, how many units do you need need to defend your territory and how should you distribute those units over your territory, how many units should attack the enemy and how many should be left for defence, should you attack civilization A or wait for more units. The first is connected with short term problems on a small scale, the second with long term problems on a large scale. The AI at present is bad at both. My post is about combat strategy.
One of the problems with the AI combat strategy is that it keeps a lot of units in cities that don't need defence and aren't threathened. It thinks these cities need garrisons of 8 or so units (especially the capital) while the enemy is conquering a border city defended by 2 units. The AI also sends all of its non-garrison troops to attack and leaves nothing for defence (or so it seems). If you defeat the attacking AI stack(s), then you only have to deal with the few units that are being produced while you attack the AI cities. The rest of the units stay in their cities while you walk from one city to the next. I even see the AI gathering units in a city for another assault on one of my cities while I am conquering cities (you can see that if there is a fleet present to transport the assault group).
My idea is that the AI should distribute its units in three groups. City garrison units, general defence units and attack units.
-
City garrison
The AI starts by calculating how many units are needed to defend a certain city, its city garrison. This should depend on elements like
-close to the border (does there exist a land tile on the same continent not of the AI's culture within 3 or 4 tiles)
-does it border on the ocean (cities bordering on the ocean are threatened by an amphibious attack)
-city size/importance
For instance:
base garrison: 1
Foreign culture within 1 tile (border directly next to the city): +5
Foreign culture within 2 tiles (only 1 tile between the city and the foreign culture): +3
Foreign culture within 3 tiles: +2
Foreign culture within 4 tiles: +1
(maybe other values for no culture tiles at the start of the game or when conquest is occuring)
City bordering on ocean: +1
(If the city is bordering on ocean and close to foreign culture, then pick largest of both values)
City size 10+ and bordering on ocean or close to foreign culture: +1
City size 15+: and bordering on ocean or close to foreign culture: +2
small wonder present and bordering on ocean or close to foreign culture: +1
great wonder that is not obsolete present and bordering on ocean or close to foreign culture: +2
These values are just a starting idea. Maybe they're a little high. At least they will not result in garrisons of 8 units in a city that is nowhere close to the enemy.
Garrison troops are just that. They should remain in the city indefinately until the borders change and less garrison troops are needed. They should only attack when chance of victory is very high (80-90%?) and the troops can return to the city (when an enemy unit is on a road, then you can attack and retreat to the city). Garrison troops should consist of typical defence units (archers, longbowmen, infantry, etc) with suitable promotions (city defence, drill)
-
Defence group
Because a static defence is doomed to fail, the AI should also build a defence group. This group is not limited to a certain city, but should defend a continent (one defence group per continent). It's size should depend on the number of AI cities on the continent or maybe on the total AI population size on the continent. The units in it should be chosen so that it can be an effective counterattack force. It's promotions should vary so that it isn't a predictable force that can be exploited by the human, some combat promotions and promotions versus certain types of units and collateral damage promotions. Units should consist of cavalry type units and footsoldiers but certainly also some artillery type units to defeat attacking stacks.
A formula for the size could be something like:
1 + [pop/20] artillery type units, 2 + [pop/10] soldier type units, 1 + [pop/20] cavalry type units (pop is the sum of all of the population sizes of the AI cities on the continent). These values are again only a starting idea.
When at war, the defence group should move to a city that is being threatened and try to relieve the city of its attackers. How it performs these actions is a part of the combat tactics AI and that is another topic. Being threatened could be defined as enemy units within 2 turns of movement. If multiple cities are threatened, then the defence group should split based on proximity to the threatened cities. We don't want a defence group that keeps moving from one threatened city to the next and back again. Too easy to exploit. Also, there should be priority for a city that has enemy units within 1 turn of movement above a city that has enemy units within 2 turns of movement.
When at peace, the defence group should be distributed randomly over all of the cities that are close to the border or bordering the ocean as defined in the part about the garrisons.
-
Attack Group
An AI that wants to be succesful at war should not wait until war comes to it. It cannot win when it only defends. So next to the garrison troops and the defence group, an attack group should be created that can be split in multiple attack stacks.
To surprise the defender, these attack stacks should not be fixed in size. If the human knows that the AI always attacks in groups of 10 unts, then the human can adapt too easily. If the stacks vary in size beteen 6 and 20, then it would work fairly ok, I guess. A succesful attack stack should contain a number of artillery type units, some city attackers and some generally promoted units for stack defence duty.
The AI should create units for the city attack group according to a certain distribution so that it can create good city attack stacks out of them. For instance, it should strive to get equally many artillery type units for city bombardment to city attack units for city capture and 1.5 times as many units for stack defence. For instance 4 catapults with precision upgrade (city bombardment group 4 units), 2 catapults with city attack, 2 swordsman with city attack (city attackgroup 4 units) and 3 axeman, 1 chariot, 2 spearmen with various promotions (stack defence group 6 units).
As long as the cities don't have enough garrison troops, the AI priority for units should be high and it should produce the unit types with promotions needed for that goal. As long as the defence group is incomplete, the AI priority for units should be moderate and it should produce units for the defence group with the suitable promotions. When the defence group is complete, the AI priority for troops should be light and the units should be produced that can be used in the attack group in the distribution as provided above.
When the AI gets involved in a war, then the AI priority for units should of course become high immediately. Each turn, it should check the units in the attack group, roll a number between 6 and 20 and see if there are enough units in the attack group. If there are, then it should pick a selection of these units and combine them into an attack stack. How the unit combinations in these attack stacks should be exactly is more a combat tactics discussion, but I would suggest something similar to the ratio in which the units for the attack group was produced. If after the combination of the first attack stack, there are still more than 6 units in the unassigned part of the attack group, then another number between 6 and 20 should be rolled to see if another attack stack can be created.
Ok, I tried to write this vision on a combat strategy AI in a way that it might be programmable. I don't know in how far the Civ AI can be transformed to use these ideas and if they really work as well as I hope they will. I didn't discuss ships or planes as I wanted to wait for a reaction on this major part of a combat strategy AI. And I think that the parts about ships and planes can be considered in a similar way.
I also have some ideas about other subjects that are far easier than the above, but that will have to wait until tomorrow.