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

The Spread Culture Espionage Mission revealed

Discussion in 'Civ4 - Strategy & Tips' started by UncleJJ, Aug 6, 2008.

  1. Dresden

    Dresden Emperor

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    Wow. This was a pretty interesting topic so I ran some tests and I was getting way different behavior than UncleJJ was. Then I saw that disclaimer that UncleJJ was running 3.13 and the readme for 3.17 claims:
    So I decided to do a comparison of the SDK sources and it appears that the 3.17 patch completely destroys this mission.

    Here is the relevant piece of CvPlayer::doEspionageMission() from Bhruic's 3.13 patch (I don't have the original 3.13 sources):
    Spoiler :
    Code:
    	//////////////////////////////
    	// Insert Culture into City
    
    	if (kMission.getCityInsertCultureCostFactor() > 0)
    	{
    		if (NULL != pPlot)
    		{
    			CvCity* pCity = pPlot->getPlotCity();
    
    			if (NULL != pCity)
    			{
    				int iCultureAmount = kMission.getCityInsertCultureAmountFactor() * pCity->countTotalCultureTimes100();
    				iCultureAmount /= 10000;
    				iCultureAmount = std::max(1, iCultureAmount);
    
    				szBuffer = gDLL->getText("TXT_KEY_ESPIONAGE_TARGET_CITY_CULTURE_INSERTED", pCity->getNameKey()).GetCString();				
    				pCity->changeCulture(getID(), iCultureAmount, true, true);
    
    				bSomethingHappened = true;
    			}
    
    		}
    	}
    


    And here is how the official 3.17 patch handles things:

    Spoiler :
    Code:
    	//////////////////////////////
    	// Insert Culture into City
    
    	if (kMission.getCityInsertCultureCostFactor() > 0)
    	{
    		if (NULL != pPlot)
    		{
    			CvCity* pCity = pPlot->getPlotCity();
    
    			if (NULL != pCity)
    			{
    				szBuffer = gDLL->getText("TXT_KEY_ESPIONAGE_TARGET_CITY_CULTURE_INSERTED", pCity->getNameKey()).GetCString();				
    
    				int iCultureAmount = kMission.getCityInsertCultureAmountFactor() * pCity->countTotalCultureTimes100();
    				iCultureAmount /= 10000;
    				iCultureAmount = std::max(1, iCultureAmount);
    
    				int iNumTurnsApplied = (GC.getDefineINT("GREAT_WORKS_CULTURE_TURNS") * GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getUnitGreatWorkPercent()) / 100;
    
    				for (int i = 0; i < iNumTurnsApplied; ++i)
    				{
    					pCity->changeCultureTimes100(getID(), iCultureAmount / iNumTurnsApplied, true, true);
    				}
    
    				if (iNumTurnsApplied > 0)
    				{
    					pCity->changeCultureTimes100(getID(), iCultureAmount % iNumTurnsApplied, false, true);
    				}
    
    				bSomethingHappened = true;
    			}
    
    		}
    	}
    


    It looks like the purpose of the change was to have several small increases in the TC portion of the culture rather than having the entire increase applied to the TC at once. But there's a big problem with this implementation. In 3.13/Bhruic, the game used a single call to changeCulture() but in 3.17/Official it instead uses changeCultureTimes100(). However, the base amount of culture added is the same! So while 3.13 adds 5% of the culture for you 3.17 actually only adds .05% :eek:

    Here's an example of the 3.17 behavior from an ad-hoc in-game test. The game situation was that the Khmer had a city with 280 total culture, generating 3 culture per turn. Using WorldBuilder, I placed a city of my own three tiles due west of them and gave my city 150 culture so that the culture spread mission would be possible and placed a bunch of spies.

    First spread culture mission:
    Code:
    				int iCultureAmount = kMission.getCityInsertCultureAmountFactor() * pCity->countTotalCultureTimes100();
    				iCultureAmount /= 10000;
    				iCultureAmount = std::max(1, iCultureAmount);
    
    countTotalCultureTimes100() returns 28000 as expected since there was 280 Khmer culture and nothing else there. Thus, iCultureAmount = 5 * 28000 / 10000 = 14. So far so good as this is the expected 5%.

    Code:
    				int iNumTurnsApplied = (GC.getDefineINT("GREAT_WORKS_CULTURE_TURNS") * GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getUnitGreatWorkPercent()) / 100;
    
    Since the game was on epic speed and the global define wasn't changed, iNumTurnsApplied is 30.

    Code:
    				for (int i = 0; i < iNumTurnsApplied; ++i)
    				{
    					pCity->changeCultureTimes100(getID(), iCultureAmount / iNumTurnsApplied, true, true);
    				}
    
    Now with integer mathematics iCultureAmount/iNumTurnsApplied = 14/30 = 0. Thus we add absolutely nothing to both the City and Plot culture 30 times. :)

    Code:
    				if (iNumTurnsApplied > 0)
    				{
    					pCity->changeCultureTimes100(getID(), iCultureAmount % iNumTurnsApplied, false, true);
    				}
    
    Now, iCultureAmount % iNumTurnsApplied will be 14 and so we will add 14 of my civ's culture to the city only. But wait! The function is using changeCultureTimes100 so in actuality it is adding only .14 culture. :eek: If you call countTotalCultureTimes100() and getCultureTimes100() on that city immediately after this and divide all returned values by 100, it tells you there is 280.14 culture, 280.00 of which is Khmer and .14 of which is mine. This was verified in the Python Console. I ran the spread culture mission 3 more times over the next 3 turns and each time, the mission told me I'd spread 14 culture, but in actuality was spreading .14 culture. After 17 more successful missions I had a whopping 2.80 total culture in that city.

    I expect this is why mirthadir (who is running 3.17) was seeing lower-than-expected culture increases on successive missions and why it looked like the game was using 5% of the Japanese culture instead of 5% of the total. It really was using the total, but the amount of added culture was so small as to be almost inconsequential. By the end of the test only 13.6 culture had actually been added after 2 dozen missions.

    In summary, I fear spread culture is pretty close to useless under 3.17. It looks like they tried to adjust the "TC" amount and in the process completely broke it...
     
  2. patagonia

    patagonia Emperor

    Joined:
    Aug 19, 2006
    Messages:
    1,025
    This fits with what I saw in a test yesterday (3.17).

    I ran enough spread culture missions in an enemy city to hit 49000:culture: or so based on the 5% rule (Bug mod tells you how much culture you're adding - does the game normally?). Then captured the enemy city only to find it on 494/1:culture: waiting to come out of revolt.

    You'd have to spread 2000:culture: just to get the 20:culture: border pop the way things stand at the moment, which seems way more trouble than it's worth.
     
  3. royal62184

    royal62184 Prince

    Joined:
    Aug 22, 2007
    Messages:
    312
    Location:
    Oak Ridge, TN
    I was just thinking at work (lol) that if you could get it about I think 10% for drafting that would be really cool. Take over a city and draft any defenders you need. But after reading this i'm guessing that isn't feasible at all, so I guess i'll just keep whipping em.
     
  4. royal62184

    royal62184 Prince

    Joined:
    Aug 22, 2007
    Messages:
    312
    Location:
    Oak Ridge, TN
    Is the error dresden found intentional? Or is this something we should ask solver to implement? I mean the 1/100 factor what purpose does it really serve?
     
  5. Dresden

    Dresden Emperor

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    I can't believe it's intentional since the help text when you try to run the mission still gives the 5% number; I'm pretty shocked that it slipped through testing though. I want to do a little more rigorous testing and then I'll spread the word by writing up a bug report and making sure both Solver and the Better AI team know about it.
     
  6. UncleJJ

    UncleJJ Deity

    Joined:
    Jun 13, 2006
    Messages:
    2,226
    Location:
    London
    :( This is sad news. Thanks for investigating this Dresden. From what you've found it certainly seems like another attempt to fix something that introduces a major problem (e.g. barrage on tanks). Does the mission still give a discount? My theory was that the discount was related to the ratio between your CC and the city owner's CC. If the 3.17 mission is much weaker at affecting your CC then the discount will also be reduced and hence worthless for supporting other espionage missions.

    I am still testing with the pre patch version, trying with Gilgamesh for a 3 city cultural victory on marathon using only espionage. I have a continent with 3 other civs and by 1 AD I have already reduced one rival to 1 city and another to 2. Just Monty is left as a potential opponent with about 7 cities but I'm stronger and ahead in tech. I just have to reduce him and then build up the espionage infrastructure. There is plenty of space for more cities and cottages.

    Given the news about 3.17 it seems I might not update for a while.
     
  7. vicawoo

    vicawoo Chieftain

    Joined:
    Feb 12, 2007
    Messages:
    3,226
    Ok, that's the final piece of the puzzle. My next prediction was that the culture added was only from your city culture spread (which could be 20 culture), but this makes more sense. The only culture is from the other cities' culture.
     
  8. Dresden

    Dresden Emperor

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    Yes, the discount is still there. You are right that it's based on the CC ratio and so the discount would be much weaker in 3.17. Here is the code for the discount, from CvPlayer::getEspionageMissionCostModifier()
    Code:
    		// City's culture affects cost
    		iModifier *= 100 - (pCity->getCultureTimes100(getID()) * GC.getDefineINT("ESPIONAGE_CULTURE_MULTIPLIER_MOD")) / std::max(1, pCity->getCultureTimes100(eTargetPlayer) + pCity->getCultureTimes100(getID()));
    		iModifier /= 100;
    
    As an example, if there is 10,000 of their culture in the city and 5,000 of your culture in the city and the Global Defines haven't been changed this would be:

    Discount is = (500,000 * 50)/(1,000,000 + 500,000) = 25,000,000/1,500,000 = 16%.
     
  9. vicawoo

    vicawoo Chieftain

    Joined:
    Feb 12, 2007
    Messages:
    3,226
    This kind of kills the thread. But I'm wondering about cost-effectiveness. For a culture win with lots of espionage, sure why not.

    But the other benefits are to ensure border popping after the capital (probably worthwhile), lowering homeland anger (need numbers on this), and reducing espionage costs. As for reducing espionage costs, it's a balance of mission cost to city culture. I'm sure it's rarely worthwhile to use to lower a city riot mission. But how about stealing physics.
     
  10. civtrader

    civtrader Chieftain

    Joined:
    Jul 22, 2006
    Messages:
    9
    Wow, nice work!
     
  11. Jerrymander

    Jerrymander Epistemologist

    Joined:
    Mar 21, 2007
    Messages:
    2,624
    Location:
    Hallways of Always
    There's a solution for fixing the problem. Just make it a variable amount. However, make the Culture % infused a logarithmic equation. A base 10 log of 100 times the espionage points infused dictates what % of Culture is added to a city.
    log(100x) = C, where x = espionage points and C = culture.
    62 Espionage points adds 1.7% culture, but to add 3.4% culture, you need 250 Espionage points. On the graph these points are displayed as (6.2, 1.7) and (25.0, 3.4), but I'm sure you could modify the Python to multiply the x value by 10 after it calculates it.

    After examining my rendered graphs, a natural log would make more sense.
    ln(5x) = C generates a more reasonable slope.
    1.7% Culture requires 117 Espionage points, 3.4% culture requires 600 Espionage points, and 5% culture requires 2990 Espionage points.
    Final x amounts are multiplies by 100. (1.17, 1.7), (6.00, 3.4), (29.90, 5.0).

    My numbers may be a little bit rough, but the math is there.
     
  12. vicawoo

    vicawoo Chieftain

    Joined:
    Feb 12, 2007
    Messages:
    3,226
    You realize that log(a*b)=log(a)+log(b), so your fancy adjustments are just adding a constant
     
  13. Jerrymander

    Jerrymander Epistemologist

    Joined:
    Mar 21, 2007
    Messages:
    2,624
    Location:
    Hallways of Always
    Yes, but it makes more sense to me when I do it like that. But thanks for trying to deflate my overinflated pride unit.
     
  14. vicawoo

    vicawoo Chieftain

    Joined:
    Feb 12, 2007
    Messages:
    3,226
    I also don't get how this solves the integer rounding problem, which if fixed should deal with the problem. Or do you just mean fix the potential of having a cultural victory off it?

    And to the Dresden mechanics post, it looks like they got lazy and just piggy backed off the recoded great work (done in pieces if i recall).
     
  15. Jerrymander

    Jerrymander Epistemologist

    Joined:
    Mar 21, 2007
    Messages:
    2,624
    Location:
    Hallways of Always
    It neither solves the first problem nor the second problem (not directly), but it does solve the 3.17 problem, where the mission only counted for 0.05% of the culture.

    This would also make it more costly to spread more culture in a city. Perhaps there could be a turn requirement between missions as well.
     
  16. Dresden

    Dresden Emperor

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    Integer rounding isn't really the issue; that only slightly affects the calculations. The major problem is the switch from changeCulture() to changeCultureTimes100() without any change in the base spread amount. The simple fix for that is, of course, to just use the other function; you don't need to use a diminishing-returns formula unless you are trying to tone-down the mission. Simply using changeCulture() again in both places will cause the mission to once again add (approximately) 5% worth of City Culture per mission as it did in 3.13 and as it still claims to do on the mission popup.

    So, what other effects would such a change have? Mainly, it has a much larger effect on Plot Culture meaning tiles actually start flipping and the target city becomes more likely to revolt. Based upon my testing it seems that they may have been actually trying to improve the mission when they broke it. I'd love to get some details on exactly what the intent of the change was...

    Anyhow, I ran the same tests I did earlier in an Epic/Noble game under 3 situations: Bhruic 3.13, Original 3.17, and a "fixed" 3.17. Results Below. Each screenshot is wrapped in spoilers.
    Spoiler :


    Starting Situation:
    The Ottoman city of Konya has 150 total City Culture and does not generate any per turn. The Khmer city of Vimayapura has 298 City Culture for the Khmer and none for anyone else; it generates 3 culture per turn. The Plot Culture surrounding it at the start of the test looks like this:
    Spoiler :



    Original 3.17 (i.e. Broken)
    After 20 successful spy missions at a cost of 675 EP, the City Culture is now 298 Khmer and 2.85 Ottoman. The Plot Culture is almost entirely unchanged; the Vimayapura city square now has 2 Ottoman Culture instead of 1 and that's the only difference. The city is still 99% Khmer with no chance of revolt.



    Bhruic 3.13
    In the previous patch, after 20 successful spy missions at a cost of 899 EP, the City Culture is 298 Khmer and 474 Ottoman. Plot Culture has increased but none of the tiles are in any danger of flipping. The city is now 85% Khmer but there is still no chance of revolt.
    Spoiler :



    "Fixed" 3.17
    If you apply the easiest fix to 3.17 as discussed above, 20 successful missions will still cost 899 EP and the City Culture will still wind up 298 Khmer and 474 Ottoman. However, Plot Culture for the Ottomans is huge. The city square gains 6151 Ottoman culture putting the city at just 38% Khmer and in danger (2.4%) of revolting. Half of the city's tiles have flipped to the Ottomans and another 7 would flip if there was any immediate pressure on them.
    Spoiler :



    So now the question becomes: is the simple fix too good? At first glance it is troubling, making me consider something more complicated like Jerrymander's idea, but I think this might be okay in more varied circumstances. Keep in mind that in my test I did run a lot of spy missions on a relatively new (112 turns on Epic) city. And the tiles didn't start flipping until the last few missions. I also did everything on one turn so the native culture didn't have any time to fight against me; every turn their city would add culture while my only substantial additions would be from more missions. What does everyone else think?
     
  17. UncleJJ

    UncleJJ Deity

    Joined:
    Jun 13, 2006
    Messages:
    2,226
    Location:
    London
    Excellent work Dresden, very clearly written and great diagrams :). I like your suggestions.


    My preference is for something close to the Bhruic 3.13 patch but that's probably because it's what I am familiar with and I can see how that can be used. I suspect the design team wanted to increase the effect on plot culture rather than mostly CC so perhaps we should go more in that direction. But in your example the amount of plot culture with the "fixed" 3.17 seems a good deal too much. Getting that much plot culture for just 899 EPs is too cost effective. We need to match the cost to the effect.

    Your example is of a very new city with low culture and relatively weak plot culture. Before we decide what to recommend I'd like to see the effect of the three options on another much older and stronger cultural target with very high plot culture. Perhaps something like a city that has built up 7500 culture (4 border pops)over several 100 turns (if the test is on Epic) and which therefore had deeply engrained plot culture. I think there could be a real conflict between making the mission effective when culture is weak and cities are new versus when culture is strong and cities are old.
     
  18. TheMeInTeam

    TheMeInTeam Top Logic

    Joined:
    Jan 26, 2008
    Messages:
    25,327
    You could just make it so that the mission gives a fixed amount of culture, and perhaps a much more expensive mission that gives a greater amount. I'm not sure I like the concept of sending cities to legendary via spies! Its uses as EP cost reduction or to make cities useful after revolt quickly make more sense.

    What fixed amount? I don't have a good feel for the balance to give a suggestion, and it would require multiple mission options (not sure how hard/easy that would be to add vs just tweaking mechanics), however in theory this would be an effective way to get it to work as intended without using 5% of some huge number snowballing into a super culture legend city because some people talked a lot under the government's nose.
     
  19. Dresden

    Dresden Emperor

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    Yeah, I'm considering working up a test on the other end of things using the most cultured AI city in that same game (Carthage, ~450 turns old with 35K city culture and 82K plot culture). While I'd like an example of a more realistic target, the closest capital to my borders is a vassal and I actually owned the city for about 10 turns and those are two variables I'd rather avoid. And an extreme situation probably could be a useful test in terms of seeing how costly (and how effective) the mission can be on the other end of the spectrum. If you're interested in doing some testing on this since you have a lot of experience with this mission, send me a PM. We can probably hack together a special 3.13 version.
     
  20. Dresden

    Dresden Emperor

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    Here's an example of how the simple fix for 3.17 would work with a mature, highly-cultured city. Because of time constraints I only tried the one DLL version. I can make educated guesses about the others, though: under 3.13 the only difference would be much lower Plot Culture and under an unmodifed 3.17 I'd be mostly wasting my time. :p

    The setup for this test: Epic Speed, Noble difficulty. I used some WB help to "peacefully" take over an Ethiopian city which was 3 tiles NE of Carthage; I gave it 750 culture to expand the borders far enough to allow spread culture missions in Carthage.
    Spoiler :


    Espionage starts at turn 466/750. At that point Carthage has 34,061 city culture (all Carthaginian) and generates 230 culture per turn. The Plot Culture under it is 91,741 Carthaginian, 2926 Ethiopian, and 13 Ottoman (me) resulting in a Nationality of 96% Carthaginian, 3% Ethiopian. My city, Gabaza, has 772 culture and generates 2.5 per turn. Here is the plot culture summary at the start of the test:
    Spoiler :


    I have built up 40,000 EP vs Carthage and am running a 100% EP Economy generating another 4200 per turn, all against them. Each turn anywhere from 1 to 7 spies are used on the spread culture mission, depending on how many have the 50% stationary bonus. Anywhere from 3 to 6 extra spies are sent into Carthage each turn to keep the cycle going.

    The espionage popup showed an estimated success rate of 67%. Over the course of 10 turns I was able to run 20 successful missions; on 14 of those, the spies returned safely and they were caught after 6. Additionally, 12 missions failed completely which is right in line with the expected 2/3 rate. Note that I did not keep track of how many were detected and executed in-between turns. The failure rate resulted in a whopping -15 Relations dropping Hannibal from Pleased all the way to Annoyed over the course of the test. That's something to keep in mind if you are trying to use this mission peacefully.

    There was a total expenditure of just under 45,000 EP and a gain of 57,436 City Culture in Carthage so the overall average was around 1.28 culture per EP spent. Additionally, 45,903 Plot culture accumulated in the city square compared to a new total of 98,066 for the Carthaginians. The Ethiopian contribution was unchanged since they no longer had a city close enough to matter. This resulted in a new nationality distribution of 66% Carthaginian, 31% Ottoman, and 1% Ethiopian. Unlike in the previous test, none of the tiles flipped as there was just too much accumulated native culture to displace with this many missions. Here's the Plot Culture summary after 10 turns:
    Spoiler :


    For those interested in the costs of this mission, here is the popup for the next attempt following the 20th mission. Note that the City Culture discount is up to 30%.
    Spoiler :


    So my primary concern has been alleviated since the Plot Culture changes are much more reasonable this time around. Even though the Plot Culture builds up quickly, a mature city has much better defense over plots flipping so it's not going to be easy to get cheap territory gains inside a nation's core. It took another 15 successful missions for me to get a single tile flip (one which was outside of Carthage's BFC) and by that time I had burned through my EP stockpile; and Hannibal had dropped to Furious and made me his Worst Enemy.

    However, this illustrates another concern that has popped up in this thread. The 5% spread adds up very fast so the potential for quickly turning EP into a legendary city would be the same as it was in 3.13. I was able to pass the Legendary barrier with 5 more successful missions (out of 9 attempted) over the next 2 turns. Adding everything up, in order to prime Carthage for Legendary status (83368 was the actual total as I wound up using 1 more than was actually necessary) the overall cost was about 60,000 EP, 40-50 spies, and -17 in relations. It took 12 turns but if you include getting the initial spies in place beforehand for the max discount it's more like 17. Of course I'd still have to take over the city militarily for that to matter in terms of a cultural victory, but there's nothing else in the game that can match that level of culture-generation.
     

Share This Page