AI flavors

alpaca

King of Ungulates
Joined
Aug 3, 2006
Messages
2,322
Does anyone know/have a good grasp of how the flavor system works for the AI and could explain it to me?

I made a table of all the unit flavors in the game (copy to a spreadsheet editor to peruse) but they're a bit strange in my opinion, which leads me to believe the game must only use these to modify some other formula based on how useful a unit is (for example war elephants have higher flavor values than mech. inf.)

Code:
Unit Type	FLAVOR_EXPANSION	FLAVOR_TILE_IMPROVEMENT	FLAVOR_RECON	FLAVOR_OFFENSE	FLAVOR_DEFENSE	FLAVOR_RANGED	FLAVOR_MOBILE	FLAVOR_INFRASTRUCTURE	FLAVOR_GREAT_PEOPLE	FLAVOR_ANTIAIR	FLAVOR_AIR	FLAVOR_NUKE	FLAVOR_NAVAL_TILE_IMPROVEMENT	FLAVOR_NAVAL	FLAVOR_NAVAL_RECON	FLAVOR_CULTURE	FLAVOR_SCIENCE	FLAVOR_GOLD	FLAVOR_PRODUCTION	FLAVOR_SPACESHIP
UNIT_INDIAN_WARELEPHANT				4		8	2													
UNIT_SCOUT			7																	
UNIT_IRONCLAD				4	7									6						
UNIT_PIKEMAN				5	6															
UNIT_KNIGHT				10	3		5													
UNIT_EGYPTIAN_WARCHARIOT				4		8	2													
UNIT_SCIENTIST																	1			
UNIT_FRENCH_FOREIGNLEGION				18	18															
UNIT_ENGLISH_LONGBOWMAN				6	6	12														
UNIT_NUCLEAR_MISSILE				12	8						8	24								
UNIT_WORKBOAT													20							
UNIT_MECHANIZED_INFANTRY				9	15		3													
UNIT_SIAMESE_WARELEPHANT				10	16															
UNIT_SWORDSMAN				5	5															
UNIT_IROQUOIAN_MOHAWKWARRIOR				10	10															
UNIT_TRIREME				1	1									3	1					
UNIT_GERMAN_LANDSKNECHT				10	12															
UNIT_WORKER		15																		
UNIT_GERMAN_PANZER				20	10		14													
UNIT_LANCER				6	4		6													
UNIT_BOMBER				10	5						12									
UNIT_ARTIST																1				
UNIT_CAVALRY				10	3		7													
UNIT_FIGHTER				6	8					6	12									
UNIT_AMERICAN_MINUTEMAN			8	10	10															
UNIT_BABYLONIAN_BOWMAN						10														
UNIT_JAPANESE_SAMURAI				11	9				6											
UNIT_SS_BOOSTER																				150
UNIT_SETTLER	21																			
UNIT_MUSKETMAN				7	7															
UNIT_INFANTRY				9	9															
UNIT_MOBILE_SAM					6		4			25										
UNIT_WARRIOR			1	2	2															
UNIT_CARRIER				8	6						4			8						
UNIT_TANK				15	5		10													
UNIT_BARBARIAN_ARCHER				2	2	5														
UNIT_ARCHER				2	2	5														
UNIT_ROMAN_LEGION				10	10			10												
UNIT_ATOMIC_BOMB				10	10						8	16								
UNIT_SPEARMAN				2	4															
UNIT_JAPANESE_ZERO				12	16						16									
UNIT_RUSSIAN_COSSACK				16	6		14													
UNIT_ARABIAN_CAMELARCHER				6		10	10													
UNIT_SUBMARINE				5	9									8	2					
UNIT_OTTOMAN_JANISSARY				14	14															
UNIT_CROSSBOWMAN				3	3	6														
UNIT_CARAVEL														5	10					
UNIT_CATAPULT				4	4	12														
UNIT_ARTILLERY				10	5	10														
UNIT_SS_COCKPIT																				150
UNIT_RIFLEMAN				8	8															
UNIT_SS_ENGINE																				150
UNIT_JET_FIGHTER				8	10					5	20									
UNIT_OTTOMAN_SIPAHI				12	8		12													
UNIT_PERSIAN_IMMORTAL				4	8															
UNIT_SS_STASIS_CHAMBER																				150
UNIT_CHARIOT_ARCHER				2		4	1													
UNIT_AMERICAN_B17				18	10						16									
UNIT_GREAT_GENERAL				1	1															
UNIT_CANNON				4	4	9														
UNIT_GREEK_HOPLITE				4	8															
UNIT_ENGINEER																			1	
UNIT_STEALTH_BOMBER				15	7						20									
UNIT_MERCHANT																		1		
UNIT_MISSILE_CRUISER				6	9									8	7					
UNIT_NUCLEAR_SUBMARINE				12	5							8		9						
UNIT_BATTLESHIP				9	9									9						
UNIT_DESTROYER				6	6									7	4					
UNIT_BARBARIAN_SPEARMAN				2	4															
UNIT_ENGLISH_SHIPOFTHELINE				8	8									12	4					
UNIT_FRIGATE				4	4									6	2					
UNIT_MECH				14	8		8													
UNIT_AZTEC_JAGUAR			2	4	4															
UNIT_HORSEMAN				6	2		4													
UNIT_GUIDED_MISSILE				7	2						7									
UNIT_SONGHAI_MUSLIMCAVALRY				12	4		10													
UNIT_MONGOLIAN_KESHIK				6		10	10													
UNIT_MODERN_ARMOR				20	7		9													
UNIT_ROCKET_ARTILLERY				10	5	8	6													
UNIT_PARATROOPER				8							3									
UNIT_ANTI_TANK_GUN				1	5															
UNIT_CHINESE_CHUKONU				6	6	12														
UNIT_LONGSWORDSMAN				7	6															
UNIT_GREEK_COMPANIONCAVALRY				10	3		6		5											
UNIT_ANTI_AIRCRAFT_GUN					6					25										
UNIT_FRENCH_MUSKETEER				14	14															
UNIT_ROMAN_BALLISTA				8	6	16														
UNIT_HELICOPTER_GUNSHIP				10	8						12									
UNIT_BARBARIAN_SWORDSMAN				5	5															
UNIT_TREBUCHET				3	3	8
 
If you look at the higher numbers, they seem to coincide with the units the AI likes to spam. That is to say, settlers, workers/boats, nukes, and SAMs.

It makes me think that the flavor type has little-to-no bearing compared to the number itself. Either that or the AI's determining of what flavor types it needs is all wrong.

Approaching this from a different angle, it may be that the flavor number determines what the AI builds, and then the flavor type acts as a bias of some sort if a unit of that flavor is already in production. For example, the AI will always opt to build a settler if it doesn't have one building, but if one's in production it will avoid building additional units of the expansion flavor type.

This may also be one of the underlying causes of the AI ICS and city placement. If it can't help but to build settlers, it's gotta use them somehow.

Does that make any sense? I'm just guessing.
 
I imagine it tells the AI how it can and should use a unit. A unit with high offense flavor should be used to attack and not to defend (can't tell from the table above as things seem a little misaligned, but horse units should be like this).

I am pretty sure it is also supposed to indicate whether a unit coincides with the AI's current goal- i.e. if the civilization wants to expand, it should build settlers. The numbers are relative, and probably aren't dependent on a unit's other stats- the war elephant obsoletes before mech infantry should conceivably be available, so the numbers are not meant to be compared.

I say this pretty much based on one presentation of a group project in a college AI class where students had made different flavors (they called them something else) for different chess pieces to define AIs that "liked" to play differently.
 
It's not the use of units - that's handled separately, by assigning various AIs to the unit.

It is choice of which one to build, and it does care about flavour type as well as value, and it is utterly unclear how it balances the two.

One thing that I'd confidently guess is that the determination of what it needs isn't sensitive to what's currently being built; if it has no settlers and wants to expand, it will start building settlers, and won't stop setting settlers to be built until it has actually built enough... and then all the others will finish building as well. Similar for SAMs. The real problem for it with SAMs and AAs is that it then doesn't feel the need to build other defensive units, as they have flavour for that as well, so it seems that it has enough defensive capability.
 
Well, there's also the flavors in the strategies and such. I imagine the AI does some analysis depending on a number of factors to determine city strategy, then somehow weighs all its needs and the flavor numbers to see what it should build next.

The simplest such approach would be UNIT_WEIGHT = sum_k <flavor_k>*<need_k> which would mean if it has a need of 1 for anti-air and a need of 5 for defense, the AA unit would still be chosen over infantry (which kind of meshes with the AI building so many of them) but mech inf would often be better. This obviously bears the question how the needs are calculated and is only a working assumption, though.
 
Back
Top Bottom