A Better AI.

In my battle with Alex, I came upon a city with 5-6 troops of various types and at least as many Catapults, all with two collateral promotions. Did they attack my stack as it sat there for multiple turns bombarding and then attacking? No. Instead, I had an easy time killing all those Cats as they defended against my Maces, Knights, Pikes and Cho-Ko-Nus. If they had attacked me, most still would have died, but I would have suffered more damage. I believe that's the whole point of the collateral promotion on siege units.

It's pretty important that the AI learns to use colateral damage units in defence of it's cities. In the long run, hitting attacking stacks with collateral damage units is the only way to win a defensive war (or having huge amounts of units to attack the stack with). If anything should have a priority to fix, I think this is it. The problem is probably related to the earlier version of this mod where units would attack pillagers or other lone units while leaving the city almost without defenders.

Suggestions:
- Count collateral damage units as unneeded for city defence. So if a city is being threatened, then the catapults don't need to stay in the city for defence. The moments where a catapult will be useful to defend a city are almost non-existant while a catapult can always hurt an attacking stack by attacking it.
- Don't attack lone units in your territory with collateral damage type of units except when the chance of victory is high.
- Do attack stacks of units inside your borders with collateral damage type units. The chance of victory should not be important.
- Move collateral damage type of units located in other cities towards the threatened city if they can attack the enemy stack before the enemy attacks the city.

When the collateral damage units attack the attacking stack, their attacks might weaken the attacking stack to such an extent that it might be smart to attack the stack with the city defenders. Hopefully, the AI also builds some attacking city defenders, but even if it does not, even longbowmen have an excellent chance to defeat macemen which have been reduced to half hitpoints. So in an ideal situation the AI should evaluate its chances to kill the stack while attacking it, especially if the stack is located next to the city and the defender thus could remain in the city to defend after it has attacked the stack.

Okay, I guess, it's pretty difficult to get the AI to act really smart when attacking or defending cities. I'm thankful for the improvements up until now. :goodjob:
 
Count collateral damage units as unneeded for city defence. So if a city is being threatened, then the catapults don't need to stay in the city for defence.

One potential problem with this: Often the AI will use a forward city as a 'staging area'. It builds up a pile of siege and troops and once it is 'satisfied' it moves them as an attack-stack into enemy territory. If those siege weapons are expended constantly on spoiler attacks, the AI might never attack in force. Obviously deep in friendly territory siege defenders could be considered 'expendable', but this should be a universal case.

Also keep in mind that siege units are immune to collateral damage. Since many of the AI's attack stacks are very siege heavy, having defending siege suicide attacking and inflicting damage on just a few units isnt exactly productive either (since many attacking stacks will be 3-4 regular units and 10+ siege).

Its a fine line IMO and it will be difficult to make a blanket policy that covers this. I'm sure an algorithm can be written to compensate, but its not as clear cut as it first appears.
 
One potential problem with this: Often the AI will use a forward city as a 'staging area'. It builds up a pile of siege and troops and once it is 'satisfied' it moves them as an attack-stack into enemy territory. If those siege weapons are expended constantly on spoiler attacks, the AI might never attack in force. Obviously deep in friendly territory siege defenders could be considered 'expendable', but this should be a universal case.

Also keep in mind that siege units are immune to collateral damage. Since many of the AI's attack stacks are very siege heavy, having defending siege suicide attacking and inflicting damage on just a few units isnt exactly productive either (since many attacking stacks will be 3-4 regular units and 10+ siege).

Its a fine line IMO and it will be difficult to make a blanket policy that covers this. I'm sure an algorithm can be written to compensate, but its not as clear cut as it first appears.

Of course, you're right. They were suggestions, not absolute truths. Refining is absolutely needed.

I did say that the catapults should only attack the bigger stacks and I personally do think they should do that whether the big stack is nearing a city attack stack or not. You don't want the city attack stack sitting in a city under attack while not counter attacking just because they were dedicated to city attack, do you.

When the AI algorithm is considering whether or not to use catapults for attacking a stack, only the units in that stack which can be hurt by collateral damage should be considered. If there exist 3 or more in such a stack, then use the collateral damage attack, if not then don't use it. (of course, this could be refined).
 
I haven't read through all the pages up to this point, so I hope I'm not reporting problems that are already known, but last night I was playing a multiplayer game with the latest version of the BetterAI mod, and noticed several possible problems.

1) We had two human players, against a team of two AIs. Every time we tried a custom continents start with "1 per team" set, one of our human players was started on a one-or-two-square island right off the coast, with lots of sea food.

2) One time on a mirror map (I'm sorry, I forgot to save this one for you), one of our human players started adjacent to an AI capital. (I.e., the AI had already founded its city.)

3) We've kept getting out of sync errors later in the game.
 
Yeah, that thing called "amphibious assault".

The AI misses a lot of chances to put a hurt on a player/other AI by not assaulting cities directly from the sea, particularly when the defender has railroads and can wipe out an invasion force on land in one turn.
 
As I mentioned in my original post, the Catapults all had collateral damage promotions, not City Raider. As such, I think they were intended to be defensive units. They just didn't do their job.

Defensive Catapults should attack (usually suicidally) enemy stacks. That is their purpose in life.
 
One observation on why the AI sometimes seems so 'peaceful':

The AI is VERY good at spreading its religions. In all 3 of the games I've started with 1/8, the other continent was all one unified religion, making for a very peaceful coexistance. I've also noticed that many of the AIs are reluctant to switch to Free Religion and thus break-up their little sewing circle.

I dont know what could be done (or even if its desirable for anything to be done), but I think that the AIs should consider Free Religion a little more as the game goes on.

I play with a rules change that grants free mysticism to everyone thus making every civ 'religious' and causing much better religion and holy city distribution.
I hate religion gathering.
I play this way since a long time ago.
 
I play with a rules change that grants free mysticism to everyone thus making every civ 'religious' and causing much better religion and holy city distribution.

Interesting solution. Do you throw Civs that are supposed to start with Mysticism a bone or do they just start down a tech? If so, what do you give them in compensation?

All in all, I dont think the religion 'problem' would be an issue if more Civs simply adopted Free Religion when it is available. In the newer builds, very few Civs seem to bother with it. Is this because people think it is a weak Civic and hence it would be inefficient for the AIs to adopt it? Personally I like to switch to if ASAP unless I absolute need the friendly relations with like-religion Civs.
 
Interesting solution. Do you throw Civs that are supposed to start with Mysticism a bone or do they just start down a tech? If so, what do you give them in compensation?

Yes i gave the 7 original religious civs another starting tech.
Which ones i don't know at the moment because Civ4 is in my laptop.
The home PC i'm surfing with cannot handle the game.

If you're interested i can look it up but i just gave another starting tech to them i thought someway fits to their civ flavor.

Gave the free mysticism in the handicapsinfo file and the new starting techs in the civilizationsinfo file.

Because i play mostly on standard maps with 8 civs that would normally mean an average of 2 religious civs who will most likely gather all or almost all the religions.
It just felt wrong that mainly 2 religions ruled the world in every game and the others were just restricted to holy city tourism for that civs.
 
Interesting solution. Do you throw Civs that are supposed to start with Mysticism a bone or do they just start down a tech? If so, what do you give them in compensation?

All in all, I dont think the religion 'problem' would be an issue if more Civs simply adopted Free Religion when it is available. In the newer builds, very few Civs seem to bother with it. Is this because people think it is a weak Civic and hence it would be inefficient for the AIs to adopt it? Personally I like to switch to if ASAP unless I absolute need the friendly relations with like-religion Civs.
Interesting.

I've been putting thought lately into things such as Spiral/Sankore strategies. My conclusions (after much experimentation and thought) are that Spiral/Sankore are best used with a SE. If you're running a CE, then the 10% research bonus is more beneficial. Let alone the happiness bonus. So, as soon as you can, it's better to switch to Univ Suffrage (to get your production bonus to replace Organized Religion) and Free Religion (to get the research and happiness). Thus, you end up building Spiral/Sankore and only getting a minor benefit before switching away from them. It's not worth it to even bother in the first place.

And, on top of that, when not trying to found more than one or two religions. If you have several shrines, then it's more powerful to spread them all throughout your empire (spreading AI religions throughout your empire helps the AI and probably should be avoided unless going for a cultural win). And, if you do that, then the 10% research bonus for Free Religion is more beneficial than the 2 or 4 beakers per city.

Wodan
 
I had noticed some strange things with the governor the last few days but couldn't pinpoint what happened. I would set a city at using certain tiles using the governor and emphasizing something (gold, hammers, food) and when I came back a few turns later, I would find that the city was using a few specialists. This was without the city growing or adding improvements. I didn't want the specialists so I changed it back, sometimes disabling the governor to get the right tiles used. However, I didn't detect a pattern in what had happened untill now.

I've attached two screenshots. In the first one you see a governor controlled city with emphasize commerce and the science-gold rate at 100% gold. It is using the tiles that I want it to use. In the second screenshot, I changed the science-gold rate to 100% science and the city has disabled a plains mine and a farmed grassland to enable two scientists. Hmm, that's not what I wanted. I of course change it back.

But often I will change my science rate without checking every single one of my cities for the consequences it might have on the tiles that I use. And thus some tile uses will switch to something that I do not want. If I want to use specialists, I can switch them on myself while still enabling the governor. I would never want the governor to choose the specialists that I use. I want to pick them myself to go for a certain type of great person and in almost every other case, I do not want the specialist.

Will I be forced to leave the governor off?

Why exactly was this added to the game. Does it somehow help the AI?

100% gold.JPG
100% research.JPG
.......Already answered I see...........
Well the reason is that the game is trying to maximize 'commerce' and would therefore go for Scientists at 100% Science or Merchants at 100% gold... because you couldn't make Merchants, it settled for scientists.


The fact is without cottages, commerce primarily comes from specialists That city should not have a 'commerce emphasis'
.......Already answered I see...........


The best solution to the polluting specialist problem would be to create a way to 'ban' specialists (perhaps if you hit the [-] for a specialist when there is none of that type of specialist, that specialist type is banned (a little red sign indicating the specilist is banned...with an inability to ban citizens)).. That wouldn't require any new buttons at least.

Perhaps change it like this
Emphasize Research button change to an 'Emphasize Culture' button (since that adds to this city only.. and will only include commerce if it )
The 'Emphasize Commerce' then will emphasize
1. Gold or Science Only (since those are the only things that go into the Empire pot)
2. With an additional Emphasis Modifier based on Multipliers and slider
ie
Gold value under Emphasized Commerce =
Commerce Emphasized Value*
Gold Multiplier/Science Multiplier (125/110 for a Marketplace+ Monastery)

Then have the option to ban specialists (the [-] button)
 
Well the reason is that the game is trying to maximize 'commerce' and would therefore go for Scientists at 100% Science or Merchants at 100% gold... because you couldn't make Merchants, it settled for scientists.

The fact is without cottages, commerce primarily comes from specialists That city should not have a 'commerce emphasis'

The best solution to the polluting specialist problem would be to create a way to 'ban' specialists (perhaps if you hit the [-] for a specialist when there is non of that type of specialist, that specialist type is banned (a little red sign going there...with an inability to ban citizens)).. That wouldn't require any new buttons at least.

I think you missed a few posts after this one of mine in which Blake and I discussed the effects of certain governor settings a bit. As I understand it, he hasn't changed a thing about how the governor for the human player picks the tiles, but would like to do that sometime in the future (it's difficult to do).

By the way, I had the city on no emphasize at first, but it picked some of the forested plaines instead of the cottaged graslands. My emphasize settings were trying to correct that, but they failed. But that is also discussed in those posts. After those posts, I understand exactly why the governor makes certain choices with and without emphasize settings. I just don't agree with them. I hope Blake can improve them in the future. But it is maybe not the most important thing to improve as it has more to do with the human player and less with the AI.
 
I haven't read through all the pages up to this point, so I hope I'm not reporting problems that are already known, but last night I was playing a multiplayer game with the latest version of the BetterAI mod, and noticed several possible problems.

1) We had two human players, against a team of two AIs. Every time we tried a custom continents start with "1 per team" set, one of our human players was started on a one-or-two-square island right off the coast, with lots of sea food.

2) One time on a mirror map (I'm sorry, I forgot to save this one for you), one of our human players started adjacent to an AI capital. (I.e., the AI had already founded its city.)

3) We've kept getting out of sync errors later in the game.

Yeah i have been trying to trouble shoot the OOS errors but i am starting to think i am in over my head a little LOL. We get them too at various times in multiplayer. We usually play Small maps with 3 human and 15 AI's on a Lan.
We have played for several hours with no OOS but we always get them around Swordsmen and when players are involved in wars. Once they start even reloads only help for about 10 turns or so then there back.

I captured all the logs from our last oos. I set from each computer but i am a little overwhelmed what i should be looking for. I love this mod and it would be great if it would work in multiplayer.
 
An easy way to make conquest not be such a dominant style compared to the builder strategies would be to change it to improve walls and castles. Here's my suggestion for walls and castles.

Any time an enemy unit moves into a space adjacent to a city with walls, the best siege unit in the city gets a free round of attacks on the stack in that tile (including collateral damage). A Castle allows 2 free rounds. In addition, at the beginning of every round, any enemy stack adjacent to such a city recieves a similar round of attacks from city walls and 2 rounds from a castle. Zero retaliation from these attacks. Equivalent to an attack with infinite first strikes.

So basically any enemy stack next to a city with walls would lose it's weakest unit every round and also receive collateral damage every round. It would also get nailed by a fresh attack every time a new enemy unit entered that tile.

Another alternative might be to do the same thing except ignore the results of the actual attack and only apply the collateral damage.

This would expire when walls and castle become obsolete (gunpowder?).
 
An easy way to make conquest not be such a dominant style compared to the builder strategies would be to change it to improve walls and castles. Here's my suggestion for walls and castles.

Any time an enemy unit moves into a space adjacent to a city with walls, the best siege unit in the city gets a free round of attacks on the stack in that tile (including collateral damage). A Castle allows 2 free rounds. In addition, at the beginning of every round, any enemy stack adjacent to such a city recieves a similar round of attacks from city walls and 2 rounds from a castle. Zero retaliation from these attacks. Equivalent to an attack with infinite first strikes.

So basically any enemy stack next to a city with walls would lose it's weakest unit every round and also receive collateral damage every round. It would also get nailed by a fresh attack every time a new enemy unit entered that tile.

Another alternative might be to do the same thing except ignore the results of the actual attack and only apply the collateral damage.

This would expire when walls and castle become obsolete (gunpowder?).

Dear Khumak,

Rules modding is not the goal of this project.

The BetterAI team instead works hard to improve AI warmongering to a challenging level and tries to improve AI defense to make human warmongering harder.
 
Yeah i have been trying to trouble shoot the OOS errors but i am starting to think i am in over my head a little LOL. We get them too at various times in multiplayer. We usually play Small maps with 3 human and 15 AI's on a Lan.
We have played for several hours with no OOS but we always get them around Swordsmen and when players are involved in wars. Once they start even reloads only help for about 10 turns or so then there back.

I captured all the logs from our last oos. I set from each computer but i am a little overwhelmed what i should be looking for. I love this mod and it would be great if it would work in multiplayer.

Look at the random calls. You are looking for a random that was done in one but not in the other, or some other difference.

-Iustus
 
It's a problem as old as Civilization (every version of Civ has had absolutely inferior governor workforce placement problems), it comes down to the algorithm used - it places each population separately rather than looking at the final configuration. With a governor rewrite I can mostly eliminate this phenomena and generally force it to pick optimal configurations. It is however not a trivial task - as I said it's been in every version of Civ (and SMAC) so it's not an easy thing to fix.
The main problem is performance - any kind of brute force approach (ie comparing every possible configuration) will just be far too slow. Extremely clever techniques are needed...

It shouldn't be too difficult (though certainly not trivial I agree!) to make an algorithm which assesses tile values better than the governor does at the moment. I've made a suggestion under the spoiler button below (only because it is long) but it is by no means thought out very thoroughly yet. Heck the loop I made probably has infinite loops at the moment:lol: - I'm not an experienced programmer.
Anyway, I'm sure there are people who've posted on this thread (or reading it) who have the ideas and skills to improve the governor further, including you and Iustus of course. Unfortunately I don't have the time to get into this very much, but I definitely think it's worth improving the governor.
Honestly I wouldn't mind if the extra computations necessary made each turn take a second longer. It would still be time saved for me to not have to check the cities each turn to see what tiles they're working.

Here's my idea:
(I guess it's a kind of pseudo-algorithm)

Spoiler :
Value each tile using the following rules:
$1 means 1 point or 1 credit - whatever you want, it's only for notation here. It is not the same as commerce or gold.

1H = $10
1F = $11
1C = $3

(These figures are an suggestion only (they would be sufficient for many of my cities)
but these can be revised with some debate)

If any emphasize buttons are on, use different weights. For example,
Emphasize food could put 1F = $100 and leave the other two the same.
Emphasize hammers could put 1H = $15 and leave the other two.
Emphasize commerce could put 1C = $6 and 1H = $0 ??? and leave the food weight alone.


Then if there are n citizens to work, pick the best n tiles.

Code:
While the city is in starvation as a result of the selection, do
	Consider the chosen tile with lowest value
	Of the unchosen tiles, consider the one with the highest value
	If the unchosen tile has more food, then
		Swap the two
	Else
		Consider the next lowest unchosen tile
		If there is no next lowest tile, then
			Consider the next highest of the chosen tiles (and go back to the highest of the unchosen tiles)
				If there is no next highest chosen tile then
					break the loop ie. let the city starve
				End If
		End If
	End If
End While


The combination emphases might need more thought but perhaps these would be close:
Food and Hammers: 1C = $1, 1F = $110, 1H = $100
Food and Commerce: 1C = $5, 1F = $16, 1H = $1
Hammers and Commerce: 1C = $4, 1F = $1, 1H = $13 (then the starvation-loop will be run until
the city is not starving.)

Avoid Growth: Use the selected emphasis as normal (including no-emphasis if none selected) but then tweak the lowest value tile until
the excess food is exactly 0. If this is not possible, then prefer growth over starvation.
Emphasize GP: 1F = $100, 1H = $5, 1C = $1
Emphasize Research: Some more thought will need to go into this one (does anyone ever use this??)

If building a settler or worker, unless emphasize commerce is on, use:
1F = 1H = $100, 1C = $1

There are then other considerations for changing these weights or adding in extra loops like for example
how I just learned Cyrus gets some bonus for hammers towards settlers (because he's imperialistic). Also cottages/villages/hamlets should be given slightly more value than other tiles of similar value which aren't cottages/villages/hamlets.
And cottages/villages/hamlets/towns close to the city and further from enemy borders should be worked preferentially.

The example I had from earlier:

Under each type of emphasis (heading) I've given the point values for each tile (using my proposed values) and then listed the most valuable tiles.

No emphasis
-- 43 28 31 --
36 32 63 31 31
36 47 -- 68 32
55 47 32 32 31
-- 32 25 36 --

68 pig
63 iron mine
55 corn
47 flood plains farm

Food
--- 43 206 120 ---
303 210 63 120 120
303 403 --- 513 210
500 403 210 210 120
--- 210 203 303 ---

513 pig
500 corn
403 flood plains farm
403 flood plains farm

Hammers
-- 63 28 41 --
36 37 93 41 41
36 47 -- 73 37
55 47 37 37 41
-- 37 25 36 --

93 iron mine
73 pig
63 plains hill mine
55 corn

Commerce
-- 10 34 13 --
39 23 12 13 13
39 50 -- 62 23
55 50 23 23 13
-- 23 28 39 --

62 pig
55 corn
50 flood plains farm
50 flood plains farm


Food and Hammers
--- 401 222 310 ---
331 320 601 310 310
331 441 --- 651 320
550 441 320 320 310
--- 320 221 331 ---

651 pig
601 iron mine
550 corn
441 flood plains farm



I understand you're not after a brute force approach, testing every possible configuration. I'd agree that's a bad idea. But I don't see how you could optimise much if you don't use a little bit of brute force... if you know what I mean.;)

That's my 20c.
 
But the AI didn't claim any of these 5 furs (and it doesn't have any other furs of its own or through trade). It's 1220 AD and the spot is something like 10-15 tiles from two AI capitals and they have more than enough production as it is an emperor level game. There are also no other spots for them to build cities.
It's also way better to have 5 furs than 1 fur in some outer border of one of your cities. The other furs can be used in trade for other resources or gold per turn.

Personally, I would even build a city there without the resources. The coastal areas and trade routes will make it profitable after it reaches size 2 or 3 depending on upkeep (how many cities have you already build and what difficulty level is this game). It will always be a lousy city, but it will make a profit. Without the resources, it would of course have a very low priority for me to build a city there, but eventually I would build it.

I'm going to claim the spot now even if I have to build a city in the middle of AI territory. I will get +2 happiness in my main cities (very nice) and a lot of trade oppertunities. But the AI should have gotten them. It feels almost like cheating.

If you post the save, Blake or I can look into it. (Forgive me if you already posted the save and I missed it).

Another thing you can do is turn on chipotle and look at what the found values are for that plot. (Hold down alt key and mouse over a plot)
playerfoundvalues.jpg


Let me explain the information here:

First is the player name. The color gives information. Green is used for plots that are explored by the player. Light blue means that the plot is unexplored. Yellow means it is the best plot on that continent for that player.

The first number is the cached value (from map creation if the plot is unexplored), the first value in parenthesis is the value if it were explored and recalculated right now (values are recalculated only once per turn), the second value is the value if it were recalculated right now for a civ start plot (for turn 0).

The second line is provided if the cached area best value is non zero. The Area Best is the best cached value on that continent. The Best value is the best cached value on the whole map.

So, from this picture, we can see this plot is the best plot for Roosevelt to found a city on this continent. It is a so so spot for Iustus and Napoleon. All three of these have explored this plot.

Isabella is on the same continent, but has not explored this plot yet (her Area Best is 5100).

Brennus, Huayna Capac, Churchill, and Shaka have not discovered this continent yet, they started elsewhere. They would have high values for founding a city here, because founding a city on a new continent has a high value plus founding the first city on a newcontinent.

-Iustus
 
I currently play with the latest Sevo/GIR/Keldath MOD loaded. Can I just use this "Better AI" MOD on top of their MOD? I'm guessing I just download this MOD and install it over their MOD folder. Please let me know if I can or cannot do this. Any information would be appreciated.

Thank you for your time!
 
If you post the save, Blake or I can look into it. (Forgive me if you already posted the save and I missed it).

Another thing you can do is turn on chipotle and look at what the found values are for that plot. (Hold down alt key and mouse over a plot)
playerfoundvalues.jpg

I didn't post a save yet. Sometimes a screenshot says it all, sometimes a save is useful to take a better look. In this case, you shall get a savegame, the 1214AD autosave.

I normally leave the cheatcode off so that I don't know that the AI is planning a dagger attack or some other spoiler information. I switched it on to look at the 1214AD autosave and got the screenshot with extra info for you. It is apparently the best settling spot for Cyrus (who's empire is very close), but the settling values are all pretty low. I think that the AI underestimates the value of luxury resources for happiness and trading. Yes, it is a poor city, but it is good for an empire. (The spot selected is the one inbetween the 4 furs.)

As I have already progressed further in this game, it is not a real problem to get some spoiler information from a savegame in the past. Apparently all the AI on my continent are planning a dagger attack. Probably because I'm playing with the aggressive AI setting. I'm about 15-20 turns or so further now and about all of the AI are at war now, so the dagger strategy worked. The dagger attack strategy of course will lead to less settling, but it is already 1212AD and the AI should have settled the spot by now.

http://forums.civfanatics.com/uploads/31106/AutoSave_AD-1214.CivWarlordsSave

Founding values.JPG
 

Attachments

  • Founding values.JPG
    Founding values.JPG
    156.4 KB · Views: 102
Back
Top Bottom