A Better AI.

I might now look into getting the AI to get a minimum number of siege units, like 100% bombard a turn...
Well, here's the process I use ....

1) Bombard until defenses are down; wait till next turn unless odds are overwhelmingly in my favor
2) Use siege weapons - this is complex in my mind, but basically:
* Always prefer siege units with the collateral damage promotion
* Attack with siege units that have > 50% chance of (winning + retreating), from most powerful down
* Attack with siege units that have >= .5 (point 5) percent chance of winning combat, from least powerful up
3) DURING or AFTER siege attacks, if there is a combat possibility with a high probability of success (arbitrary, but somewhere like 75%-95% as a threshold), then take that combat; continue taking such combats until there are no more left
4) AFTER siege attacks are finished, attack with conventional units that have >= .5 percent chance of winning combat, from least powerful up, BUT taking any very likely favorable combats as per 3) when they occur

I guess that's a reasonable short version of the way I attack cities, but it omits some more tactics, plus strategizing like making sure that the attack doesn't take place across a river, and preferably from a tile with good protection. Does this make any sense?
 
That would be an excellent idea. Now if only you can convince the AI to bombard and assault a city on the same turn instead of letting defenders heal. :D

Obviously that is a bad idea unless you have a large enough stack to actually do that, which is unlikely in many cases.
 
Sorry Blake, and Iustis, but it's wrong, very wrong.

In the Old Builds the AI used to get close to Domination. Like control 1/4 of the continent. Now it fumbles around, doing stupid 3 unit stack attacks just to die. And then, and I've played 3 test games now under the last build, it always does stupid things like initiating a total war (and why total war at that point?) and it sees it's target cities and then realizes it can't take the city, so it just sits there with it's weak stack and doesn't even go on pillaging runs anymore (wich the stack that hits is seriously designed for, it pretty much always does balanced stacks now), so instead it just sits there.

It used to be where when it hit, it hit furiously with a full on dagger, grabbing cities, now it does like a human--Which is a good start for a pressed civ, but--while it starts with harrasment wars in chipotle it says total war (Why is harrassing a civ with a spear and two archers total war?), And then when a small stack like that hits it should pillage the horse and metals, but instead of pillaging to make $$$ and knock out it's foes strategic resources, it just sits there, and lets the drefense build. Warmonger AI has been nerfed to the point where the old used to be scary AI dagger is now a nuisense.

The AI will still do daggers, but not like before, I never see them until trebs, then when the do them, they can't give up on a city and pillage, they just sit there, which is great to deal with militarily, but is even worse then standard AI code in terms of a challenge.

The AI needs to pillage again if it can't take the City, and it's initial hits need to go back to full daggers, unless it can be programmed to realize it can't take the city and go on pillaging runs for cash. At least the way now the AI stands no chance of ever hitting a domination victory, which (and I could be wrong, but like the culture) I always thought was one of the goals of this project.

I have multiple saves where the AI is going on what should be limited war hits and under chiptole says total war if you want them. Also (and I never realized before but this probably still went on) why when an AI goes into a defensive war can't it switch to total when it could counterstrike and hit hard to vasillate and start building it's own juggernaught with no diplo penalties to the other civs? Why does it have to make peace and then redeclare to go on total war against the other AI to truly go on a city grab for vassilation goal? Which is also another problem, since it usualy picks some other random civ other the then one that it recently screwed up and could vassilate or fully conquer.

Anyway my point is AI warmongering has been significantly killed. Hit the first 10 pages of this thread, and remember when the AI used to be able to take any city that wasn't on a hill. Scary that was, but no more, not even close. The Potential and illusive Domination win is in need of some serious help, and I think the orginal better AI builds did this far more effectevely, sometimes seriously getting close. The current build can't even get in the ballpark.
 
Just found this city placement on the 12/21 build (latest one):

I'll also say that the leader is in ($$$). I think he might have been ($$$) before he settled, but I cannot see why it would value settling there. It has missed the copper and the only other thing of remote value is the wine that it has next to no chance of getting.
 

Attachments

  • Civ4ScreenShot0007.JPG
    Civ4ScreenShot0007.JPG
    133.3 KB · Views: 173
In terms of stack composition, the AI is remarkably ignorant of what a siege engine actually is (which is also why it's dumb about escorting them - it really doesn't know). The "City Attack" quality value now takes into account whether the unit receives defensive bonuses. I'm going to look into this function more since it might be overvaluing the bombard factor.

edit: Looking into some stuff I've discovered that First Strike gives a whopping +16% to the combat value of a unit which probably makes the AI overvalue Archer and such. I've halved that to the more appropriate +8%.

Also the bombard rate would seem to MASSIVELY overvalue early siege units.

So I've utterly tweaked that so for City Attackers, units which are NDB are valued less, extra movement is valued less, withdrawal chance is valued less, collateral is valued less, Bombard is valued a lot less, Immunity to FS is now valued (slightly, wasn't before at all), raw strength counts for a lot more. The City Attack Ranking with Knight tech now goes:
Treb > Knight > Mace > Catapult > Sword > Horse Archer > Axeman

Before these changes it was:
Treb > Catapult >>> Knight > Mace > Horse Archer > Sword > Axeman

I might now look into getting the AI to get a minimum number of siege units, like 100% bombard a turn...

Good to see that you're working on the combat AI. The attacking stacks did have a lot of artillery type units. But personally, I like maces better for city attack jobs than knights, mainly because they can get the city attack promotions. I also like axmen better than horse archers because of that same reason. It's not that knights and horse archers are bad for city attack jobs, but they are more expensive than macemen and axemen and because of their lack of city attack promotions are less suited for the job in general. Would it be possible to give units that have access to city attack promotions a higher value for city attack jobs?

In response to the 100% bombard a turn per city attack stack (last line of your post). I generally take enough artillery type units to get 100% bombard per turn (precision promotion) AND 3-5 city attack or collateral damage promoted artillery type units. The rest of the stack consists of units defending the stack, some other city attackers (maces/swordsmen) and some city defenders for the city that is going to be taken.

I was considering suggesting that (# defenders should scale based on size). However, I would also like to suggest that AI defender count should probably be weighted:

- holy cities should get an extra defender
- border cities near hostile neighbors should get extra
- core cities can go lighter on defenders
- top cultural cities should get extra
- cities under cultural influence should get more
- coastal cities should probably get a slight extra
- cities on top of strategic resources should get extra
- cities near strategic resources should get more
- cities that can see large armies of non-allies should get more

I agree with this part of your post. I have posted something similar in post 253:

Roland Johansen said:
-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.

We don't want city garrisons of 5+ units in cities that are nowhere close to the enemy just because the size of the empire is large. That will just use up units that could be used for better jobs and it will increase the maintenance cost for the AI.


I would like to report a strange bug with the 12/21 version. In the screenshot below, you can see some desert adjacent to a river which lacks the floodplain overlay. It's rather close to the starting point of my civilization, so maybe the bug is connected to the code that regulates the upgrading of the terrain around the capital.

desert.jpg

Thank you for all the work that you've done to improve the AI.
 

Attachments

  • Deserts.JPG
    Deserts.JPG
    206.2 KB · Views: 124
Obviously that is a bad idea unless you have a large enough stack to actually do that, which is unlikely in many cases.

I disagree. You only need to add 3-4 extra catapults/trebuchets/cannons to your usual stack of 3-4 catapults/trebuchets/cannons + stack defenders to facilitate this increase in conquest speed. 3-4 artillery type units will destroy the cultural defence, 3-4 artillery type units will be available for collateral damage attacks and the rest of the stack will defend the stack and finish off some defenders. You can take the city one turn after you've moved your stack next to the city.

You will conquer faster, giving the opponent less time to reinforce his/her cities, giving the opponent less chances for counterattacks against your city attack stack(s). It will shorten the time at war and thus result in less damage to your economy due to war weariness. And all of that for the one-time cost of 3-4 catapults/trebuchets/cannons. It's a great tactic.
 
I would like to report a strange bug with the 12/21 version. In the screenshot below, you can see some desert adjacent to a river which lacks the floodplain overlay. It's rather close to the starting point of my civilization, so maybe the bug is connected to the code that regulates the upgrading of the terrain around the capital.

I had one of these too in a 12-21 game. I'd never seen anything like it before, a desert next to a river with value of 1 commerce, no food, no hammers. I thought it was just something I've never encountered before, but now I agree, that it is probably something to do with this build.
 
I had one of these too in a 12-21 game. I'd never seen anything like it before, a desert next to a river with value of 1 commerce, no food, no hammers. I thought it was just something I've never encountered before, but now I agree, that it is probably something to do with this build.

In my case there were 6 or 7 of them next to eachother (you can't see all of them in the screenshot), so I didn't think it was an accidental bug in the original game. I checked the game with the worldbuilder but didn't see any other incidents of this bug in that world.
 
We don't want city garrisons of 5+ units in cities that are nowhere close to the enemy just because the size of the empire is large. That will just use up units that could be used for better jobs and it will increase the maintenance cost for the AI.

I mused a bit about this over in:
http://forums.civfanatics.com/showthread.php?t=198346

I decided to use those values as weights rather then # of defenders.

When I play, I always have 1 defender (max'd CG promotions) in each city. Then I estimate how many additional defender units I need and use the weightings to spread those across my cities. Which also makes the math easier because you don't have to do a 2-pass leveling to make sure everyone gets at least 1 defender. You can just total up the weights, convert to percentages, and then multiply (with normal rounding) to get the desired # of mobile defenders per city.

Estimating how many movable defenders to have is the black art. I need enough to dissuade opportunistic attacks, enough to keep my enemies at bay, but not too many that I cripple my economy or cripple my offensive. I can have more if I'm passive, less if I'm aggressive (using them for the assault stack rather then defense).

Those mobile/spare defenders are typically of mixed style (medic / CG / drill / strength). Having them as mixed style also allows them to be used for assault stacks. About half of the movable defenders are still true city defenders (max CG).

Since the AI doesn't cheat, there should probably also be some scout-class mounted units (tricky to do since the AI evaluates each promotion level separately). Those scout units should end up in the border cities so that the AI has more warning of incoming invaders. I don't know wehther this is doable or needed. But it's something that I always tend to do (plus the mounted units can be used as anti-pillage).

Moving units around (rebalancing defenders) can probably be done lazy fashion during peace. Units should probably be balanced across the empire strictly according to weight.

During war, additional defenders need to be pulled from the nearest city that has a lower weight value. So go through the list from highest weight city down to the lowest weight city. Cities with the lowest threat rate can never go below 1 defender, but otherwise may be stripped of defense for more important locations. In my other post, I gave a city additional weight points for each stack in their line of sight (heavier if 2 tiles away, heavier still 1 tile away) along with additional weight points based on the # of units in the stack (also distance-based).

Not sure how you'd handle defenders that will get there "too late". I'd say that moving a defender during war time that will take more then 3 turns to get there might be too long. This should only occur in early game if there aren't roads. But if the defenders are properly balanced across the empire, there should be less need to move defenders during conflict (other then to replace losses).

The other thing the AI doesn't seem to understand is the use of forts. I play Tokugawa (Protective) and put forts in between cities on otherwise unworkable plots. A forest+fort is +75% defense and provides a good place to store spare defenders. Either for setting up an assault stack, or to act as anti-pillaging (guarding a strategic resource), or as a staging point. Using it as a staging point is more of a human thing. It lets me accumulate units in an easy to locate spot. Where I don't have to futz with separating them from the city defenders when it's time to use them. So I'm not sure how to teach the AI about forts.
 
When I go to war, I bring enough units to take the city in a single turn, plus enough defenders to move in and hold the city. I then bring additional defenders towards the current "front" from cities that are now behind the front.

Plan of attack:

1) Before bombarding, sort the list of units in the stack by % chance of success. Dunno if the AI can do this.

2) Starting with the least % chance, bombard with any bombard units until the defenses fall. That way my better seige units are left for the city assault.

3) Re-evaluate and re-sort chances now that the defenses are down. Preserving units is important, but I don't want to sit here cooling my heels. This is also where pacifist / aggressive AIs can show their colors. An aggressive AI will press forward if they have enough units to take the city, even with moderate losses. A pacifist AI should only attack if it can get away with minor losses (otherwise it should've gone pillaging?).

Bit of a black art to estimate this. I generally look at total base STR of the units on each side, the average base STR on each side, the promoted STR on each side and the average promoted STR on each side. I only look at city attack or city/terrain defense promotion values.

The average/total promoted STR on each side is probably the best indicator. Aggressive AIs may go ahead with as little as a 25% margin. Passive AIs or reluctant warmongers might want a 75% margin. AIs that are ahead in the power graph can afford more losses. AIs that are behind in tech need to be more aggressive if they hope to catch up.

Units that I'm going to use to defend the city are not used in the calculation.

4) Assuming we attack... look at my % chance of success list. If I don't have % chances above 80-99% (aggressive AI might go with lower values, pacifist higher), then I start using collateral damage units or cannon fodder (low XP units).

5) Collateral damage units are picked to go first if they have > 80% chance. Otherwise, I use my weakest collateral damage units as cannon fodder. This is a hard balancing act because I only want to use enough cannon fodder to get the chances for my best units above 80%. So I may suicide a fodder unit, attack with the best unit, see that my next fight is below 80% so suicide the next fodder unit.

6) After that, it's simply attack with the highest percentage downward until I take the city. If success chances fall below 50%, I usually stop and heal until the next round.
 
I just started a new game with the 21/12 build as I didn't want to continue my previous game after I had opened the world builder to check for more deserts without floodplains (not fun when you know how the world looks like).
I was an expansionistic leader in my new game and thus my workers are being build at an increased speed whenever I build them with hammers instead of food. The governer however fails to recognize this (it seems).

See the screenshots below, the first one without emphasizing and the second one while emphasizing hammers. Notice the difference in build time for the worker. As I understand the AI uses the standard governer which is doing a suboptimal job in this case.

No emphasize.jpg
Emphasize production.jpg
 

Attachments

  • No emphasize.JPG
    No emphasize.JPG
    140.1 KB · Views: 115
  • Emphasize production.JPG
    Emphasize production.JPG
    139.1 KB · Views: 108
I realize Blake has a lot on his plate, but the starting locations could use a little more work . . . it seems the engine is tooled to start Civs up as far apart from each other as possible, which is resulting in a LOT of "Greenland" and peninsula starts. A little more flexibility on starting locations wouldn't hurt, starting close to another city isn't great, but I'd prefer it to starting in an oasis of green on the edge of the polar ice cap.
 
I realize Blake has a lot on his plate, but the starting locations could use a little more work . . . it seems the engine is tooled to start Civs up as far apart from each other as possible, which is resulting in a LOT of "Greenland" and peninsula starts. A little more flexibility on starting locations wouldn't hurt, starting close to another city isn't great, but I'd prefer it to starting in an oasis of green on the edge of the polar ice cap.

I have to say i do miss some of the polar starts.. It made for an interesting game. Otherwise after playing a few games with the new build the ai vs ai war declaration seems to be a lot better. I still havn't seen any sea assaults but i haven't been the victim of an ai war declarations from across the sea. but the culture victory for the ai is fantastic, almost too good.. I was unluckly being between Ghandi and Ramases and needless to say all my metals "were" on the outer borders of my empire.
 
See the screenshots below, the first one without emphasizing and the second one while emphasizing hammers. Notice the difference in build time for the worker. As I understand the AI uses the standard governer which is doing a suboptimal job in this case.

No emphasize.jpg
Emphasize production.jpg
from waht i've noticed, expansive civs will recalculate the worker's cost after closing the screen a lot of time, as in, it is re-jiggering the worked tiles once it gets the build order in.

the same holds true of settlers and imperialistic civs ~

this might not hold with the new patch (1221), but it could be
 
from waht i've noticed, expansive civs will recalculate the worker's cost after closing the screen a lot of time, as in, it is re-jiggering the worked tiles once it gets the build order in.

the same holds true of settlers and imperialistic civs ~

this might not hold with the new patch (1221), but it could be



That does still hold true with the new patch.
 
Just grabbed the new version and got what I would consider an abnormally close start. Standard size Ice Age map, narrow continents:

civ4screenshot0000xm5.jpg


The starting location is also a bit sick.

Darrell
 
I have just played a game (Vanilla) with Blake's AI improvements. Well, here is my option:

Now, the AI is quite good at peaceful building. But something's wrong with their warmongering aspect...

I am playing as French. The Germans declare war at me, and send a really huge stack of Cavalry, Grenadiers, and Catapults to my city of Rheims, which is defended by 3 musketters on a hill.

"Well," - I think - "I can kiss Rheims goodbye".

But, instead of just attacking the city with Cavalry (10 Cavalry and 10 Grenadiers surely will defeat 3 Musketters) the AI bombards my city defenses, giving me valuable time to bring reinforcements. Now Rheims is garrisoned by 15 Musketters (I really like Musketters, they are really mobile defenders).

The AI attacks with a Catapult, causing collateral damage, attacks with a Cavalry (who dies) and that's all. :crazyeye:

I draft Musketters all over the place and send them to Rheims, so Rheims has 20 Musketters.

Finally, after bringing in a bit more Cavalry and Grenadiers and bombarding my city defences to zero, the AI attacks Rheims and takes it, taking rather heavy casualities.

I see, that AI's warmongering motto is "Slow, but sure". But really, can't AI's be a little more willing to take risk? If the AI has 10 Cavalry and 10 Grenadiers against my 3 Musketters in a city, there is absolutely no need in bombarding city defences to zero, giving me time to bring reinforcements.

Just my little bit of two cents.
 
I have just played a game (Vanilla) with Blake's AI improvements. Well, here is my option:

Now, the AI is quite good at peaceful building. But something's wrong with their warmongering aspect...

I am playing as French. The Germans declare war at me, and send a really huge stack of Cavalry, Grenadiers, and Catapults to my city of Rheims, which is defended by 3 musketters on a hill.

"Well," - I think - "I can kiss Rheims goodbye".

But, instead of just attacking the city with Cavalry (10 Cavalry and 10 Grenadiers surely will defeat 3 Musketters) the AI bombards my city defenses, giving me valuable time to bring reinforcements. Now Rheims is garrisoned by 15 Musketters (I really like Musketters, they are really mobile defenders).

The AI attacks with a Catapult, causing collateral damage, attacks with a Cavalry (who dies) and that's all. :crazyeye:

I draft Musketters all over the place and send them to Rheims, so Rheims has 20 Musketters.

Finally, after bringing in a bit more Cavalry and Grenadiers and bombarding my city defences to zero, the AI attacks Rheims and takes it, taking rather heavy casualities.

I see, that AI's warmongering motto is "Slow, but sure". But really, can't AI's be a little more willing to take risk? If the AI has 10 Cavalry and 10 Grenadiers against my 3 Musketters in a city, there is absolutely no need in bombarding city defences to zero, giving me time to bring reinforcements.

Just my little bit of two cents.

Actually in your case, AI did the right move to bombard everything then take the city. Attacking right away without bombard defence will cost double to triple casualty. Then when the AI moves to your next city, the muskteers that you were going to sent to rheims is in there, Ai still have to bombard and fight those same muskteers but with alot weaker force because they already took heavy casualty killing the 3 well defended muskteer in rheims.
 
darrelljs said:
Just grabbed the new version and got what I would consider an abnormally close start. Standard size Ice Age map, narrow continents:

Um yeah there's an issue with the Python starting distance function, now some scripts such as Pangaea use the Python function, others such as Continents use the SDK function. This is why my changes were strangely ineffectual at times, now that I know what's causing it I've fixed it so that all map scripts consistently take my distance algorithm into consideration. It seems to work.


I realize Blake has a lot on his plate, but the starting locations could use a little more work . . . it seems the engine is tooled to start Civs up as far apart from each other as possible, which is resulting in a LOT of "Greenland" and peninsula starts. A little more flexibility on starting locations wouldn't hurt, starting close to another city isn't great, but I'd prefer it to starting in an oasis of green on the edge of the polar ice cap.

That's easy to change, I was tweaking it anyway, here's how it working with the latest modifications I've made:

When near other starts, reduce the value proportionally-squared for the nearest civ range (ie if there is a start at a distance of 50% of minimum distance, reduce value to 50%*50% = 25%).
NewCiv <---------CivX---> MinDist


When there are no nearby starts, increase the value by up to 25% at 1.5xMinDist, only count the nearest civ for this calculation.
NewCiv <---------------> MinDist <-------CivX-----> 1.5xMinDist


When there are no civs within 1.5xMinDist then increase the value by 25%, regardless of how near or far the other civs actually are ("far away" is good enough, no need to get pushed into some desolate corner).
NewCiv <---------------> MinDist <---------------> 1.5xMinDist <---------CivX


The "1.5" and "25%" numbers may be subject to tweaking, it's rather conservative as it is.
 
I have just played a game (Vanilla) with Blake's AI improvements. Well, here is my option:

Now, the AI is quite good at peaceful building. But something's wrong with their warmongering aspect...

I am playing as French. The Germans declare war at me, and send a really huge stack of Cavalry, Grenadiers, and Catapults to my city of Rheims, which is defended by 3 musketters on a hill.

"Well," - I think - "I can kiss Rheims goodbye".

But, instead of just attacking the city with Cavalry (10 Cavalry and 10 Grenadiers surely will defeat 3 Musketters) the AI bombards my city defenses, giving me valuable time to bring reinforcements. Now Rheims is garrisoned by 15 Musketters (I really like Musketters, they are really mobile defenders).

The AI attacks with a Catapult, causing collateral damage, attacks with a Cavalry (who dies) and that's all. :crazyeye:

I draft Musketters all over the place and send them to Rheims, so Rheims has 20 Musketters.

Finally, after bringing in a bit more Cavalry and Grenadiers and bombarding my city defences to zero, the AI attacks Rheims and takes it, taking rather heavy casualities.

I see, that AI's warmongering motto is "Slow, but sure". But really, can't AI's be a little more willing to take risk? If the AI has 10 Cavalry and 10 Grenadiers against my 3 Musketters in a city, there is absolutely no need in bombarding city defences to zero, giving me time to bring reinforcements.

Just my little bit of two cents.

The bombarding thing is a bug, it's been fixed. If the AI has overwhelming odds it will just attack and not bother with bombarding.

That other issue... of pillaging... that it doesn't pillage strategics can basically be considered a bug...
I don't really favor mass pillaging as a legitimate strategy, it is too easy to counter and awards too much easy experience for the attacker... in some cases it would really be better to disband the units than pillage with them.
Don't worry, I'm not pretending that it's working well at the moment (but I think it is better than mass pillaging as a first resort).

Basically the ideal algorithm goes something like this:

If we have a more attacking strength than the enemy has defending strength, then attack. (outnumbering the enemy)
If we have less defending strength than the enemy has attacking strength, then run away. (outnumbered/outgunned by the enemy, stick together for safety)
If we have more defending strength than the enemy has attacking strength, then pillage. (longbows in a city on a hill but no counter units)


However I would still question whether it's better to pillage than to just go away and hope the enemy lets their guard down a bit... it could be based on whether it's war for profit vs war because i hate you....
 
Back
Top Bottom