1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

RefuseAttitudeThresholds not working ???

Discussion in 'Civ4 - Unofficial Patches' started by DanF5771, Jul 4, 2008.

  1. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Very well done DanF, that's huge both in terms of player-AI relations and just AI-AI relations ... glad you kept searching to find the source!

    This will certainly be in the next Better BTS AI release (currently at .21)
     
  2. Dresden

    Dresden Chieftain

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    Another potential trade-denial-related bug has popped up in the topic This is weird; anyone ever see this?

    You can't ask an AI civ to run Emancipation because they will redline it with the message TXT_KEY_DENIAL_ANGER_CIVIC ("We don't want to deal with the unhappiness"). However, that kind of denial message seems like it should come from asking them to switch out of Emancipation, not into it. Here's the very brief bit of CvPlayerAI::AI_civicTrade() that is causing it:
    Code:
    	if (getCivicPercentAnger(eCivic) > 0)
    	{
    		return DENIAL_ANGER_CIVIC;
    	}
    
    That would make sense if a positive return value from CvPlayer::getCivicPercentAnger() means that your people will become unhappy if you run the suggested civic. But a positive return value instead means that you will get unhappiness if you aren't running it. Note that you can see the true meaning of this return value by looking at how the same function is used in CvCity::unhappyLevel().

    Unfortunately, fixing this properly is a little tricky. The quick and dirty method would be to do something like this:
    Code:
    	if (getCivicPercentAnger(getCivics((CivicOptionTypes)(GC.getCivicInfo(eCivic).getCivicOptionType())),true) > 0)
    	{
    		return DENIAL_ANGER_CIVIC;
    	}
    
    That basically says "if switching out of our current civic of the same type as the suggested one can cause unhappiness, deny." So, for example, if the AI is in Emancipation and the human is suggesting Caste System, they'll deny. But if the AI is running Caste System and the human is suggesting Emancipation, they'll consider it. This did work for me in a brief test.

    Note that this fix assumes there is a maximum of one civic of each type that can cause unhappiness in other nations. This should work fine in the original game where Emancipation is the only such civic, but wouldn't be so hot if multiple civics have been modified to cause that sort of unhappiness. That'd require a much more complex check where you'd have to try and determine how much civic-related unhappiness you currently have and compare it to how much civic-related unhappiness you'd have if you switched.
     
  3. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Wow, nice catch. Certainly the quick and dirty method you describe seems to be what Firaxis intended here, to make it a little more mod friendly we could do:

    Code:
    	if (getCivicPercentAnger(getCivics((CivicOptionTypes)(GC.getCivicInfo(eCivic).getCivicOptionType())),true) > getCivicPercentAnger(eCivic))
    
    How does that sound?
     
  4. Dresden

    Dresden Chieftain

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    That might work, but it would definitely need some testing. Don't know why I didn't think of using that comparison. :)
     
  5. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Haha, really nice Dresden! The problem is not so much the AI's denial to switch into Emancipation (most of the times they do so automatically, plus the human player would probably want to decrease his own Emancipation unhappiness more often than to increase it for other AIs), but the thus never occurring denial to switch out of it.

    jdog5000: shouldn't the comparison be if Anger(CurrentCivic) < Anger(NewCivic) --> denial ?
     
  6. Dresden

    Dresden Chieftain

    Joined:
    Jul 10, 2008
    Messages:
    1,081
    @Dan: you're making the same mistake Firaxis made ;) getCivicPercentAnger() does not tell you how much anger running that civic causes, but how much not running it causes. so jdog's comparison should be okay.

    Here's a concrete example:
    Assume that a new labor civic called Unions generates small unhappiness in non-users while Emancipation generates large unhappiness in non-users. Thus we get the relationship getCivicPercentAnger(Emancipation) > getCivicPercentAnger(Unions) > 0

    jdog's comparison looks like this:
    if (getCivicPercentAnger(current) > getCivicPercentAnger(proposed)) then deny.

    Thus they would redline a change from Emancipation to Unions but would not redline a change from Unions to Emancipation.
     
  7. DanF5771

    DanF5771 Chieftain

    Joined:
    Feb 21, 2008
    Messages:
    1,194
    Right! Should have taken a look at the actual code and not just at the clever :)rolleyes:) name of getCivicPercentAnger.
    Your Unions example makes it "clear as an unmuddied lake, sir".:goodjob:
     
  8. Niklas

    Niklas Fully Functional GOTM Staff

    Joined:
    Dec 21, 2004
    Messages:
    10,290
    Location:
    57°47'55"N 12°09'16"E
    I agree with Dan too - this is a really serious bug, and I won't willingly play 3.17 until it has been fixed.

    And the favorite civic bug is definitely a bug too.
     
  9. TheMeInTeam

    TheMeInTeam GiftOfNukes

    Joined:
    Jan 26, 2008
    Messages:
    22,331
    Location:
    Orlando
    I've been running into this problem lately. Your argument in its defense isn't particularly valid, because even in theocracy for example Justinian would still switch from caste system to emancipation. However, it would be impossible to bribe him to do so.

    On the flip side, bribes for civic switches make sense. I switch civics just for diplo sometimes, I would DEFINITELY switch civics if it meant a free tech or 500-1k gold depending on how fare in the game I am, especially if spiritual.

    There's already a check for "we don't want to deal with the unhappiness" which usually would prevent them from switching out of emancipation or something - something similar may exist for state property and $$$ - haven't tried.
     
  10. DMOC

    DMOC Mathematician

    Joined:
    Aug 23, 2007
    Messages:
    5,592
    Just wondering ... has this been added to the unofficial patch?
     
  11. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    I believe it was in prior versions, it's certainly been in BBAI for a while now. Thanks for checking though, I'll add it to the list of BBAI fixes appropriate for a patch.
     

Share This Page