Resource icon

AI+ v13.1

It's not that I want to put in tons of extra effort into city states, it's that by doing entire rewrites parts of the AI behavior, the city states would without additional changes act exactly the same as normal civs. Which isn't desirable. They shouldn't build wonders or try to secure good settle spot locations for example.
 
IMO:

CSs units:
make them cover area something like the span of another city, that is:
say, max 8 tiles from city center...

CS should
- have military to able to defend itself,
- also, when attacked or at war, build units...
- (perhaps save up money so to rush buy some army?)
- have walls and ranged unit in city...

- have districts and buildings according to CS-type
 
Yeah unfortuantely I'll never be able to change something about this part of the code without dll access :( The diplomacy system can be really wonky, and it's very visible to players, so it's definitely one of the more important sections to have it feel sensible, but alas..

@Victoria knows quite a bit about diplomacy modifiers. Maybe there's something possible?

So here's my question. to what degree would you like to see city states changed? Should I make them as smart as possible, which may make them feel like normal civs playing a one city challenge or should I keep this feeling that they're completely different things?

They already do build traders, actually.
As for what they should/shouldn't do, in my opinion they should keep their units relatively close (including naval units, which isn't always the case currently), and focus on defense. I do like the traders though. Also, they should keep developing the city and building districts.
 
Hey @Victoria it's not just simply making the less friendly but fixing the system that appears to be bugged somehow. See my observation below; do you agree and/or know the cause?


The AI being too friendly is a big issue indeed but unrelated to AI+ I think. Basically once you declare friendship and later became allies you can stay that way for the entire game without any effort. Nothing will piss them off you can wipe out their religion, ally their friends, break promises etc. When its time to renew friendship, even if there are more negative vs positive modifiers, they accept. Something is bugged or off balance in the code.

Also, except the very early game, it's very common for AI to accept friendship AND alliance the very first turn of meeting them. Again, seems like a bug in the code behind the scenes.. All this on Deity. There seems to be either some large hidden positive modifier or the thresholds for accepting friendship is bugged.
 
Sadly one suspects as do both of you this is code bound.
The accept envoys on the first turn is a good example of this that has always been there but they do seem to be throwing more into the bucket. The allies bit was there before R&F, I could be -100 with Barby for spying amd he would still open his sleeping bag for me.
I know the joint wars are not everyone’s cup of tea, they seem OK to me but where they are specifies seems code bound again.
Trade is a great example of the point that if you do not explain the concepts to the players they often get the wrong idea and in some cases it is broken. Code bound also and sadly the no communications policy is the safest way nowadays where the world is full of critics amd flamers.
 
So is Civ's AI hard coded into bunch of "if, then" clauses or does lack of DLL access means one doesn't even know how the AI code is phrased?

Could half decent results be met with simple conditions like:

******
production
if peace 10% of production on units.
if still not top military out of threats, 20% on units
if neighbor denounced, 25% on units.
if neighbor has 3+ units 5 hex away, 30%.

production if war is lasting:
if war distant: 30%
if war w neighbor: 40%
if a forward city faces defeat: 50%
if major city faces defeat: 60%
if capital faces defeat 75%

(all % until upkeep can be met)


when to decide to declare war (threats):
if opponent a neighbor- 10%
if opponent settles nearby- 10%
if opponent settles nearby again - 20%
if opponent buys land so it borders after purchase - 10%
if opponent tries to convert religion- 10%
if religion convert again- 15%
If opponent spies: 10%
if opponents spies again: 15%
if opponent makes a demand: 10%
if opponent denounces: 25%
if opponent has 3-4 units 5 hex away, 1% per turn. 50 turn duration.
if opponent has 5-9 units, 3% per turn.
if opponent has 10-19 units, 10% per turn.
if opponent is found to plan joint war - 30%
+special random modifier.
if some of the above has total of 100% or more, decision to go to war is made. units are first assembled and then war is declared.


special cases -
if opponent has city close, which has strategical resource that AI lacks and if 50% weaker - 10-50% (domination victory condition preference)
if opponent has city close, which has luxury resource which AI lacks, and if 50% weaker - 5-25%.

if opponent is 100% of strength as AI - AI looks into joint war. if joint war does not lower the percentage under 100%, AI does not declare war. all else is overridden.

military strength is each unit (certain units lose value if too disproportionate in numbers, like siege rams) times its attack value.

if war decided - check if there are multiple threats. weigh them. appropriate available units per threat. send units to a threat, close by. if war not declared yet, wait for declaration.
if war declared - check where threat's units are. check what can be seen. send stronger army, if possible. if army not stronger, then defensive stance.

if threat city nearby, check for units around it. check for approach vector. how many units could fire at once. how many turns would need to surround the city. how much damage would own units suffer while surrounding. if stronger, based on units and city strength, send units tasked to that particular threat/subthreat.
*****

and then have them subdivided into bunch of local sub-threat areas? Or would checking of all those mean 2 minute turns for AI to compute all that?
 
Could half decent results be met with simple conditions like:
sure or even an array each of these conditions is taking nanoseconds (10-100 maybe) and there is a billion nanoseconds in a second. You could code a million decisions and not notice if it was not for the pretty stuff and exceptions you also have to wrap around this code.
No access to the functions so no clues possible beyond what was seen in civ V
A deal screen does not slow a turn noticeably because it’s interactive.
 
Last edited:
So is Civ's AI hard coded into bunch of "if, then" clauses or does lack of DLL access means one doesn't even know how the AI code is phrased?

Lack of dll access means we can't see the code, correct.
But we do have access to xml files and logs, which betray a lot about the internal code. The system used also seems very similar to civ 5 codes in places, which suggests theres code reuse, and since we know the civ 5 code, we can infer some things.
It depends a bit on the system, but most of the internal civ systems use some kind of heuristics. For example building buildings, it calculates the worth of buildings based on the yields, then compares all the buildings and picks what it thinks the best one is. The desire for each yield can then depend on some factors
This is honestly probably one of the best approaches if done well, which it unfortunately isn't.

Internal diplomacy logic is a bit less clear. But it too seems to put certain values on items in a trade, and then calculates whether a deal is acceptable enough (also taking relationship into account)
Again, the problem isn't that it's a bad approach, it just doesnt seem to be tweaked very well. It doesnt make much sense to only accept 1 for 10 resource trades or something, even if you hate someone else, youll benefit from a 1 to 1 luxury trade.

Your declaration of war system actually looks a lot like what they used in civ 5, but they've done something entirely differently in civ 6. Luckily I'll be able to overrule (non joint) war declaration so I can try to build something better.
What you describe is computationally no problem. Usually you get into computational issues because of some algorithms with nested loops. Like, suppose you want to determine for every tile what the fastest path to every other tile is. Because of the large numbers of start tiles, the large number of destinations and the large number of possible paths you run into computational limits. A couple of small checks per turn for just one player is no big deal at all
 
So er, has anyone here tried to do an entertainment complex spam strategy to see if it was viable?

While working on the next version, something I did in my build logic made the AI spam entertainment complexes in every city. And while it looks dumb, funnily enough, I'm getting my best results with the new build system so far. As in, a prince level AI having both nationalism as well as renaissance techs in 1300AD while having plenty of troops.

And thinking about it, it does make some sense. They're getting much bigger cities with more districts, and are profiting from the % bonuses for happy cities + all the free culture and science on larger cities. It just never occurred to me to actually try spamming them.
 
So er, has anyone here tried to do an entertainment complex spam strategy to see if it was viable?

While working on the next version, something I did in my build logic made the AI spam entertainment complexes in every city. And while it looks dumb, funnily enough, I'm getting my best results with the new build system so far. As in, a prince level AI having both nationalism as well as renaissance techs in 1300AD while having plenty of troops.

And thinking about it, it does make some sense. They're getting much bigger cities with more districts, and are profiting from the % bonuses for happy cities + all the free culture and science on larger cities. It just never occurred to me to actually try spamming them.

I could try it out in my next game. Other people will probably be faster though.
 
I could try it out in my next game. Other people will probably be faster though.
One suspects it works for the AI because it is growth focused and often fills its card slots with Amenities cards. Maybe these districts are freeing them as well as giving them 10%.
Its a great thing you bring to the table @Siesta Guru because its not an area covered in a thread that I have seen and often there can be gems in that there dust.
One doubts it will be an optimal strategy but as said it seems like it may just suit the AI.
 
One suspects it works for the AI because it is growth focused and often fills its card slots with Amenities cards. Maybe these districts are freeing them as well as giving them 10%.
Its a great thing you bring to the table @Siesta Guru because its not an area covered in a thread that I have seen and often there can be gems in that there dust.
One doubts it will be an optimal strategy but as said it seems like it may just suit the AI.

Yes, I think you're probably right that it's mostly an AI thing.
But, math wise it does seem really tempting. With the district + arena providing 2 amenities together, that'll translate to an increase of 4 population if not housing/food capped.
4 population gives:
- On average maybe about 6 production and gold from tiles
- 2 science
- 1.2 culture
- The ability to construct another district

That's really quite good. And this is even ignoring zoo/stadium + potential to get Colosseum

Because of the extra district, if you can get at least 3 pop out of it, it should be an easy choice over any other district.
The question then just is what the odds are you'll get that 3-4 pop out of it, and how quickly you get it.
But even if you're not heavily amenity capped and get only 2 pop + the happiness bonus, it doesn't seem that bad compared to the first building equivalents of other districts.
 
Unfortunately I will have time only at the end of week...

Siesta, any ETA...? :) or some diary? :)

ETA wise, I'm afraid it'll be a while. At the very least a month.

Unfortunately I'm still somewhat stuck on unit control, and I'm at a point where I'm considering throwing the idea of doing micro control on units out of the window. I have two ways of controlling unit movement, and both just don't seem to work properly.
- Calling direct move orders is still giving me the rare double move where units suddenly walk twice as far as they can, which I can't seem to trace down to anything. It may be that the internal AI execution isn't actually halted while in my lua code, so that I have to beat the internal AI to the punch when it comes to ordering moves. On top of double moves, I'm also seeing impossible move+promotion turns etc.
Additionally, it seems to do something funky where it's making the internal AI stack units. I've seen cases where a barbarian unit (which I'm not controlling) moved on top of a players unit without attacking it. And leaders playing 2 UPT with their own units is super common too.

-Ordering units around with operations has so far been very unpredictable, with units not always moving where I order them to / with them not attacking even though I order them to. Since I can't see the eventual results of my orders (since they happen after my code execution), I can't adjust. So it ends up doing weird moves, like settlers moving onto tiles they think they'll be protected on, while the protector chose to do run off. I also can't find a reliable way of doing 'end turn' yet, with units either running off when they have mp left, or somehow fail to heal even while standing still.

It's too bad, because it actually works pretty decently when it's not bugging out. Civs lose far less units against barbs even with my initial simple micro logic.

On building choices I'm making good progress. So far I've not encountered any weird issues with the internal AI being in the way or with lack of control. I'm now working on my own build choices evaluation system and it's coming along nicely. I'm basing 95% of it on variables I can read out of the database, to support mods etc. It already handles some things better than the default, but still has big gaps (like currently it doesn't do any projects yet)

The settling spot choice logic is working well too. Spots chosen seem superior to the inbuild AI. Due to the unit microing system, they also get to their destinations much faster on average, but yeah, that's going to have to be abandoned if I can't get it to work bugfree.
 
After applying yeild fix and medieval fix - noticed AI being able to runaway alot easier and it seems monarchy is not (yet) as rampant(emperor, epic, large around 0 AD im about 100 science and im fourth ). ...and in 2 of my games gandhi has been domination spree... this is without a.i+ - was bit surprised to see Gandhi wipe out Japan (2lovely border neighbours)also I have not been able to get gpt out of my greatworks as much I used to aswell. Was this medival fix applied in a.i+ before?

Is it possible for you to release modules for us to test? like building choices, settling etc..

Thanks for the updates on progress!

btw: move and promotion as impossible move? thats how it works normally - if you have mp left you can promote after you moved.
 
After applying yeild fix and medieval fix - noticed AI being able to runaway alot easier and it seems monarchy is not (yet) as rampant(emperor, epic, large around 0 AD im about 100 science and im fourth ). ...and in 2 of my games gandhi has been domination spree... this is without a.i+ - was bit surprised to see Gandhi wipe out Japan (2lovely border neighbours)also I have not been able to get gpt out of my greatworks as much I used to aswell. Was this medival fix applied in a.i+ before?

I actually delete the medieval changes thing from the base game entirely in AI+. So the fix won't do anything if they're combined. I've got my own version of an era based yield changes implemented which isn't as weird. (the default one has all of those era based changes stack)

Is it possible for you to release modules for us to test? like building choices, settling etc..

I might to that for the next version if I find the time.
It's a bit lower on the priority list though as it would have to mean testing and maintaining several versions at the same time. It'll also be harder to collect feedback. Placebo reports are already pretty common, and they'll probably become even more common and harder to detect if everyones running around with different versions.
What I might do is to just split it up in a competitive and a roleplaying AI, with the latter being a bit less warlike/backstabby etc.

btw: move and promotion as impossible move? thats how it works normally - if you have mp left you can promote after you moved.

Oh yeah I just meant impossible moves. Like having a unit move on top of a a wooded hills while promoting the same turn. I've even seen it do a promote+attack
 
Hey Siesta and folks ;):lol::love: , here are some more observations with the AI using the newest AI+ patch Siesta sent to Abd121, at https://forums.civfanatics.com/attachments/ai-hotfix-rar.491256/. However, this patch is not available from steam workshop yet. Sorry for the pictures spam below, i hope the picture provided help to give clarity to the descriptions.

I am using the above Ai+v12 hotfix patch (together with yield spelling fix but without the Medieval spelling fix), here are some things i noticed in my deity games.

A) The AI now is able to build commence district and markets and able to fund their big armies . ( i think Siesta managed to ameliorate on that part where the AI can't get enough gold to pay for the maintenance). The Ais now are able to compete with one another for Great merchant points as well as all the other GPs.

Nice econs.png


B) The AI is a lot more challenging since with a bigger army, they are able to flank my units using military maneuver that looks like the triple pincer movements of the hannibal / romans, sandwiching my poor units and even go for my unprotected cities before going for my capital.

1Mongol units surround my ranged and catapults first.png


C) At AD 120, mongols already have a military score of 1770. About 4 AIs have a score of over 1000.

5 120AD Ai score 1770.png


D)They are also able to capture my walled cites and walled capital (with garrison) with no difficulty.

2Take my nearby walled city also.png


4Ai captured my walled city with garrison.png



E)Last picture shows during renaissance era, the top ai(germany and Mongol) have a military score of 2.2k/2.5k , whilst many more have scores around 1.5, compared to my score of 750.

6 Ai have high scores.png


F)After allying with mongol and advancing east, China orchestrated a suprise attack on me. 100 turns later, One strange thing i noticed is that even Mapuche is angry at me, they did not sneak attack me while i am attacking china. Is it possible to make AI more able to seize opportunities?
 
Last edited:
Back
Top Bottom