1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

My personal thread: Clarification of certain game mechanics

Discussion in 'Civ4 - Strategy & Tips' started by Manco Capac, Jun 16, 2012.

  1. Pangaea

    Pangaea Rock N Roller

    Joined:
    Sep 17, 2010
    Messages:
    5,107
    Thanks for clearing that up. Still some personality in tech choice then, it appears, but not as much as I thought/hoped. The coders have put a lot of emphasis on random factors everywhere, possibly too much, to the detriment of the game.

    In tech trades, do the AI value the techs equally with the same ratio towards the human no matter diplomacy (assuming they are willing to tech trade) and difficulty level?

    During a monarch game I did the math as there was a trade where the AI demanded gold. Think it worked out to about 0.90. So assuming it was a 1000 tech, the AI was willing to give me a 900 tech - on the assumption that 1 :science: = 1 :gold:

    Actually, I assume this will scale on difficulty; seem to recall possibly Seraiel saying it was 0.7 at Deity. But will it scale on level of relationship (pleased etc) with the AI in question? Or will it be the same as long as they are willing to trade with you?
     
  2. Seraiel

    Seraiel Deity

    Joined:
    Sep 6, 2011
    Messages:
    7,954
    Gender:
    Male
    Diplomacy doesn't affect the ratio of tech-trades, an AI is either willing to trade, or not, but the conversion factor mostly depends on the difficulty. I've read that things like the tech being a monopoly or many civs knowing it already also influences the ratio, and I think I can approve that, but the amount at which the conversion factor changes because of that must be almost insignificant, maybe 5%.
     
  3. Pangaea

    Pangaea Rock N Roller

    Joined:
    Sep 17, 2010
    Messages:
    5,107
    Thanks, suspected it differed on difficulty.
     
  4. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    Bump and will add what people discussed later.
     
  5. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    Bump for new questions in the opening post. If you know something or has a lead, feel free to post.
     
  6. Um the Muse

    Um the Muse King

    Joined:
    Sep 11, 2009
    Messages:
    922
    Location:
    surrounded in the USA
    I've never heard this before. Can you explain it further? If I understand you correctly, you're saying that if a city is building a culture, has an item in the queue and it's about to get a borderpop, you get hammers into the item in the queue. Did I understand that right? What if you have multiple items in the queue? Can you do that with wonders, too?
    Err, you can choose to trade any amount of gold. I've also seen the AI offer to trade XX4 gold (because they're allowed to trade all of their gold away for a really good deal) so I don't know what you mean here.
     
  7. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    Comments in blue.
     
  8. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    Bump. Some added questions.
     
  9. damerell

    damerell Slow Worker

    Joined:
    May 31, 2012
    Messages:
    804
    Location:
    UK
    Any chance of a diff?
     
  10. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    Any chance of a ....Urban Dic let me down this time...

    Well, true only one question was added in the OP (opening post or whatever that acronym means). Every question is added at the beginning of the thread.
    True, I do some "fresh" necro because CivFanatics population changes over time and maybe...maybe one has the answer to one of these questions.

    Anyways, I hope this thread is going to increase in importance over time as a small bible of under-known mechanics of the game. Sometimes, knowing how it works...as little the aspect of the game is...changes dramatically the game outcome.

    For instance, I just recalled (unless it was patched) spies in boat accumulate stationary discount while the boat advances and is completely invisible by the AI (no detection by evil RNG) until we unload the spy. Indeed, it dramatically changes the game outcome if the stars are perfectly aligned like a nice coastal city with our religion by under a different religion state and close by our city that pumps boats.
     
  11. damerell

    damerell Slow Worker

    Joined:
    May 31, 2012
    Messages:
    804
    Location:
    UK
    An indication, in each bump, of what the new questions are.
     
  12. ben-jammin

    ben-jammin Emperor

    Joined:
    Jan 12, 2011
    Messages:
    1,436
    Am I mistaken or do techs that unlock wonders become less valuable to the AI in trades after the wonder is built? I try to make those trades only when I have the wonder for sure (edit: but before it's finished of course), but I realize I acually have no idea if this makes any difference.
     
  13. damerell

    damerell Slow Worker

    Joined:
    May 31, 2012
    Messages:
    804
    Location:
    UK
    The AI does try not to trade you a tech it would like to build the wonder for, yes.
     
  14. ben-jammin

    ben-jammin Emperor

    Joined:
    Jan 12, 2011
    Messages:
    1,436
    I know they will not trade a tech if they are building an associated wonder, I was wondering if they give you a higher return on a tech if the wonder isn't built yet.
     
  15. VoiceOfUnreason

    VoiceOfUnreason Deity

    Joined:
    Dec 5, 2005
    Messages:
    3,663
    If I ran the zoo -- new questions would be added to the end of the thread, and then copied to the first post when a satisfactory answer is found.

    I also wouldn't use that shade of green, because (a) it has very poor contrast with the default background and (b) I wouldn't expect it to be particularly friendly to color blind readers.

    But it's not my personal thread, and so....
     
  16. Sun Tzu Wu

    Sun Tzu Wu Deity Supporter

    Joined:
    Mar 26, 2007
    Messages:
    7,920
    I concur on all points made, especially the one about the green font. I can see that the font is green, but due to the poor contrast I can't discern a single character. I'm forced to highlight the green text which changes the foreground and background of the green text to high contrast colors.

    Sun Tzu Wu
     
  17. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    AI leaders bragging about their strongest unit:
    Synopsis and use:
    AI that is CAUTIOUS or less towards the human and has less power (in terms of soldier values in demographics) will start bragging at a random instances about their strongest unit available.

    A tactical use that stems from this AI weakness is the knowledge without condition (like exploration) of what the AI best abilities in war. For instance, if an AI still insists on his/her chariots being so great after a great span of the early game, then the lack of metal units sure is a military edge to stomp them or take them as the softest target.
    Their unit bragging does not equal they have gotten out a unit; it is based on the availability of unit as a build in the AI unit, which comes from the usual fact of a connected strategic resource.
    Or a tech that enables the unit.


    Hereunder is the code ruling the conditions needed for bragging (and commanding what string texts will be sent in diplo tables):
    Spoiler :
    Code:
    DiploCommentTypes CvPlayerAI::AI_getGreeting(PlayerTypes ePlayer) const
    {
    	
    [...]
    		else if ((GET_PLAYER(ePlayer).getPower() < getPower()) && AI_getAttitude(ePlayer) < ATTITUDE_PLEASED && (GC.getASyncRand().get(4) == 0))
    		{
    			return (DiploCommentTypes)GC.getInfoTypeForString("AI_DIPLOCOMMENT_UNIT_BRAG");
    		}
    	}
    
    	return (DiploCommentTypes)GC.getInfoTypeForString("AI_DIPLOCOMMENT_GREETINGS");


    (A great thanks to Refar for the big big pointer)
    Hereunder is a brief explanation on how the AI decides what is the best unit to brag.

    In CvPlayer.cpp
    Spoiler :
    Code:
    const wchar* CvPlayer::getBestAttackUnitKey() const
    {
    	CvCity* pCapitalCity;
    	CvCity* pLoopCity;
    	UnitTypes eBestUnit;
    	int iLoop;
    
    	eBestUnit = NO_UNIT;
    
    	pCapitalCity = getCapitalCity();
    
    	if (pCapitalCity != NULL)
    	{
    		eBestUnit = pCapitalCity->AI_bestUnitAI(UNITAI_ATTACK, true);
    	}
    
    	if (eBestUnit == NO_UNIT)
    	{
    		for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
    		{
    			eBestUnit = pLoopCity->AI_bestUnitAI(UNITAI_ATTACK, true);
    
    			if (eBestUnit != NO_UNIT)
    			{
    				break;
    			}
    		}
    	}
    
    	if (eBestUnit != NO_UNIT)
    	{
    		return GC.getUnitInfo(eBestUnit).getTextKeyWide();
    	}
    
    	return L"TXT_KEY_MISC_NO_UNIT";


    Basically reporting AI_bestUnitAI(UNITAI_ATTACK, true), that is units with possible <UnitAI>UNITAI_ATTACK</UnitAI>, otherwise report TXT_KEY_MISC_NO_UNIT, which is the commonly known "Fear our --!".


    After cutting most parts that not related: In CvCityAI.cpp
    Spoiler :
    Code:
    
    UnitTypes CvCityAI::AI_bestUnitAI(UnitAITypes eUnitAI, bool bAsync, AdvisorTypes eIgnoreAdvisor)
    {
    iBestOriginalValue = 0;
    
    	for (iI = 0; iI < GC.getNumUnitClassInfos(); iI++)
    	{
    		eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(iI)));
    
    		if (eLoopUnit != NO_UNIT)
    		{
    			if ((eIgnoreAdvisor == NO_ADVISOR) || (GC.getUnitInfo(eLoopUnit).getAdvisorType() != eIgnoreAdvisor))
    			{
    				if (!isHuman() || (GC.getUnitInfo(eLoopUnit).getDefaultUnitAIType() == eUnitAI))
    				{
    				    
    					if (!(bGrowMore && isFoodProduction(eLoopUnit)))
    					{
    						if (canTrain(eLoopUnit))
    						{
    							iOriginalValue = GET_PLAYER(getOwnerINLINE()).AI_unitValue(eLoopUnit, eUnitAI, area());
    
    							if (iOriginalValue > iBestOriginalValue)
    							{
    								iBestOriginalValue = iOriginalValue;
    							}
    						}
    					}
    				}
    			}
    		}
    	}
    }
    


    Notice the canTran() functions; that is the very condition for showing off some units without even having one yet. "UnitAITypes eUnitAI" is set to UNITAI_ATTACK btw.
    It compares between units with possible UNITAI_ATTACK and via "AI_unitValue()"
    function, it calculates what is the best unit to brag about.

    Let takes a look into that mess: In CvPlayerAI.cpp

    Spoiler :
    Code:
    
    int CvPlayerAI::AI_unitValue(UnitTypes eUnit, UnitAITypes eUnitAI, CvArea* pArea) const
    { 
    
    [...]
    [...]
    [...]
    [...]
    
    case UNITAI_ATTACK:
    		iFastMoverMultiplier = AI_isDoStrategy(AI_STRATEGY_FASTMOVERS) ? 2 : 1;
    		
    		iValue += iCombatValue;
    		iValue += ((iCombatValue * GC.getUnitInfo(eUnit).getMoves() * iFastMoverMultiplier) / 2);
    		iValue += ((iCombatValue * GC.getUnitInfo(eUnit).getWithdrawalProbability()) / 100);
    		if (GC.getUnitInfo(eUnit).getCombatLimit() < 100)
    		{
    			iValue -= (iCombatValue * (125 - GC.getUnitInfo(eUnit).getCombatLimit())) / 100;
    		}
    		
    		break;
    [...]
    [...]
    [...]
    [...]
    
    return std::max(0, iValue);
    }
    


    Here is the exact formula for evaluating UNITAI_ATTACK units.
    Let put it more friendly:

    iValue = (CombatValue) + (CombatValue*Move*FastMoverMultiplier/2)+
    (CombatValue*WithdrawalValue/100)

    FastMoverMultiplier is a multiplier equalling to 2 if the AI is pursuing a war planning about 2 moves units. I suppose this has to do with WHEOON mode with an AI having in mind that war planning.

    The condition "GC.getUnitInfo(eUnit).getCombatLimit() < 100" is not important because it is tied to units with <iCombatLimit>0</iCombatLimit>, which are units that can't attack, like workers, settlers, missionaries, naval units, air units, spies, etc.
    Those units have penalties, but they doesn't interest us in bragging function, especially where that function is best used early game where exploration is not done yet.

    Conclusions from that formula:
    2 movers are more prioritized than slow units and this is even more increased with 2 move units having an innate withdrawal odd like horse archers.
     
  18. Sun Tzu Wu

    Sun Tzu Wu Deity Supporter

    Joined:
    Mar 26, 2007
    Messages:
    7,920
    Great work tachywaxon!

    Thanks for using a shade of green with good contrast with the background. Unfortunately, the contrast is not so good with spoiler background which it occurs to me may have been my original complaint about green fonts.

    Sun Tzu Wu
     
  19. 2metraninja

    2metraninja Defender of Nabaxica

    Joined:
    Sep 19, 2007
    Messages:
    5,663
    Location:
    Plovdiv, BG
    The "trick" with the culture works with money/beakers put in to hammers too, but I consider it too strong and tempting to be used non stop while it is in fact bug/cheating. To save you the temptation and inner fights and not put you all in sin, I wont tell how it works.
     
  20. Manco Capac

    Manco Capac Friday,13 June,I Collapse

    Joined:
    Mar 1, 2010
    Messages:
    8,051
    ^
    I know how it works, but I don't exactly know how it happens. I have a hunch it has to do with culture output are stocked before hammers stocks...

    This trick/cheat/whatever you call it is best on quick speed and negligible on marathon.
     

Share This Page