+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 41 to 54 of 54

Thread: How to code AI for Event selections..

  1. #41
    I was still confused (not sure why, seems like people were saying it was division but i wanted to test it again) so i did some more tests:

    indeed, as expected the non-catholics in these three options seemed to be A70 B25 C5 because of the factor of 1.0. factor of 1.0 does indeed seem to mean 'no change' (70 / 1 = 70) while less than 1.0 seems to indeed mean 'higher chance' because catholics chose option A 90% of the time with this example:
    Code:
    option = {
    		name = "Join the Joust *C33 NC70"		
    		#ai_chance = { factor = 70 }
    		ai_chance = {
    			factor = 70
    			days = 1
    			modifier = {
    				factor = 1.0
    				owner = {
    					NOT = { religion = catholic }
    				}
    			}
    			modifier = {
    				factor = 0.45
    				owner = {
    					religion = catholic
    				}
    			}
    		}
    		owner = { 
    			set_country_flag = Joust_Join
    			clr_country_flag = Joust_Champion
    			clr_country_flag = Joust_No
    			relation = { who = PAP value = -15 }
    		}
    		VAR = { mercantilism_freetrade = 1 }
    	}
    	option = {
    		name = "This is not wise *C33 NC25"		
    		#ai_chance = { factor = 25 }
    		ai_chance = {
    			factor = 25
    			days = 1
    			modifier = {
    				factor = 1.2
    				owner = {
    					religion = catholic
    				}
    			}
    			modifier = {
    				factor = 1.0
    				owner = {
    					NOT = { religion = catholic }
    				}
    			}
    		}
    		owner = { 
    			set_country_flag = Joust_No
    			clr_country_flag = Joust_Champion
    		}
    	}
    	option = {
    		name = "Ban the Joust! *C33 NC5"		
    		#ai_chance = { factor = 5 }
    		ai_chance = {
    			factor = 5
    			days = 1
    			modifier = {
    				factor = 6.0
    				owner = {
    					religion = catholic
    				}
    			}
    			modifier = {
    				factor = 1.0
    				owner = {
    					NOT = { religion = catholic }
    				}
    			}
    		}
    		owner = { 
    			set_country_flag = Joust_Ban
    			clr_country_flag = Joust_No
    			clr_country_flag = Joust_Champion
    			relation = { who = PAP value = 50 }
    		}
    	}
    theory: unlike MTTH modifiers, where it is multiplication ONLY (we all agree on this right?), factors in ai_chance is Division ONLY. this theory is supported by my results with these event options above. according to that theory, catholics had a ai_chance of 156% for option A after the factor was divided. I will run another test and try to achieve a catholic 33% across all three option while non-catholics remain 70,25,5.

    in the test below, results:
    Code:
          catholic                   non-catholi
    A     10                              8
    B      11                             2
    C      3                               1
    it is important to note that option c was actualy about 7% but i thought it was going to be 33%. I thought my test was flawed until I realized that the results actualy go along with my flawed math on option c. also, about half of the events I ran were in a situation where there was no catholic nations, so there would have been more non-catholic data if I did all the tests in the 1649 era.
    Code:
    option = {
    		name = "Join the Joust *C33 NC70"		
    		#ai_chance = { factor = 70 }
    		ai_chance = {
    			factor = 70
    			days = 1
    			modifier = {
    				factor = 1.0
    				owner = {
    					NOT = { religion = catholic }
    				}
    			}
    			modifier = {
    				factor = 2.1
    				owner = {
    					religion = catholic
    				}
    			}
    		}
    		owner = { 
    			set_country_flag = Joust_Join
    			clr_country_flag = Joust_Champion
    			clr_country_flag = Joust_No
    			relation = { who = PAP value = -15 }
    		}
    		VAR = { mercantilism_freetrade = 1 }
    	}
    	option = {
    		name = "This is not wise *C33 NC25"		
    		#ai_chance = { factor = 25 }
    		ai_chance = {
    			factor = 25
    			days = 1
    			modifier = {
    				factor = 0.75
    				owner = {
    					religion = catholic
    				}
    			}
    			modifier = {
    				factor = 1.0
    				owner = {
    					NOT = { religion = catholic }
    				}
    			}
    		}
    		owner = { 
    			set_country_flag = Joust_No
    			clr_country_flag = Joust_Champion
    		}
    	}
    	option = {
    		name = "Ban the Joust! *C33 NC5"		
    		#ai_chance = { factor = 5 }
    		ai_chance = {
    			factor = 5
    			days = 1
    			modifier = {
    				factor = 0.75
    				owner = {
    					religion = catholic
    				}
    			}
    			modifier = {
    				factor = 1.0
    				owner = {
    					NOT = { religion = catholic }
    				}
    			}
    		}
    		owner = { 
    			set_country_flag = Joust_Ban
    			clr_country_flag = Joust_No
    			clr_country_flag = Joust_Champion
    			relation = { who = PAP value = 50 }
    		}
    	}
    Conclusion: seems that this realy is division ONLY for factors.

    Theory: if I change option c, catholic factor to 0.15, the results will be 33%.
    Shalom
    John F. Kennedy
    "For we are opposed around the world by a monolithic and ruthless conspiracy that relies primarily on covert means for expanding its sphere of influence--on infiltration instead of invasion, on subversion instead of elections, on intimidation instead of free choice, on guerrillas by night instead of armies by day."

    John 8:32
    "And ye shall know the truth, and the truth shall make you free."
    Martin Luther King
    "A nation that continues year after year to spend more money on military defense than on programs of social uplift is aproaching spiritual death."

  2. #42
    Dei Gratia author dharper's Avatar
    Crusader Kings IIEU3 CompleteDivine WindFor The GloryHearts of Iron III
    Heir to the ThroneEuropa Universalis III: In NomineMarch of the EaglesEU3 Napoleon's AmbitionVictoria: Revolutions
    Europa Universalis: RomeSengokuVictoria 2Victoria II: A House DividedVictoria II: Heart of Darkness
    Rome: Vae VictisEU3 Collectors Edition500k clubEuropa Universalis IV: Pre-orderEUIV: Wealth of Nations
    EUIV: Conquest of ParadiseEUIV: Res Publica

    Join Date
    Aug 2002
    Location
    Province #989 (EU3/4)
    Posts
    15,427
    I'm having trouble following you here, but math has never been my strong suit.

    Looking at your event, I would expect these results for Catholics:

    A = weight 70/0.45 = 155.6
    B = weight 25/1.2 = 20.8
    C = weight 5/6 = 0.8

    Total weight = 177.2, giving us the expected probabilities of:

    A = 155.6/177.2 = 87.8%
    B = 20.8/177.2 = 11.7%
    C = 0.8/177.2 = 0.5%

    Is this not the case?

    In my own tests I usually don't get results like these in the short run; I get better results over long periods of time, especially if the actual events are far apart. I suspect this has to do with the way EU3 determines random numbers.
    A mod for Europa Universalis IV that enhances religion in the age of faith and reason
    Over 1,100 events and decisions for over 30 religions
    Wiki
    Version 1.7.08 compatible with the Res Publica expansion
    Download available (August 23, 2014) or subscribe on Steam to get updates automatically
    Project Cryptic: 25% complete

  3. #43
    Quote Originally Posted by dharper
    I'm having trouble following you here, but math has never been my strong suit.

    Looking at your event, I would expect these results for Catholics:

    A = weight 70/0.45 = 155.6
    B = weight 25/1.2 = 20.8
    C = weight 5/6 = 0.8

    Total weight = 177.2, giving us the expected probabilities of:

    A = 155.6/177.2 = 87.8%
    B = 20.8/177.2 = 11.7%
    C = 0.8/177.2 = 0.5%

    Is this not the case?

    In my own tests I usually don't get results like these in the short run; I get better results over long periods of time, especially if the actual events are far apart. I suspect this has to do with the way EU3 determines random numbers.
    actualy, you are exactly right as to how my first set of posted options worked. these joust events spanned over months (game time) and i do not think any (or hardly any) of those data collecting events happened on the same day. so if random numbers change every day, then i think it would not effect the event (am i right?).

    on my second example of options I understood the math better. if i change the option c factor for catholics to 0.15, then in theory, all three options for catholics should be 33% or so while non catholics are more like 70/25/5. Am I right in these assumptions? the data on the second option set did seem to confirm this.

  4. #44
    Darken, observation seemed to me to confirm what your thorough analysis proves; that MTTH is multiplied by modifying factors, whereas ai_chance is divided by multiplying factors. We can probably set that in stone as basic modding knowledge.
    Mourning Magna Mundi

  5. #45
    Quote Originally Posted by Helius
    Darken, observation seemed to me to confirm what your thorough analysis proves; that MTTH is multiplied by modifying factors, whereas ai_chance is divided by multiplying factors. We can probably set that in stone as basic modding knowledge.
    I agree. I dont know why it took me so long to grasp the concept that the ai_chance simply used division. it seemed everyone figured this out earlier than me. anyway, since we all seem to agree now that its division, I hope to finaly adjust some events so that they use these ai_chance modifiers This along with the INx AI files will make a rather good AI system for EU3.

  6. #46
    Six-star scriptmaster alvya's Avatar
    Crusader Kings IIDeus VultEuropa Universalis 3Europa Universalis III: In NomineEU3 Napoleon's Ambition
    500k clubEuropa Universalis IV: Pre-order

    Join Date
    Mar 2003
    Location
    Betanzos, A Coruña, España
    Posts
    3,674
    Quote Originally Posted by Darken
    actualy, you are exactly right as to how my first set of posted options worked. these joust events spanned over months (game time) and i do not think any (or hardly any) of those data collecting events happened on the same day. so if random numbers change every day, then i think it would not effect the event (am i right?).
    The random number DOESN'T change every day. If you create an event with a MTTH of 1 day and many options you will see:
    -Countries that get the event the same day select the same option.
    Conclusion: all of them use the same number.
    -Usually countries that get the event close in the time also select the same option. Suddenly the number change and the option is different several days. With a different number each day you should see different options each day. You could see the same option several days. But usually different options. That doesn't happen.
    Conclusion: the random number generator doesn't choose a new number each day.
    Proud member of the Big Four of Magna Mundi Mod.
    Orgulloso miembro de los Cuatro Grandes del Mod Magna Mundi.

  7. #47
    Quote Originally Posted by alvya
    The random number DOESN'T change every day. If you create an event with a MTTH of 1 day and many options you will see:
    -Countries that get the event the same day select the same option.
    Conclusion: all of them use the same number.
    -Usually countries that get the event close in the time also select the same option. Suddenly the number change and the option is different several days. With a different number each day you should see different options each day. You could see the same option several days. But usually different options. That doesn't happen.
    Conclusion: the random number generator doesn't choose a new number each day.
    ok, thank you how often do you think the random number gets changed?

    I used to call this (where two of the same events happen at the same time) the 'Event Echo' bug. I thought that it was a bug when two countries got the same exact uncommon event at the same exact moment. Perhaps I am wrong though.

  8. #48
    Six-star scriptmaster alvya's Avatar
    Crusader Kings IIDeus VultEuropa Universalis 3Europa Universalis III: In NomineEU3 Napoleon's Ambition
    500k clubEuropa Universalis IV: Pre-order

    Join Date
    Mar 2003
    Location
    Betanzos, A Coruña, España
    Posts
    3,674
    Quote Originally Posted by Darken
    ok, thank you how often do you think the random number gets changed?

    I used to call this (where two of the same events happen at the same time) the 'Event Echo' bug. I thought that it was a bug when two countries got the same exact uncommon event at the same exact moment. Perhaps I am wrong though.
    I am not sure. My bet (not tested) is that the game calculate a new number when it needs it (a battle, a merchant...) and then use the last number in the events until it calculates a new one. But probably it also calculates a new one each month.

    But this is all an untested theory based in the fact that some values (number of cities of the country, number of merchants...) sometimes aren't refreshed. For example, if the controller of one of your provinces changes by event the value of controlled provinces that the game uses doesn't change. But if two days later you fight in a battle, when the battle ends, the value is changed.
    Proud member of the Big Four of Magna Mundi Mod.
    Orgulloso miembro de los Cuatro Grandes del Mod Magna Mundi.

  9. #49
    Studio Manager Paradox Dev Team Johan's Avatar
    Crusader Kings II

    Join Date
    Dec 1999
    Location
    I iskall kyla...
    Posts
    16,035
    Blog Entries
    2
    Its a logical error which makes it use MTTH calcs instead of absolute values.

    Johan Andersson
    Studio Manager at Paradox Development Studio AB - Follow me at Twitter!

    "A patch is never late! Nor is it ever early. It arrives precisely when I mean it to do!"

    For our Patching and Expansion Policy, read here...

    Read here why EU4 requires steam!

  10. #50
    Well, I have been seeing some wierd outcomes with ai_chance modifiers in IN.

    I had the theory like most others that it was division so most of my modifiers use a base factor of 50 or so and then the modifiers use 0.67 to get the chance to 75% or 2.0 to get the chance to 25%. When I first tested division theory with my joust events, the results were as expected and I made up my mind it was division.

    Now, in IN, I seem to be getting the nearly opposite ai_chance modifiers results which may suggest that IN changes ai_chance modifiers to multiplication. now I have not tested this directly, but the in game AI changes to seem to suggest something is wrong with ai_chance modifiers in TN mod with IN. TsarAlexanderII also seems to be seeing some problems with ai_chance and he also thinks it might now be multiplication. Both of us will be doing further tests.

    Has anyone else seen problems with ai_chance modifiers in IN? anyone else do tests with IN?

  11. #51
    General orwell's Avatar
    Hearts of Iron 2: ArmageddonCrusader Kings IIDeus VultEuropa Universalis 3Divine Wind
    For the MotherlandHearts of Iron IIIHeir to the ThroneEuropa Universalis III: In NomineEU3 Napoleon's Ambition
    Victoria: RevolutionsEuropa Universalis: RomeSemper FiSupreme Ruler 2020Victoria 2
    Victoria II: A House DividedRome: Vae VictisMount & Blade: WarbandEuropa Universalis IV

    Join Date
    Sep 2006
    Location
    Washington
    Posts
    2,224
    Blog Entries
    8
    Was this ever confirmed as multiplication? Does the upcoming patch fix a potential problem here?
    Even an ignorant, paranoid, cowardly, ugly, corrupt, unsociable, aristocratic thug can conquer large parts of the world, kill thousands of people and be celebrated as the saviour of the Republic.

  12. #52
    Six-star scriptmaster alvya's Avatar
    Crusader Kings IIDeus VultEuropa Universalis 3Europa Universalis III: In NomineEU3 Napoleon's Ambition
    500k clubEuropa Universalis IV: Pre-order

    Join Date
    Mar 2003
    Location
    Betanzos, A Coruña, España
    Posts
    3,674
    Quote Originally Posted by orwell
    Was this ever confirmed as multiplication? Does the upcoming patch fix a potential problem here?
    In IN it uses multiplications instead of divisions as in NA.
    Proud member of the Big Four of Magna Mundi Mod.
    Orgulloso miembro de los Cuatro Grandes del Mod Magna Mundi.

  13. #53
    Quote Originally Posted by Darken View Post
    I had a 0% joust ban rate for catholic nations with this province event test. so either i did something wrong or the ai_chance modifiers will not work in province events. the events fired fine, just no nation chose this ban option. also, i know it doesnt mess up the event otherwise because I have the exact same option in the Joust hosting event that allows the Joust Join events that i tested with thsi option. I think this is the same way the events acted when i tried this test without days = 1 in the past. I also tried this option with a factor of 5. still no Bans. Also, I know the rest of the event chain works fine because they fire often and have been in my mod for months.
    Has anyone established whether this modding tool will or will not work with province events? I've been messing around with it myself without much success, and I feel confident with the code.
    Europa Universalis 3 Player
    -------------------------------------------------------------------------------------------

  14. #54
    Nevermind , I just got a light bulb and found that my code wasn't so solid after all. So, in confirmation this tool definitely works for province events.
    Europa Universalis 3 Player
    -------------------------------------------------------------------------------------------

+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts