For those interested in AI logic

Gazebo

Lord of the Community Patch
Supporter
Joined
Sep 26, 2010
Messages
18,400
Location
Little Rock
I was inspired to answer this reddit question, and thought you all might enjoy the light read:

https://www.reddit.com/r/civ/comments/45kbcg/ai_layers/czypn4c

I'm always happy to answer questions about the AI's behavior, as it is a fascinating beast. For all of the vanilla game's flaws, the Civ 5 DLL is a pretty ambitious thing!

Cheers,
Gazebo
 
I think I can speak for all of us when I say thank you for taking a couple afternoons to meddle in the code to improve behavior. The game plays a little better as a result. ;)
 
The vanilla AI does not have certain functionality that humans have, but humans also don't have functionality that AI has (asking to move troops from your border, for example). Which is a shame because such things can greatly improve immersion for the human player. I wonder why they decided to have so much separation between humans and AI.
 
The vanilla AI does not have certain functionality that humans have, but humans also don't have functionality that AI has (asking to move troops from your border, for example). Which is a shame because such things can greatly improve immersion for the human player. I wonder why they decided to have so much separation between humans and AI.

Actually, it does now (border request)! :)

Also, did you see that I moved the DLL function defines for C4DF out of C4DF and into the CP? I did this for LUA (was breaking lua in the CBP that I wanted to use in all lua files). Make sure to remove them from the C4DF, as they're not needed there anymore:

Spoiler :
Code:
-- C4DF

-- Insert SQL Rules Here 

ALTER TABLE GameSpeeds		ADD		ShareOpinionDuration			integer;									-- How long do we have to wait after Share Opinion rejection?
ALTER TABLE GameSpeeds		ADD		TechCostPerTurnMultiplier		float;										-- How much does each turn of research add to tech cost?
ALTER TABLE GameSpeeds		ADD		MinimumVassalTurns				integer;									-- Minimum turns of vassalage (before we can break it off)
ALTER TABLE GameSpeeds		ADD		MinimumVoluntaryVassalTurns		integer;
ALTER TABLE GameSpeeds		ADD		NumTurnsBetweenVassals			integer;									-- How many turns we must wait (after we've revoked vassalage) before they'll sign a new agreement)
ALTER TABLE Technologies	ADD		VassalageTradingAllowed			boolean;									-- Enables Vassalage (tech)
ALTER TABLE Eras			ADD		VassalageEnabled				boolean;									-- Enables Vassalage (era)
ALTER TABLE Resolutions		ADD		VassalMaintenanceGoldPercent	integer	DEFAULT	0;
ALTER TABLE Resolutions		ADD		EndAllCurrentVassals			boolean	DEFAULT	0;

G
 
Fine, fine...a couple evenings/nights (considering when new versions get posted!).

It's pretty amazing. We've been working on this for over a year now, so the iterations are hard to really quantify/qualify in terms of difference. For fun, I booted up vanilla the other day and autoran a game. Holy cow. We've done so much.

Also, I think the builder plot AI rework I did for 2-13 will be almost as game-changing as the city production sanity logic. The AI is so, so much better at building improvements in the proper places.

Funak, if you're reading this, I specifically got the AI to build villages and towns on roads (and almost always just roads) just for you. :)

G
 
The only "problem" with you is... I just cannot keep up with you. I have probably started dozens and dozens of CBP games in the last few months, and I barely remember finishing 2. Yes, TWO.

Amazing. Specially for a couple of evenings... :D
 
Actually, it does now (border request)! :)

Also, did you see that I moved the DLL function defines for C4DF out of C4DF and into the CP? I did this for LUA (was breaking lua in the CBP that I wanted to use in all lua files). Make sure to remove them from the C4DF, as they're not needed there anymore:

Spoiler :
Code:
-- C4DF

-- Insert SQL Rules Here 

ALTER TABLE GameSpeeds		ADD		ShareOpinionDuration			integer;									-- How long do we have to wait after Share Opinion rejection?
ALTER TABLE GameSpeeds		ADD		TechCostPerTurnMultiplier		float;										-- How much does each turn of research add to tech cost?
ALTER TABLE GameSpeeds		ADD		MinimumVassalTurns				integer;									-- Minimum turns of vassalage (before we can break it off)
ALTER TABLE GameSpeeds		ADD		MinimumVoluntaryVassalTurns		integer;
ALTER TABLE GameSpeeds		ADD		NumTurnsBetweenVassals			integer;									-- How many turns we must wait (after we've revoked vassalage) before they'll sign a new agreement)
ALTER TABLE Technologies	ADD		VassalageTradingAllowed			boolean;									-- Enables Vassalage (tech)
ALTER TABLE Eras			ADD		VassalageEnabled				boolean;									-- Enables Vassalage (era)
ALTER TABLE Resolutions		ADD		VassalMaintenanceGoldPercent	integer	DEFAULT	0;
ALTER TABLE Resolutions		ADD		EndAllCurrentVassals			boolean	DEFAULT	0;

G

Cool, done!
 
It's pretty amazing. We've been working on this for over a year now, so the iterations are hard to really quantify/qualify in terms of difference. For fun, I booted up vanilla the other day and autoran a game. Holy cow. We've done so much.

Also, I think the builder plot AI rework I did for 2-13 will be almost as game-changing as the city production sanity logic. The AI is so, so much better at building improvements in the proper places.

Funak, if you're reading this, I specifically got the AI to build villages and towns on roads (and almost always just roads) just for you. :)

G

I've been following CPP from pretty early on (it's when/why I made an account here). I haven't been paying attention throughout that whole time though, real life usually involves me completely ignoring Civ for months at a time followed by periods of probably playing too much. :)

Every time I revisit after a hiatus, I'm blown away by the improvements made in the meantime. I have to be careful on here before talking about things the AI "can't do," as it's likely been fixed since I was last aware. Recently I was trying to get a map script compatible with CBP, and I elected to take the quick and dirty route because I frankly didn't care about breaking compatibility with vanilla--just like I couldn't go back to older Civ games once BNW was released, there's no way I can go back to playing vanilla BNW now. Way too much has been improved upon to ever go back.

I'm about to leave on vacation (my first attempt at skiing!), but I can't wait to try out these new optimizations when I get back in a week--though I'm sure there will be at least 2 new betas and probably a new stable version by then. :rolleyes: The plot improvement/selection work has me really excited...it hasn't been bad, but as someone not familiar with the DLL it's struck me as the most obvious potential for further AI improvement for a little while.
 
Funak, if you're reading this, I specifically got the AI to build villages and towns on roads (and almost always just roads) just for you. :)

I know, I read the patch-notes, worked out fine in my testgames as well, automated iroquois workers still build unnecessary roads all over the place however.
Also seems to want to cut down forest and replace them with farms while playing Iroquois, no idea if this behavior is new however as I usually play with "Automated workers don't replace features) when playing the iroquois, if I even use automated workers.


The AI also seems to put a lot more value into building farms and roads than actually hooking up luxuries, in my current Zulu-game I have 15 farms, 15 road tiles and 0 improved luxuries.

Great work.
 
I know, I read the patch-notes, worked out fine in my testgames as well, automated iroquois workers still build unnecessary roads all over the place however.
Also seems to want to cut down forest and replace them with farms while playing Iroquois, no idea if this behavior is new however as I usually play with "Automated workers don't replace features) when playing the iroquois, if I even use automated workers.


The AI also seems to put a lot more value into building farms and roads than actually hooking up luxuries, in my current Zulu-game I have 15 farms, 15 road tiles and 0 improved luxuries.

Great work.

Roads are useful even for the Iroquois and Songhai. Sure, they could use more work, but it's barely a problem.

Luxuries not being improved was a bug - fixed in hotfix.

G
 
Roads are useful even for the Iroquois and Songhai. Sure, they could use more work, but it's barely a problem.
Well, I still think they could get free roads on their autoconnecting tiles, they are wasting that part of their UA.

Luxuries not being improved was a bug - fixed in hotfix.
Kinda figured that out eventually, I invaded my neighbor and he had farmed desert-tiles and unimproved jade-hills :D
 
Also, I think the builder plot AI rework I did for 2-13 will be almost as game-changing as the city production sanity logic. The AI is so, so much better at building improvements in the proper places.

G

Don't tell anybody I told you this, because I know it's a highly taboo topic, but I actually feel pretty comfortable automating my Workers now.
 
Don't tell anybody I told you this, because I know it's a highly taboo topic, but I actually feel pretty comfortable automating my Workers now.

People actually control workers manually? Forget that, it's way too much effort :D
 
I'm still sad that I can be the last in score, be attacked by my 4 civ (3 neighbours) at the same time, and win without any effort (I did not lost a single unit).

First thing : Gandhi could see all my units before the war started (they were on the border one of his city, a weak and undefended one). I was clearly ahead on the front, with a lot of conquistadors. Still, he declared war without blinking (he lost 2 cities and sent around 3 ... spearmen !)

I have the impression the tactical AI actually regressed in my last games.
I've seen a lot of boats not attacking, just standing around and getting fired at like this one : http://steamcommunity.com/sharedfiles/filedetails/?id=625995697 (in this game I'm actually at war with Pacal, Pedro and Gandhi, all the top cities in my empire were theirs before)
It also seem to me that the AI is putting to much value in UU : Pacal has been keeping a lot of UU around, I've been stomping them with Conquistador ... (he is first in tech).

Freshly taken cities are quite vulnerable, one caravel could have taken back one city I conquered. But no, Pedro left them sitting just next to the city. His lost (I know that I could have taken the city again, and kill his caravel, but he would also have killed my unit).

Weird moves like this : http://steamcommunity.com/sharedfiles/filedetails/?id=625999309 (Don't see how Pedro would not have visibility). (quick edit : this just happened AGAIN, exactly the same move with exactly the same unit, I killed the previous one, finished my turn, here is a new one ...)

Well, you got my points. I love the new plot improvement AI, but the tactical AI is not challenge at all anymore, I'm under the impression that the AI actually regressed.

Edit : here is Pacal sending obsolete units (with a few longswordmen) under a heavily defended, hill surrounded city : http://steamcommunity.com/sharedfiles/filedetails/?id=626001713
My capital is harder to defend, surrounded by plains, with less units around. I have no clue why he is insisting to come here and die.

Edit 2 : No clue if this should be analyzed somewhere else, and if I should provide a save. Playing with latest beta and nothing else (I'm a pure CBP player <3 )

Edit 3 : Serial Editor inside. The goal here was to point out some behaviors which look fishy to me. I know that the AI is dumber than a human, and that I may be biased - especially about vision range, etc. I also remember that the AI does not have a tactical memory apparently. If none of the above are relevant criticism, feel free to send me back to my cave !
 
@Deluxe,

yes, I am also under the impression of an AI regression... specifically, more suicidal embarkations, and moves like the ones you pictured (lone units committing suicide moving into the bulk of my forces).
 
I've seen some problems with the Ai worker logic, sometimes they build one extra tile of road that doesn't really add anything. Sometimes they get stuck replacing improvements over and over again mostly village to farm/mine and back again, usually tiles on a road.

EDIT: Really minor problems compared to how the AI started out, worker automation is actually usable now.
 
Right after I posted about being comfortable automating my Workers, I was playing last night and my Workers built Trading Posts over all my Landmarks. I didn't notice it until it was too late :( I have since gone into the Options and checked off "Workers don't remove Improvements," so I'll have to be more vigilant when Strategic Luxuries pop up under existing improvements.
 
Back
Top Bottom