AI Wonder Priority?

It may be simpler to mod out all wonders then create two equally priced wonders and load up a duel map. I would not be surprised to see one wonder consistently chosen and yet it would be self evident there was no AI priority.
 
More code diving ... glug glug ... :)

Made loads of notes but not sure how much of it would be useful to post. Here are some things which might be interesting:

City governor AI is different to Great Engineer AI
(In other words we should not confuse the two when considering the OP question of this thread - i.e. "AI wonder priority").

More info:

Spoiler :
The city governor chooses what to build after a careful process of considering all the different conditions which exist in both the city and the whole civ at the current point in the game. It attaches very high priority to units in general. Buildings, including wonders, are assessed for their value but always in the context of what is currently required. The city governor also applies a healthy dose of randomness to all production choices, including buildings.

AI great engineers apply much less thought than that. They are only interested in wonders, not units, and not other buildings. They call the same building value routine as the city governor, and that does consider the state of the city/empire, but does not apply the same amount of context as when called by the city governor. GEs also do not apply any random factors afterwards.

The building value routine - CvCityAI::AI_buildingValue() - considers all the different benefits a building can have and gives them a weighting. When called by the city governor it will only consider the particular "flavour" of building requested at that point in the city governor's thought processes (e.g. defence, gold etc).

A general list of wonder priorities
What you have been waiting for:
Spoiler :
Nope, sorry I'm dodging this task :lol: At least for now - there are about 50 tests to write up! But it is possible in theory because the evaluation routine is deterministic - I believe no RNG rolls are used.

In a lot of cases though, the values depend on parts of the AI's empire set-up which the human could not know, such as how many specialists they are running and how they have their sliders. Other factors like how many and how big cities they have, as applying to the calculated value of several wonders, the human could indeed know that info.

Also remember that the city governor is applying a lot of randomness which would further reduce how much we could know about its choices, and whether it would be worth having this list.

Details of Great Engineer AI
For anyone interested:
Spoiler :
GE priorities are the following:

  1. "Switch hurry"
  2. Hurry
  3. Lighbulb
  4. Golden age
  5. Settle (considers all cities to decide where would be best)
  6. Compound lightbulb with other GP(s) (not sure how this works)
  7. Other stuff like staying out of danger
  8. Skip a turn
"Switch hurry" is significantly different to "hurry". Switch hurry only applies to the city the GE was born in. It means consider all available world wonders not currently being built in this city, choose the "best" (using the above evaluation routine) that can also be rushed in a single turn, and insert it into the build queue. Hurry means look at all cities *already* building a world wonder and choose the one with most turns left above 8 turns (after GE travel time), and go there to hurry.

In either case it appears the AI will only ever hurry world wonders, not national ones or other buildings.

AI great engineers *WILL DEFINITELY* rush a world wonder if the above conditions for switch-hurry or hurry are satisfied (unless they would have to go near enemy units).

The wonder value routine used by a GE seems to involve no RNG rolls - so if we had the time to asses all the factors involved, and could see the AI's slider settings and so on, we could predict their GE usage completely.

The MoM in particular is a relatively low-priority AI wonder
Spoiler :
The main reason is that its special benefit is not one of the ones considered by the evaluation routine - this may be an oversight by the developers, who knows. Therefore the MoM's value according to the routine is just its +GP and its +:culture:, which are the same as many other wonders. The sistine chapel has special benefits which *do* seem to be accounted for by the evaluation routine. I didn't follow it completely but I think it will score a non-zero weighting if the AI is currently running at least one specialist somewhere.

The AP I didn't specifically look for but since it has a variety of benefits it would not be surprising if it reliably scored more than either MoM or sistine.

Another thing about the MoM is it has no "flavour" as mentioned in an earlier post, so it never scores bonus points for matching the AI leader's flavour. Having said that, Freddy's flavour is "production" so the sistine would not get this bonus with him either.
 
Awesome! I wondered if the GE code was different or not.

Which parts of the code are we discussing? The randomness I was talking about is cvCityAI.cpp method AI_bestBuildingThreshold line 3370:

Code:
iValue *= (GC.getASyncRand().get(25, "AI Best Building ASYNC") + 100);
iValue /= 100;

is that not called when using a GE?
 
I wish too, but he returned to his long slumber of 2 years. :(
Maybe during the next cycle.


Wait I'm seeing strip of codes...

:D :thumbsup:

The wonder value routine used by a GE seems to involve no RNG rolls - so if we had the time to asses all the factors involved--

:deadhorse: yea I'm being immature, still finding a typo proves I read the post right? :D
 
3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 22 31 2e 30 22 20 65 6e
63 6f 64 69 6e 67 3d 22 55 54 46 2d 38 22 3f 3e 0a 3c 62 6c 6f 63
6b 6c 69 73 74 20 78 6d 6c 6e 73 3d 22 68 74 74 70 3a 2f 2f 77 77
77 2e 6d 6f 7a 69 6c 6c 61 2e 6f 72 67 2f 32 30 30 36 2f 61 64 64
6f 6e 73 2d 62 6c 6f 63 6b 6c 69 73 74 22 3e 0a 20 20 3c 65 6d 49
74 65 6d 73 3e 0a 20 20 20 20 3c 65 6d 49 74 65 6d 20 69 64 3d 22
66 64 6d 5f 66 66 65 78 74 40 66 72 65 65 64 6f 77 6e 6c 6f 61 64
6d 61 6e 61 67 65 72 2e 6f 72 67 22 3e 0a 20 20 20 20 20 20 3c 76
65 72 73 69 6f 6e 52 61 6e 67 65 20 6d 69 6e 56 65 72 73 69 6f 6e
3d 22 31 2e 30 22 20 6d 61 78 56 65 72 73 69 6f 6e 3d 22 31 2e 33
2e 31 22 3e 0a 20 20 20 20 20 20 20 20 3c 74 61 72 67 65 74

No, as I see it that's part of the randomness which gets added by the city governor after getting the building "value" a few lines before. The GE (see e.g. CvUnitAI::AI_switchHurry) works with the value as-is.

Incidentally it's a different line number in the version I'm looking at. I don't have the better AI version though.

PS. Anyone know how to get black background text in CFC posts? :scan:

:deadhorse: ... finding a typo proves I read the post right? :D

You are observe!
 
You are spot on sir. Seems that GEs ARE deterministic. It takes the value of AI_buildingValueThreshold and doesn't mess with it afterwards.

Where did you get the original source from? I wouldn't mind a copy of that.

If you have a moment I was wondering if you'd had any luck in deriving the intent of a particularly troubling line in AI_buildingValueThreshold:

Code:
	for (iPass = 0; iPass < 2; iPass++)
	{

?

That looks _awfully_ hacky, running the code twice for seemingly no apparent reason. Followed (hilariously) by a ton of code that asks either:

Code:
if (iPass == 0)

// or

if (iPass > 0)

Weird......

EDIT: Wait... this means we can produce a list of wonders that the AI will rush in a deterministic list! If I can get the vanilla code I'd be entertained to try to write it up.
 
Where did you get the original source from? I wouldn't mind a copy of that.

Just googled "Civ 4 SDK", don't remember where the file came from - probably riddled with viruses :rolleyes:. I'm sure there's a copy on this site somewhere though.

The 2 pass thing is doubling the weight for types of benefits at certain times ("focus") - e.g. if we want a "happy building" evaluate all the benefits but add extra weight to any happy benefits by running that code twice.

But only some types of focus seem to be handled that way. Other ones are handled later on in a different way, maybe coded by somebody else? Or maybe it's that some of the benefit types correspond directly to the "flavor" multipliers in the XML for buildings and AI leaderheads (production, science, culture, etc), and they get their extra weight that way. Some don't (happy, maintenance, experience, etc.), so maybe those ones have to get it the kooky 2-pass way. Just speculation though....
 
Top Bottom