Order of AI computation

anarres

anarchist revolutionary
Joined
Apr 22, 2002
Messages
6,069
Location
www.civ3duelzone.com
Do you know the exact order of AI computation during a turn, for production, upkeep, research, trades, stuff like that?

If so, please spill the beans, because I want to know. I have looked around and can not find anything related...

As far as I know, in PTW they changed the order of science and production calculations at the beginning of a turn. In civ 3 vanilla it used to do production, then science. Now it does science, then production.

The result of this particular change is that if you are about to build ToE and have 1 turn left to research a tech (Nationalism, say), it will finish Nationalism and then complete ToE, allowing you to get 2 free techs on top of Nationalism. Under the old system, production would be done first, so ToE would have been built giving only 1 free tech and Nationalism (as it would finish Nationalism for you).

I figure that the exact order of AI computations must be known to people, even if not by one single person. It would help me a lot to understand this, and it would be an invaluable source of information.

Edit: I know it's a bit silly, but here is my 1000'th post dance:
[dance] [dance] [dance]
 
Interesting question anarres, I personally thought the order was like this:

First, at the start of the turn, science and commerce is taken care of for all your cities at one time, then for all AI empires after that. Then per city, I believe in order of the date the city was founded (not sure of that though):

1. checks for unhappiness
2. increase food bar/city growth
3. production added to current build project

Trades with AI empires always end exactly 20 turns after they are established, so if you traded during your own turn, the trade will end after the "upkeep phase" (including building stuff etc.), before you can move your units. If you made the deal during an AI's turn, it will end during the AI turn, before your building/growth phase (and thus unhappiness check phase), because the AI states its offers before your building phase.

So there should be three phases:

1. general commercial processing phase (every empire, starting with yours, gets beakers/gold added in this phase).
2. building phase (starting with yours, every empires gets unhappiness check/growth/production).
3. movement phase (starting again with you, and when you finish AI moves).

Anybody any other ideas?
 
The Nice One would disagree about the trade thing, as that is what I said, but he said not.

I have posted a link from that thread to this one. Hopefully we can resolve all of these issues together.

I agree that the start appears to be:

1: Science / Commerce calculations
2: Happiness check
3: Food calculation (including growth)
4: Production calculation

I'm not sure if it would make any difference if 2, 3 and 4 are done for each city in turn or if 2 is done for all cities, then 3 for all cities, then 4 for all cities.

If the next step is

5: Movement (including diplomacy)

for each civ in turn numerically, then as player 1 you will always go first. In PBEM games you may be player 5, with player 1 human as well and all the other civs as AI's.

I need more convincing that your 'three phases' are correct. If they are, then when you are in the movement phase the AI has already had their upkeep done for their cities. This has serious implications on multiplayer games, as player 1 may be attacking player 5, and player 5 has already had unit upkeep and the chance to finish building units/etc, even though their movement is yet to happen.

It would make a perverse kind of sense if you are right, and it will effect PBEM games...
 
The difference that 2,3,4 are not done at the same time gives the human player a valuable edge by zooming in on a city and then use the toggle city buttons to change/repair production/happiness/growth in other cities that haven't had such an upkeep yet.

Also, I'm hesitant to limit diplomacy to the movement phase, because you can access the foreign advisor and conduct diplomacy if you use "what's the big picture" when you gain a scientific advance. That's diplomacy in between the general commercial phase and the prodcution phase.

The reason I think that this 3 upkeep phase thing is correct is because I thought I remembered you can see it happening when the AI liberate one of their former cities you captured. They immediately have an additional defender built (at least in vanilla civ they had, I haven't lost a city to the AI on PTW yet :D), so apparently they have had a production phase after the end of their previous movement phase. (this is before Nationalism and drafting).

The reason you don't see this with flips is IMO that the AI can't rush production (or draft citizens for that matter) during his production upkeep phase like the human can, using the "toggle cities" workaround.

Another thing that points to the direction of an upkeep for all players before the movement phase, for example, is the finishing of wonders. If an AI has a wonder on 1 turn, it finishes on the next turn after your production phase, indicating the AI production is handled after your own production phase, and not just before their movement phase because if you and the AI both have a wonder at 1 turn you'll be the one who finishes first.

As for the multiplayer thing, in (turn-based!) LAN-games I've played so far it works exactly as you say: all players got their production at the same time, then player 1 moved, then player 2 etc. , meaning that if player 1 attacked player 5, player 5 would indeed already have built units that turn.

I'm not 100% sure myself, but I've always believed the three phases thing to be correct.

edit: added multiplayer thing
 
Originally posted by Kemal
The difference that 2,3,4 are not done at the same time gives the human player a valuable edge by zooming in on a city and then use the toggle city buttons to change/repair production/happiness/growth in other cities that haven't had such an upkeep yet.

...

The reason you don't see this with flips is IMO that the AI can't rush production (or draft citizens for that matter) during his production upkeep phase like the human can, using the "toggle cities" workaround.
That is true, I can't think why I forgot about that.

Oh, yes I can. It's an expliot :nono:

The rest seems to make sense, even if it is a bit backwards...
 
Originally posted by anarres
That is true, I can't think why I forgot about that.

Oh, yes I can. It's an expliot :nono:


Maybe for you and the tournament staff it is, but in the GotM competition here at CFC it has just been given the green light, so it certainly isn't an exploit by default.
 
Well i posted that I thought that using 'the big picture' and 'toggle cities' was an exploit in a GOTM thread. You can shave off a turn using them. No less an authority than Aeson was quoted to suggest otherwise.

You're not allowed to get the gold then change to production the same turn to double count your production - which is possible.

In a recent pbem game I knew a temple was due to complete on the same turn that my pop would grow pushing me over the unhappiness limit. I thought the temple completion would prevent it. What happened is that the pop grew first, the city fell into disorder so the temple never got built.

That would suggest that food/pop growth occurs before unhappiness is calculated, wouldnt it?
 
Originally posted by col
Well i posted that I thought that using 'the big picture' and 'toggle cities' was an exploit in a GOTM thread. You can shave off a turn using them. No less an authority than Aeson was quoted to suggest otherwise.

You're not allowed to get the gold then change to production the same turn to double count your production - which is possible.

In a recent pbem game I knew a temple was due to complete on the same turn that my pop would grow pushing me over the unhappiness limit. I thought the temple completion would prevent it. What happened is that the pop grew first, the city fell into disorder so the temple never got built.

That would suggest that food/pop growth occurs before unhappiness is calculated, wouldnt it?

You're right about the "goldminer exploit" there col, that is forbidden in gotm. As for other uses of this "what's the big picture"stuff, I'll just follow cracker's statements about this when playing gotm games.
In casual play, I find this too much of a hassle to use unless the AI threatens to get TOE or the spaceship 1 turn earlier than I. (as happened to someone in the last gotm). I certainly wouldn't use it in multiplayer games (if possible) unless agreement about it had been reached by all participants.

As far as the unhappiness is concerned, I can't explain what happened in your game. Your situation would certainly suggest food before happiness, but I'm pretty sure unhappiness is checked before food/growth is handled.
It can be used really well to bypass the need of an additional military police or luxury tax on deity/emperor by making sure your settler is finished on the turn the city grows to size 3. :)

Maybe you had additional war-weariness that turn, or maybe it was just a bug. There are many varieties of those in civ3... ;)
 
I agree with Kemal about the happiness before food.

I often have cities that are going to grow to an 'unhappy' size at the end of the turn, but then you can move a unit in after they have grown and are unhappy.

How can we be sure that production doesn't happen before food as well though? I agree that if you end a turn with more unhappy than happy, it is irrelevant if a temple will finish as the happiness goes before production. This is well observed behaviour.

It could be that for each city in turn it calculates:

1: (un)happyness
2: Production
3: Food

This is not only possible, but I am sure the extra shields from growth are not taken in to account for production, implying that production is done first.

Oh, and about the 'toggle city' thing, the AI is unable to do it in any way, and so how can it not be an exploit? We have not discussed it for the tourney yet for season 4, but I think last season it was informally considered an exploit. In spacerace entries, I think it was not permitted to switch to the last component the same turn you researched it by the 'toggle city' method.
 
Originally posted by col


In a recent pbem game I knew a temple was due to complete on the same turn that my pop would grow pushing me over the unhappiness limit. I thought the temple completion would prevent it. What happened is that the pop grew first, the city fell into disorder so the temple never got built.

That would suggest that food/pop growth occurs before unhappiness is calculated, wouldnt it?

col, I think when your not using the governors you are given a 1 turn period of grace to set your city so it does not fall into disorder but I have seen the bug that you describe (I'm not sure why the production of a temple/or whatever would make you lose this little advantage), makes one fall back on using the governors at times. Bamspeedy wrote a nice little piece on these goveror quirks awhile back.

As for the exploit, that is allowed in GOTM, I guess since you can't police the activity, you have to allow it. Too bad some of these quirks weren't ironed out before PTW. Once they fix the free science tech era program error that Mike B. pointed out, the whole situation will be so out of hand that people will be launching space ships before 1000AD on Regent games.

anarres, I thought that production from growth was used in the same turn but maybe that is a difference in Civ3 and PTW (I'm pretty sure this 'feature' helps my settler factories). As for the 'toggle city' exploit I guess if you have to submit the GOTM game before the actual win, you cut that little loophole quite nicely. Bit, with this turn the game in after you win, then all these little loopholes become more prominent that they were in the past.
 
Strange that after all this playing we still dont know the basic mechanics of the game! I think there's a suspicion that ptw has changed the order somewhere too.

I cant remember the state of the governor in the game referred to above - but it was earlyish in the game and I'm pretty sure Id have been micromanaging everything then.

In tournament games I've verified, I have in some cases put the end date back one turn so that everyone is using the finish rule - especially important in a game where finish date is 90% of score.
 
I am more than willing to be wrong about the city growth adding to production. In fact, I can remember toggling tiles the turn before growth, just so I can make sure it selects a 2.2.2 tile when it grows.

Hmm. Testing tonight...
 
Originally posted by col


I cant remember the state of the governor in the game referred to above - but it was earlyish in the game and I'm pretty sure Id have been micromanaging everything then.


col, I'm pretty sure you had the governor off, else it would not have gone to disorder before getting the temple. ;)
 
of course - I see what you mean.
 
I don't have very much to add here, as I've never really checked this, but have one comment:

Anarres is wrong in his first post about civ 3 vanilla (at least in 1.29). My tactic has always been to finish a tech on the exact same turn as I build ToE. The tech is then completed before ToE, giving me two completely free techs. So this was not changed from civ3 1.29 to PTW.
 
Thx, TNO.

I am shocked, but not totally suprised at my wrongness.
 
This is an interesting thread though, and I'd like to know more about it. I'm not 100% sure about the trade but either.

What I'm sure about is that you will be informed that a deal is over, and possible get a chance to renegotiate it between your turns, regardless of whether the trade was made during your or an AI turn.

I do not know whether a luxury deal that expires will affect happiness differently if the deal was made in your turn than a deal made in the AI turn. I doubt it, but I have never checked.
 
TNO, I just re-read. I was refering to vanilla civ3, i.e. unpatched civ3 when I was talking about the production/science order. Vanilla in my mind has always meant unpatched, in reference to civ3 or any other software package/os.

I may still be wrong, it is impossible for me to test for it without an uninstal/reinstlal of civ3. I will do it when I get time, if only for my own peace of mind. :)

As and when we get consensus on the order of things here I will update the first thread...
 
Can anybody confirm whether I'm correct in assuming that there is one phase preceeding the commercial processing phase, that phase being the score calculating phase?

I do not know when the game calculates your score for a given turn, but after giving some more thought about this "Big Picture" stuff, I would like to know whether it is calculated anytime after the commercial processing phase and before the movement phase. If so, you could use the Big Picture to access the domestic advisor and set 100 lux tax, effectively doubling your trade by getting gold/beakers and happy faces in your cities from luxury tax output. Has anybody observed whether you're getting higher scores using this method?

About contacting the foreign advisor via the big picture, I don't find that exploitive at all, since the AI does the exact same thing (if current assumptions on how the turn is split in phases are correct). I guess everyone has had the situation once in a while where the you had a tech at 1 turn and none of the AI cis had it, but when you invented it the next turn contacting the other civs revealed they had already discovered it(that would be because your commercial phase is handled first, and after that the AI civs get their commercial phase thus profitting form knowing someone who owns the tech). However, you can also note that civs of which you can make certain they didn't have the tech at 1 turn (for example, because they didn't even have the techs required to research the one you got at 1 turn) now also suddenly have the tech.

This wouldn't be possible if AI civs only traded during their movement phase because they wouldn't have had a chance to invent the tech untill after their movement phase was finished.
 
Back
Top Bottom