Results 1 to 7 of 7

Thread: Research: Bribery Mechanics

  1. #1
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Research: Bribery Mechanics

    Since I'm currently testing bribery which I want to use in a feature for Italia Invicta (bribable condottieri stacks as mercenary armies), I'll log my test results and conclusions here so everyone has some use out of it (settings means settings changed from vanilla test unless specified).

    First of all, the vanilla settings:

    Code:
    <base_character_chance float="0.4"/>
          <religion_modifier float="0.66"/>
          <combined_attribute_modifier float="0.2"/>
          <briber_attribute_divisor float="3.0"/>
          <bribee_attribute_divisor float="3.0"/>
          <army_size_modifier float="0.035"/>
          <base_settlement_chance float="0.8"/>
          <settlement_loyalty_modifier float="0.01"/>
          <settlement_population_modifier float="0.0001"/>
          <faction_standing_divisor float="10.0"/>
          <max_bribe_chance float="100.0"/>
          <min_bribe_chance float="1.0"/>
          <bribe_chance_modifier float="1.0"/>
    Faction standing is 0 as it will be in my final use case so that won't have an effect.

    The test setup is using a neutral faction character and one of my diplomats who I can kill and respawn by pressing buttons. This allows me to test things without restarting the campaign and therefore I have a much smaller statistical error.

    Test 1:
    Briber: 0, Bribee: 0
    Settings: Vanilla
    Units: as above
    Approximate success chance: 0.3
    Cost: 10228
    Description: Not sure yet, we can probably discount the attribute effects so we'd have 0.4, possibly modified by religion and army size.
    Theory: Chance to succeed is roughly 26.4% - testing for this tester
    Results: 15/50 successes -> 0.3 relative frequency. This doesn't quite fit the 0.264 I calculated (expectation would be 13) but it's well within the error margin.

    Test 2:
    Briber: 0, Bribee: -1
    Settings: Vanilla
    Units: as above
    Approximate success chance: 0.52
    Cost: 7978
    Description: I'll continue with above working assumption because nothing better turned up. However I have no idea how the bribee_attribute_divisor works so let's have a look
    Results: 26/50 success -> 0.52 relative frequency. Need more tests to get a theory for the formula
    Side result: The game's RNG seems to be somewhat prone to produce streaks of bad luck/good luck. Most of the times I had more than 3 times the same result here and with a chance of about 0.5 that's not very likely

    Test 3:
    Briber: 0, Bribee: -2
    Settings: Vanilla
    Units: as above
    Approximate success chance: 0.88
    Cost: 4603
    Description: Continuing #2 to try to figure out a sensible function.
    Results: 44/50 success -> 0.88 relative frequency
    Still no sensible idea yet. Side result: Any lower loyalty doesn't decrease the cost, didn't test often enough to say anything about the probability but I assume it's capped, too.

    Test 4:
    Briber: 1, Bribee: 0
    Settings: Vanilla
    Units: as above
    Approximate success chance: 0.52
    Cost: 10228
    Description: Continuing #3 to try to figure out a sensible function. I'm assuming the briber and bribee attributes modify things by either one being subtracted from or one being divided by the other, so I'm doing this test to see if it yields the same result as #2 which would speak for a subtraction
    Results: The price is the same, so for now I'll assume that the probability is the same, too. Subtraction it is.

    Test 5:
    Briber: 1, Bribee: 0
    Settings: religion_modifier=1.0
    Units: as above
    Approximate success chance: 0.36
    Cost: 10228
    Description: Something I should have done before is eliminating the religion_modifier. It's quite possible that it only applies to foreign religions so I'll test it now.
    Results: 18/50 or 0.36 - this is somewhat higher than the vanilla test, but not necessarily significant. The cost was the same so I'll just try to bribe a character of a different religion and see if that has a different cost to be sure.

    Test 6:
    Briber: 1, Bribee: 0
    Settings: vanilla
    Units: as above
    Approximate success chance: 0.2
    Cost: 10228
    Description: This test serves to figure out how the religion modifier works. Using an islamic bribee instead of a catholic one
    Results: 10/50 -> 0.2; this fits quite well with 0.2/0.66 = 0.3 which was the chance for the catholic test with the same religion but if that formula was true then #5 should have shown 0.2 and not 0.36 so it's very unlikely that it's so easy. I'll test with some ridiculously high religious modifier now.

    Test 7:
    Briber: 1, Bribee: 0
    Settings: religion_modifier=100.0
    Units: as above
    Approximate success chance: 1
    Cost: 10228
    Description: This test serves to figure out how the religion modifier works. Still an islamic character
    Results: 10/10 -> 1; to speed up testing I cancelled after 10 tries. Obviously the chance got ridiculously high.

    Test 7:
    Briber: 1, Bribee: 0
    Settings: religion_modifier=100.0
    Units: as above
    Approximate success chance: 0.50
    Cost: 10228
    Description: Still trying to understand the religion_modifier, so now a catholic target again.
    Results: Just figured out that I probably did the last few tests with a briber attribute of 1 without noticing. The results of this one were 25/50 = 0.5 which is very close to the 0.52 of #2
    What bugs me a bit now is the discrepancy between test 5 and test 2 so I'll have to properly run #4 now.


    --------------------------------------------------------------

    After leaving this for the evening, I decided to change my test philosophy. I'll now first disable any modifiers I don't want to test, then look at what the others change.
    First of all, I'll try disable everything except for the base chance.

    My current settings are:
    Code:
    <bribe_to_family_tree bool="false"/>
          <base_character_chance float="0.4"/>
          <religion_modifier float="0.0"/>
          <combined_attribute_modifier float="0.0"/>
          <briber_attribute_divisor float="1.0"/>
          <bribee_attribute_divisor float="1.0"/>
          <army_size_modifier float="0.00"/>
          <base_settlement_chance float="0.8"/>
          <settlement_loyalty_modifier float="0.01"/>
          <settlement_population_modifier float="0.0001"/>
          <faction_standing_divisor float="1.0"/>
          <max_bribe_chance float="100.0"/>
          <min_bribe_chance float="1.0"/>
          <bribe_chance_modifier float="1.0"/>
    I will now conclude the next test on a catholic faction with briber and bribee at 0

    Test 8:
    Briber: 0, Bribee: 0
    Settings: see above
    Units: as above
    Approximate success chance: 0.48
    Cost: 10228
    Description: I hope that this time, I will get the 0.4 as a result which should only be the base chance.
    Results: 24/50, 48%. For a test sample of 50 it's still possible but I think there's something else.

    Test 9:
    Briber: 0, Bribee: 0
    Settings: faction_standing_divisor=1000.0
    Units: as above
    Approximate success chance: 0.35
    Cost: 10228
    Description: This test will serve to see whether there is some influence of the faction standing on my test results.
    Results: I ran this test two times to test whether the streaking problem is serious and to see how large the variance is (a characteristic of independent results is that in a sufficiently large subset of random results, you should observe the same relative frequency). The first test revealed 17/50 which is 0.34, the second 18/50 which is 0.36; total the relative frequency is 0.35 and it's pretty likely that this is fairly close to the actual probability for this. So what did I learn? The faction_standing modifier definitely has a large effect (0.48 is pretty far away from 0.35 and since both of my last tests yielded almost the same result it's unlikely that the 0.48 is a realization of the same distribution).

    Test 10:
    Briber: 0, Bribee: 0
    Settings:faction_standing_divisor=0.001
    Units: as above
    Approximate success chance:
    Cost: 10228
    Description: This is pretty much the counter-test for Test 9. I should observe a higher probability or the same as in Test 8
    Results: 19/50 or 0.38 - this is weird, it's almost exactly what I got in test 9 and would fit with the 0.4 I initially expected. However it doesn't fit test 8 at all. I'll re-run test 8.
    Decided to try this one again to make sure the db was properly reloaded, it yielded 18/50 which is probably the same result as in Test 9 and in this test before. Now to test the divisor of 1 again.

    Test 8, take 2:
    Briber: 0, Bribee: 0
    Settings: see above
    Units: as above
    Approximate success chance: 0.46
    Cost: 10228
    Description: Rerunning to test.
    Results: 23/50, 46% - a very good reproduction of test 8. So what's happening here? The only feasible assumption I have right now is that CA maybe included a fall-back default for too high or too low settings (which could be tests 9 and 10 respectively). So I'll try with the vanilla value of 10.

    Test 11:
    Briber: 0, Bribee: 0
    Settings: faction_standing_divisor=10.0
    Units: as above
    Approximate success chance:
    Cost: 10228
    Description: This one goes to further test the faction_standing_divisor
    Results: I ran this test twice and the results were very dissatisfying. The first test gave a result of 13/50 (26%) while the second arrived at 25/50 (50%) - taken together it's 38%. I observed two huge streaks of successes (one with length 8 and one with length 7). I had mentioned this earlier and noticed it today, too. It could well be that the random number generator is somewhat broken in regards to this as the variance in my other tests didn't seem to be that large (i.e. I felt like it mostly came from the streaking). This is of course a huge problem for me as it means I can't properly test things with the current sample size.
    I'll take a break and I guess I'll stop to try figuring out the exact formula for the bribery chance because I'd need a much larger sample size to figure it out which is just not worth it. I'm just going to run some qualitative tests (i.e. try which settings affect the chance in which way) instead of striving for probably impossible to reach quantitative results.
    Last edited by alpaca; 10-11-2007 at 10:10.

  2. #2
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: Research: Bribery Mechanics

    Ok, after deciding to settle for some qualitative results, I decided to test what determines the cost on a successful bribery attempt. I found out it only depends on the bribee's loyalty attribute and all the modifiers don't seem to affect the cost, only the chance. I did my tests with a single spearmen unit (stat-wise very similar to the levy spearmen from vanilla) with 0 and with 6 xp

    However, there's a problem: The function isn't monotonous!



    Exact data:
    Spoiler Alert, click show to read: 
    Code:
    Loyalty	Cost (0 XP)	Cost (6 XP)	Ratio (0xp / 6xp)
    -3	3115	4603	0,68
    -2	4239	5727	0,74
    -1	6490	7978	0,81
    0	8740	10228	0,85
    1	14039	15676	0,9
    2	20688	22474	0,92
    3	26867	30621	0,88
    4	11636	13719	0,85
    5	11235	13467	0,83
    6	10384	12765	0,81
    7	9083	11613	0,78
    8	8607	11285	0,76
    9	9293	12120	0,77
    10	9980	12956	0,77


    Not bad enough that the cost shows a sudden severe drop at a loyalty of 4, the cost doesn't even seem to scale uniformly with army quality so it could well be there's some hidden inversions there, too.

    This is so seriously screwed and insane that I believe there must have been some kind of oversight at work. At first I presumed it was some integer number overflow (i.e. the game wrapping the number around after reaching 2^15 or 2^16) but that doesn't fit either.

    Some number crunching using gnuplot to fit:

    f(x) = b*x + c (values -2 to 0)
    g(x) = g1*x^2 + g2*x + g3 (values 0 to 3)
    h(x) = h1*x^2 + h2*x + h3 (values 4 to 7)
    i(x) = i1*x + i2 (values 8 to 10)



    Spoiler Alert, click show to read: 

    *******************************************************************************
    Fri Oct 12 23:55:07 2007


    FIT: data read from "bribery.txt"
    x range restricted to [-2.00000 : 0.000000]
    #datapoints = 3
    residuals are weighted equally (unit weight)

    function used for fitting: f(x)
    fitted parameters initialized with current variable values



    Iteration 0
    WSSR : 1.23565e+006 delta(WSSR)/WSSR : 0
    delta(WSSR) : 0 limit for stopping : 1e-005
    lambda : 1.1547

    initial set of free parameter values

    b = 1700.4
    c = 10136.5

    After 4 iterations the fit converged.
    final sum of squares of residuals : 0.166667
    rel. change during last iteration : -1.84833e-006

    degrees of freedom (FIT_NDF) : 1
    rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 0.408248
    variance of residuals (reduced chisquare) = WSSR/ndf : 0.166667

    Final set of parameters Asymptotic Standard Error
    ======================= ==========================

    b = 2250.5 +/- 0.2887 (0.01283%)
    c = 10228.2 +/- 0.3727 (0.003644%)


    correlation matrix of the fit parameters:

    b c
    b 1.000
    c 0.775 1.000

    *******************************************************************************
    Fri Oct 12 23:56:37 2007


    FIT: data read from "bribery.txt"
    x range restricted to [0.000000 : 3.00000]
    #datapoints = 4
    residuals are weighted equally (unit weight)

    function used for fitting: g(x)
    fitted parameters initialized with current variable values



    Iteration 0
    WSSR : 7.05427e+007 delta(WSSR)/WSSR : 0
    delta(WSSR) : 0 limit for stopping : 1e-005
    lambda : 3.10913

    initial set of free parameter values

    g1 = -3096.5
    g2 = 14578.7
    g3 = 7965.2

    After 5 iterations the fit converged.
    final sum of squares of residuals : 0.05
    rel. change during last iteration : -3.22514e-007

    degrees of freedom (FIT_NDF) : 1
    rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 0.223607
    variance of residuals (reduced chisquare) = WSSR/ndf : 0.05

    Final set of parameters Asymptotic Standard Error
    ======================= ==========================

    g1 = 674.75 +/- 0.1118 (0.01657%)
    g2 = 4773.45 +/- 0.35 (0.007332%)
    g3 = 10227.9 +/- 0.2179 (0.002131%)


    correlation matrix of the fit parameters:

    g1 g2 g3
    g1 1.000
    g2 -0.958 1.000
    g3 0.513 -0.688 1.000


    *******************************************************************************
    Fri Oct 12 23:59:43 2007


    FIT: data read from "bribery.txt"
    x range restricted to [4.00000 : 7.00000]
    #datapoints = 4
    residuals are weighted equally (unit weight)

    function used for fitting: h(x)
    fitted parameters initialized with current variable values



    Iteration 0
    WSSR : 6.63552e+008 delta(WSSR)/WSSR : 0
    delta(WSSR) : 0 limit for stopping : 1e-005
    lambda : 19.8074

    initial set of free parameter values

    h1 = 1
    h2 = 1
    h3 = 1

    After 8 iterations the fit converged.
    final sum of squares of residuals : 0
    abs. change during last iteration : -3.30872e-024


    Hmmmm.... Sum of squared residuals is zero. Can't compute errors.

    Final set of parameters
    =======================

    h1 = -225
    h2 = 1773
    h3 = 10227


    *******************************************************************************
    Sat Oct 13 00:01:58 2007


    FIT: data read from "bribery.txt"
    x range restricted to [8.00000 : 10.0000]
    #datapoints = 3
    residuals are weighted equally (unit weight)

    function used for fitting: i(x)
    fitted parameters initialized with current variable values



    Iteration 0
    WSSR : 4.41373e+008 delta(WSSR)/WSSR : 0
    delta(WSSR) : 0 limit for stopping : 1e-005
    lambda : 6.4291

    initial set of free parameter values

    i1 = 1
    i2 = 1

    After 6 iterations the fit converged.
    final sum of squares of residuals : 0.166667
    rel. change during last iteration : -5.05772e-011

    degrees of freedom (FIT_NDF) : 1
    rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 0.408248
    variance of residuals (reduced chisquare) = WSSR/ndf : 0.166667

    Final set of parameters Asymptotic Standard Error
    ======================= ==========================

    i1 = 835.5 +/- 0.2887 (0.03455%)
    i2 = 4600.83 +/- 2.609 (0.0567%)


    correlation matrix of the fit parameters:

    i1 i2
    i1 1.000
    i2 -0.996 1.000


    At -3 this seems to be capped so I didn't include that point.
    What's interesting is that h(x) actually gives a very good fit for all except the last three values (it hits the three values it was fit to perfectly and seems to do the same for the -2 and 0 values; -3 is hit almost exactly, too). However the whole thing remains a mystery and I wonder what CA did to generate those values. It's simply totally insane (I think they just included it to see if somebody actually notices - or they smoked some really bad **** that evening)

    For the 0xp test things change slightly. The first 4 points follow the same proportionality, but now the second differentiation has a negative value at loyalty 3 and also differs at 4 and 5, while the rest is similar again.
    Last edited by alpaca; 10-12-2007 at 23:19.

  3. #3

    Default Re: Research: Bribery Mechanics

    Yikes, on the one hand alpaca really great effort into research, on the other hand is loyalty bugged??!

  4. #4
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: Research: Bribery Mechanics

    Quote Originally Posted by SigniferOne
    Yikes, on the one hand alpaca really great effort into research, on the other hand is loyalty bugged??!
    At least the bribery cost calculation is severely flawed. Can't say I tested anything else much but rebelling characters seems to be weird, too.
    I set the min and max chance for a revolt to 100 but only 2 of my 10 characters rebelled which is obviously strange considering that the minimum chance to revolt should be 100% unless the 100 doesn't refer to a percentage but to some modifier value.

    I really wonder what CA did to calculate those costs. I mean it doesn't even seem to follow any real pattern (the fits I gave don't fit the 0 loyalty test anymore, either).

  5. #5

    Default Re: Research: Bribery Mechanics

    Alpaca any more news on this? Does it seem like the loyalty attribute is severely bugged?

  6. #6
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: Research: Bribery Mechanics

    Quote Originally Posted by SigniferOne
    Alpaca any more news on this? Does it seem like the loyalty attribute is severely bugged?
    I didn't get around to test it to be honest. The problem is that with this rng that seems to like streaking you sometimes need a pretty large result pool to make sensible statements. In addition I didn't figure out what the revolt factors actually do so I cast my attention elsewhere for the moment (in fact the last week or so I didn't have any time for modding at all).

  7. #7
    Relentless Bughunter Senior Member FactionHeir's Avatar
    Join Date
    Dec 2006
    Location
    London, UK
    Posts
    8,115

    Default Re: Research: Bribery Mechanics

    There seems to be a hidden time factor in bribery that is based on years rather than turns elapsed (i.e. 2 years = 1 turn by default).

    For instance I was able to buy a neutral catholic quarter stack for about 7000 30 turns (1 year/turn) in, but trying to buy a similar stack 60 years (2 years/turn) in, it cost quite a bit more.

    Another rebel stack of 1 upgraded no experience spear militia cost about 10000 to bribe some 130 years in (2years/turn)
    Want gunpowder, mongols, and timurids to appear when YOU do?
    Playing on a different timescale and never get to see the new world or just wanting to change your timescale?
    Click here to read the solution
    Annoyed at laggy battles? Check this thread out for your performance needs
    Got low fps during siege battles in particular? This tutorial is for you
    Want to play M2TW as a Vanilla experience minus many annoying bugs? Get VanillaMod Visit the forum Readme
    Need improved and faster 2H animations? Download this! (included in VanillaMod 0.93)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO