Liberated city

grandad1982

Deity
Joined
Dec 4, 2007
Messages
2,552
I'm just playing a game as Pericles of the Greeks.

Mao just liberated a city to me. It was under cultural pressure but not a huge amount, maybe about 20%ish. The diplo situation is he likes me +4 and is pleased.

What determins weather the AI will liberate a city to you? Is there a way of forcing or predicting it?

Just as an aside the city is a bit bubbish but it does help me block him in even more. The fool.
 
While I don't know the code for the game, I believe it happens more often if the city is mostly your city via culture and the AI doesn't "think" it can hold it by culture.
 
I don't know the game mechanics, either, but I'm guessing that he has to like you. I know I've had cities that had enough tile culture that I had the plurality (higher percent of the culture was mine than anybody else, even though I've never owned the city) and nearly a simple majority (48% mine). I even threw in a few culture missions via espionage. When I eventually took the cities by war (he attacked me without provocation), I had enough city culture to expand two rings.

I have to conclude that there's more than just culture at play here.
 
First I have to say I'm bad beyond human imagination in regards to code reading...
I think I might found the string of code ruling the AI behaviour.

It was found in the following directory:

C:\Program Files\2K Games\...\Beyond the Sword\CvGameCoreDLL

The file in question is CvPlayerAI.cpp.

Spoiler :
if (!(GET_TEAM(getTeam()).isAtWar(GET_PLAYER((PlayerTypes)iI).getTeam())))
{
if (AI_getAttitude((PlayerTypes)iI) >= ATTITUDE_CAUTIOUS)
{
for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
{
if (pLoopCity->getPreviousOwner() != ((PlayerTypes)iI))
{
if (((pLoopCity->getGameTurnAcquired() + 4) % 20) == (GC.getGameINLINE().getGameTurn() % 20))
{
iCount = 0;
iPossibleCount = 0;

for (iJ = 0; iJ < NUM_CITY_PLOTS; iJ++)
{
pLoopPlot = plotCity(pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE(), iJ);

if (pLoopPlot != NULL)
{
if (pLoopPlot->getOwnerINLINE() == iI)
{
iCount++;
}

iPossibleCount++;
}
}


if (iCount >= (iPossibleCount / 2))
{
setTradeItem(&item, TRADE_CITIES, pLoopCity->getID());

if (canTradeItem(((PlayerTypes)iI), item, true))
{
ourList.clear();

ourList.insertAtEnd(item);

if (GET_PLAYER((PlayerTypes)iI).isHuman())
{
//if (!(abContacted[GET_PLAYER((PlayerTypes)iI).getTeam()]))
{
pDiplo = new CvDiploParameters(getID());
FAssertMsg(pDiplo != NULL, "pDiplo must be valid");
pDiplo->setDiploComment((DiploCommentTypes)GC.getInfoTypeForString("AI_DIPLOCOMMENT_OFFER_CITY"));
pDiplo->setAIContact(true);
pDiplo->setTheirOfferList(ourList);
gDLL->beginDiplomacy(pDiplo, (PlayerTypes)iI);
abContacted[GET_PLAYER((PlayerTypes)iI).getTeam()] = true;
}
}
else
{
GC.getGameINLINE().implementDeal(getID(), ((PlayerTypes)iI), &ourList, NULL);
}
}
}
}
}
}
}


All I can say if I understood...a big if rly...the green colored lines seem to be meaningful:

if (!(GET_TEAM(getTeam()).isAtWar(GET_PLAYER((PlayerTypes)iI).getTeam())))

seems to say not under war state...

pDiplo->setDiploComment((DiploCommentTypes)GC.getInfoTypeForString("AI_DIPLOCOMMENT_OFFER_CITY"));

I have seen the corresponding XML file and the AI diplo response was about city gift.

If I understand, a CAUTIOUS AI may give cities.

It looks like the orange section is about the inner mechanism...city condition for city gift?

May a new generation DanF5771-like people helps me...pleaaase.

I expect no answer, but if some people may give some pointers, I will glad to receive it. :D
 
This didnt happen too often in my games. Whenever it happened it was due to the city being culture crushed.

I even had 1 AI settle a city next to my capital and then gift it to me after 1 turn. I think some surrounding city just got a border pop. I would not really count on that one , though.
If you happen to lose an inner city and a third party retakes your city, you usually get it back in a couple of turns. That one is pretty reliable.

About the code: it seems that the attitude of the AI has to be cautious at least. The rest i dont understand.
 
I love your avatar, what's it from?

Humanoid form of GlaDOS. From Portal. I stumbled on a image featuring many facial expressions and I loved it.

=========================================

No code reader...sad...any. VoU, you are a code reader, right? It looked like in some old posts three years ago.

I am thinking if I should forward this to the mod creation section...
 
... summoned back to the fanatic board to try to shed some light on dark lines of civ code :wavey:
... a bit rusty though ... well, here is what i read:

already covered:
  • city-owner's attitude towards the player needs to be 'cautious' or better
  • player must not be at war with the city-owner (other wars don't matter)

new:
  • city has never been controlled by the player before
  • the liberate-city offer can only happen during the exact 4th inbetween-turn after the city-owner acquired the city, next opportunities occur in intervals of exactly 20 turns :crazyeye:
  • player needs to own at least half of all possible city plots, normally that would require 10 (due to integer division) of the 21 city plots, less in case the city is located at an edge of the map
  • the city must show up as a tradeable item in the diplo screen with the white line of text "city name (Liberate)", i.e. the player needs to fulfil the city's getLiberationPlayer condition which is a function of city culture and distance to the respective capitals. The city must also be unthreatened, if there is a visible enemy unit within the city radius then it cannot be liberated (-> "You'll have to take it from our cold, dead hands.")
  • there is (most likely) no randomness involved



test scenario:
  • HC will conquer the barb city on game turn 21 - 3160 BC
  • the barb warrior behind the rocks 'threatens' the city -- it cannot be liberated -> remedy via amphibious axe attack :hammer:
  • 11 of the 21 city plots are within Roman borders (can also be water tiles) -> during IBT 25/26 - 2960 BC Huayna Capac is in the mood for a gracious act of generosity :yeah:
 

Attachments

Wow great analysis Dan. Very interesting to know.

It's certainly a lot harder to culturally dominate other players in Civ 4 than it was in Civ 3 and certain builds of FreeCiv (spies were pretty much the best unit in the game)
 
Yeah, wow. Thanks for coming back just to clear that up. :thanx:
 
The HELL! :eek:
DanF5771 itself explaining the mechanism of liberation.
This is something I wouldn't ever expected since he looked retired from CivFanatics.

I guess this r_rolo1's doings. Thanks a lot.

In regards to the mechanism, it is quite interesting by the lack of randomness, we can make it a small tactic to gain a free city. Nonetheless, this is usually hard, but comes easier on marathon as most mechanisms are badly scaled.

:scan:
 
Mysteries ? Well, there are some, mainly because there has been a really heavy shortage of code divers since civ V got out ( some ported out, others recoiled in horror after seeing that mess they delivered :/ ). it got to the point that people ask me code stuff :D but the bigger issue is that the good stuff that people ask over and over again is scattered round ( proable that is why they created the content staff position recently , to clean up the thing a little )

Cool tricks since you're gone ? Well, not much really ... there are some issues to solve since the last UP ( like for example one I discovered in one of my last offline games, where entering future era made the active quest I had to fail ) , but tricks that you don't know ... not sure if there is any :D
 
civ is good ... in moderation :)

:lol: 2 years between posts isn't moderation to my point of view. :hmm::D
But really, I am curious what brought you in this lone (usually what I ask is kind of question in relation to mechanisms and they are not popular) stolen old thread.

Now you are around...he he...:mwaha:...can I poke you for some later specific questions?...under condition...I do some dirty work to find the code segment I guess.

Hmmm...I already have to unearth some of my old threads having interesting unconclusive answers...

Anyways, here's my shake hand :goodjob:, nice to meet you. Like Oyzar, I thought you weren't contemporaneous to my time.

it got to the point that people ask me code stuff :D

load? ... really?

Unless I misunderstood the correlations, I am of these people poking too much. ;)
 
BTW, in a halted deity game (I had to stop it due to huge lack of time),
I almost found an opportunity to try your conclusions ,DanF5771.
And it wasn't done in a way it would impede my progress that much.

In the screenshot, I founded a city on the grass hill 1N of the fortified archer.
Being solid creative leader (Zara), I expected no much later to control 11 tiles out of 21.
The target city is a turd, true that, but it has no pillageable iron (not visible but can be guessed). Before that city (not founded long ago), evil Shaka was bragging about Chariots. If I remember correctly, if the AI doesn't have strong many types of units, it won't go after someone.

Guess the use if Shaka was about to give the city to me if I intervened some turns earlier, he would have handed me his lone source of iron.
That would be epic...:p


In a nutshell, the explanations you posted is a micro-tactic that can be useful in some (but rare) occasions. Tactic due its random feature absence.
On slower speeds like Epic and Marathon, that tactic should be strong.

Oh yeah, that screenshot was taken because I was about to ask question about stupid AI switching defenders, leaving city undefended.
 

Attachments

  • No city guarding!.jpg
    No city guarding!.jpg
    177.6 KB · Views: 253
That one is because AI chariots rarely get the role of defending cities . that one most surely was with CITY_ATTACK ( IIRC ) and scrip changes don't happen that often as that when the AI take a city ( other example is what our dear LEMMING uprise barb sometimes do when there is a city in the way to their target: they attack it no matter the owner being the real target or not and, if conquered they leave it to continue to their target ). jdog5000 had something about this in the betterAI subforum IIRC ( again ) :p

P.S Do not take my comment as you being annoying or not. I was just pointing to dan that now I'm in the other side: 2 years ago i was making the questions :p
 
Of the 2 times I've been gifted a city, I'm pretty sure there were no option to disband it, so it's worse than taking it thru revolts.
 
Tachywaxon said:
But really, I am curious what brought you in this lone (usually what I ask is kind of question in relation to mechanisms and they are not popular) stolen old thread.
got pointers by a friend who said something about 'desperation' ... ;)

Tachywaxon said:
can I poke you for some later specific questions?
sure, although I definitely won't be able to return to the responsiveness of former days ... :coffee:

Tachywaxon said:
Guess the use if Shaka was about to give the city to me if I intervened some turns earlier, he would have handed me his lone source of iron.
That would be epic...

indeed hahaa!
however, it wouldn't have been easy -- deity AI basterds only need like 17 hammers (classical era) for a monument :mad:, which is often the very first build. Once the AI has >~2 city culture you need spread culture missions ... :undecide:
Shaka is also very likely to drop <Cautious due to close borders ...

As to Shaka leaving the city undefended - to be honest, I've never seen a regular AI do that. :confused: r_rolo1 is most likely right about the Chariot's AI ~= UnitAI_City_Defense.

nfw said:
Of the 2 times I've been gifted a city, I'm pretty sure there were no option to disband it, so it's worse than taking it thru revolts.

right, disbanding is not possible, but compared to revolts the advantages imho are:
  • no randomness (as mentioned several times)
  • independence of culture garrison units
  • you can avoid long periods of diplomatic tensions sparked by close borders with proper planning
  • cities can be acquired without having any culture in the city / on the plot (as long as the AI has a city-culture of / near to zero)

r_rolo1 said:
I was just pointing to dan that now I'm in the other side: 2 years ago i was making the questions
:goodjob: :high5:
 
Back
Top Bottom