+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 37

Thread: About events, triggers, MTTH and performance

  1. #1

    About events, triggers, MTTH and performance

    This post had me thinking so I decided to test a few things. I had some interesting results, to say the least.

    I have a setup with a country in the middle of the pacific who knows nothing about the world except for its island and sea zone. I made the following event:

    Code:
    country_event = {
    	id = 97990001
    
    	trigger = {
    		#tag = ALI
    		has_country_flag = willneverhappen
    	}
    
    
    	mean_time_to_happen = {
    		days = 1
    	}
    
    	title = "Testing event"
    	desc = "Testing effect of mtth scale."
    
    	option = {
    		name = "I am done here"
    
    		prestige = 0.01
    		clr_country_flag = willneverhappen
    	}
    }
    I duplicated the event a thousand times, made a version with years instead of days in MTTH, and another version each where "tag = ALI" was not commented out. Then I ran the game from july 1st 1453 to july 1st 1454 and noted the time it took. Here are the results, with a +/- 2 seconds error margin:

    Code:
    No known countries
    
    first run: 	2:50	vanilla events
    second run:	3:33	vanilla+900 events with days = 1
    third run:	3:31	vanilla+900 events with years = 1
    fourth run:	2:46	vanilla+900 events with years = 1 and tag = ALI
    fifth run:	2:51	vanilla+900 events with days = 1 and tag = ALI
    Then I loaded a game 10 years later with the same country, where I knew almost all countries.

    Code:
    knows most countries
    
    first run: 	3:03	vanilla events
    second run:	3:50	vanilla+900 events with days = 1
    third run:	3:56	vanilla+900 events with years = 1
    fourth run:	3:04	vanilla+900 events with years = 1 and tag = ALI
    fifth run:	3:20	vanilla+900 events with days = 1 and tag = ALI
    As expected, the game ran slower.

    What's next? Well 900 events doesn't seem to change the speed all that much, how about 5000?

    Code:
    no known countries
    
    second run:	7:12	vanilla+4500 events with days = 1
    third run:	7:16	vanilla+4500 events with years = 1
    fourth run:	2:57	vanilla+4500 events with years = 1 and tag = ALI
    fifth run:	2:55	vanilla+4500 events with days = 1 and tag = ALI
    Finally we can see that "tag = XXX" is really the fastest way to do things, when you can afford to use a hardcoded country. But wait, what if the engine can recognize that 2 events have the same triggers and process them as 1? After all, those 4500 events all have the same triggers.

    Here is a new version of the event I made:

    Code:
    country_event = {
    	id = 97990000
    
    	trigger = {
    		tag = ALI
    		has_country_flag = will97990000
    	}
    
    
    	mean_time_to_happen = {
    		days = 1
    	}
    
    	title = "Testing event"
    	desc = "Testing effect of mtth scale."
    
    	option = {
    		name = "I am done here"
    
    		prestige = 0.01
    		treasury = 0000
    	}
    }
    All the "0000" gets incremented while duplicating the event a thousand times. That gives us 5000 events (yeah, I did not miss a group of 100 this time) with different triggers and even different effects just to be on the safe side.

    Anyone wants to take a guest at the final timer? I'll post it tomorrow.

    As a side note, I tried the first run without any files in the music folder, this is what I got:

    Code:
    No known countries
    
    sixth run:	2:33	vanilla no music files
    seventh run:	2:40	vanilla no music files + winplayer at high priority
    What conclusion can we draw from this? Well the most obvious one is that I have way too much time on my hands.

  2. #2
    Sort of kind of back dharper's Avatar
    EU3 Collectors Edition OwnerNapoleonic MarshalEuropa Universalis: RomeVictoria: RevolutionsEuropa Universalis III: In Nomine
    EU3 CompleteRome: Vae VictisHearts of Iron IIISupreme Ruler 2020 GoldFor The Glory
    Heir to the ThroneSemper FiVictoria 2Divine WindCrusader Kings II
    Pride of NationsFor the MotherlandVictoria II: A House Divided

    Join Date
    Aug 2002
    Location
    Province #989 (EU3)
    Posts
    12,467
    Fascinating and useful.

    Please be sure to post your conclusions in simple English for those of us, like me, who have had their brains stolen by squirrels and can't draw our own conclusions from your data.

    What I am seeing:
    1) Mean time seems to be relatively insignificant (using the 1.3 patch) to game speed.
    2) Limiting an event to a single country will make the game run faster - and this gap becomes greater the more events there are in the game.
    3) The more countries you can see, the slower the game will run.
    Last edited by dharper; 12-06-2007 at 19:56.

    A mod for EU3: In Nomine and EU3: Complete that enhances religion
    Religious Minorities - More Religions - Religious Fervor - New Graphics - Hundreds of Events and Decisions
    New In Nomine version released December 31, 2011 (less than a month ago)

    Still playing EU3: Complete? Get my Magna Mundi Platinum 2 bugfix for religion and the Sengoku.

    Honor of Lancaster: A Magna Mundi IV AAR (finished)




  3. #3
    MM Dev Team
    EU3 Collectors Edition OwnerNapoleonic MarshalDeus Vult!Hearts of Iron 2: ArmageddonEuropa Universalis III: In Nomine
    Heir to the ThroneMount & Blade: WarbandSword of the StarsDarkest Hour

    Join Date
    Dec 2000
    Location
    Lisbon
    Posts
    18,694
    Quote Originally Posted by JaxomCA
    This post had me thinking so I decided to test a few things. I had some interesting results, to say the least.

    I have a setup with a country in the middle of the pacific who knows nothing about the world except for its island and sea zone. I made the following event:

    Code:
    country_event = {
    	id = 97990001
    
    	trigger = {
    		#tag = ALI
    		has_country_flag = willneverhappen
    	}
    
    
    	mean_time_to_happen = {
    		days = 1
    	}
    
    	title = "Testing event"
    	desc = "Testing effect of mtth scale."
    
    	option = {
    		name = "I am done here"
    
    		prestige = 0.01
    		clr_country_flag = willneverhappen
    	}
    }
    I duplicated the event a thousand times, made a version with years instead of days in MTTH, and another version each where "tag = ALI" was not commented out. Then I ran the game from july 1st 1453 to july 1st 1454 and noted the time it took. Here are the results, with a +/- 2 seconds error margin:

    Code:
    No known countries
    
    first run: 	2:50	vanilla events
    second run:	3:33	vanilla+900 events with days = 1
    third run:	3:31	vanilla+900 events with years = 1
    fourth run:	2:46	vanilla+900 events with years = 1 and tag = ALI
    fifth run:	2:51	vanilla+900 events with days = 1 and tag = ALI
    Then I loaded a game 10 years later with the same country, where I knew almost all countries.

    Code:
    knows most countries
    
    first run: 	3:03	vanilla events
    second run:	3:50	vanilla+900 events with days = 1
    third run:	3:56	vanilla+900 events with years = 1
    fourth run:	3:04	vanilla+900 events with years = 1 and tag = ALI
    fifth run:	3:20	vanilla+900 events with days = 1 and tag = ALI
    As expected, the game ran slower.

    What's next? Well 900 events doesn't seem to change the speed all that much, how about 5000?

    Code:
    no known countries
    
    second run:	7:12	vanilla+4500 events with days = 1
    third run:	7:16	vanilla+4500 events with years = 1
    fourth run:	2:57	vanilla+4500 events with years = 1 and tag = ALI
    fifth run:	2:55	vanilla+4500 events with days = 1 and tag = ALI
    Finally we can see that "tag = XXX" is really the fastest way to do things, when you can afford to use a hardcoded country. But wait, what if the engine can recognize that 2 events have the same triggers and process them as 1? After all, those 4500 events all have the same triggers.

    Here is a new version of the event I made:

    Code:
    country_event = {
    	id = 97990000
    
    	trigger = {
    		tag = ALI
    		has_country_flag = will97990000
    	}
    
    
    	mean_time_to_happen = {
    		days = 1
    	}
    
    	title = "Testing event"
    	desc = "Testing effect of mtth scale."
    
    	option = {
    		name = "I am done here"
    
    		prestige = 0.01
    		treasury = 0000
    	}
    }
    All the "0000" gets incremented while duplicating the event a thousand times. That gives us 5000 events (yeah, I did not miss a group of 100 this time) with different triggers and even different effects just to be on the safe side.

    Anyone wants to take a guest at the final timer? I'll post it tomorrow.

    As a side note, I tried the first run without any files in the music folder, this is what I got:

    Code:
    No known countries
    
    sixth run:	2:33	vanilla no music files
    seventh run:	2:40	vanilla no music files + winplayer at high priority
    What conclusion can we draw from this? Well the most obvious one is that I have way too much time on my hands.


    Your flaw is to apply this event to a single country, using a very simple trigger, without modifiers, limits, etc. This is the classical example that a lab experience rarely stands up to the real world effects. When you have hundreds of events with lots of conditions things start to get slower.


    From my tests in Magna Mundi III, I was able to shave off about 20% of the yearly time in my computer just changing the MTTH. It is true I have no data for version 1.3 and that this version net gains in the order of 15% while running Magna Mundi, but even then, in my book it is significant.
    == MAGNA MUNDI ==

    PAY GOLD,
    SHED BLOOD,
    INSTILL FEAR,
    PROMISE HOPE


    HISTORY IS YOURS!

  4. #4
    More data from the mad laboratory. Here is the event, the year version use 160 years to have the same mtth.

    Code:
    country_event = {
    
    	id = 97990000
    
    	trigger = {
    		NOT = { aristocracy_plutocracy = 2 }
    		NOT = { DIP = 7 }
    		centralization_decentralization = 2
    	}
    
    	mean_time_to_happen = {
    		days = 58400
    		
    		modifier = {
    			factor = 0.5
    			OR = {
    				NOT = { constable = 1 }
    				NOT = { courthouse = 1 }
    			}
    		}
    		modifier = {
    			factor = 0.8
    			NOT = { stability = 0 }
    		}
    		modifier = {
    			factor = 2.0
    			luck = yes
    		}
    		modifier = {
    			factor = 1.2
    			stability = 1
    		}
    		modifier = {
    			factor = 1.5
    			OR = {
    				constable = 2
    				courthouse = 2
    			}
    		}
    	}
    
    	title = "TESTMTTH"
    	desc = "EVTDESC5077"
    
    	option = {
    		name = "EVTOPTA5077"		# Let them handle it
    		ai_chance = { factor = 20 }
    		treasury = 10
    
    		any_country = {
    		    limit = {
    			num_of_cities = 1
    			NOT = { aristocracy_plutocracy = 2 }
    			NOT = { DIP = 5 }
    			centralization_decentralization = 2
    		    }
    
    		    relation = { who = THIS value = 1 }
    		}
    	}
    	option = {
    		name = "EVTOPTB5077"		# Increase attempts
    		ai_chance = { factor = 80 }
    
    		# 1-4
    		random_owned = {
    			limit = {
    			    owner = {
    				num_of_cities = 1
    				NOT = { num_of_cities = 5 }
    			    }
    			}
    			owner = { treasury = 2 }
    		}
    
    		# 5-9
    		random_owned = {
    			limit = {
    			    owner = {
    				num_of_cities = 5
    				NOT = { num_of_cities = 10 }
    			    }
    			}
    			owner = { treasury = 4 }
    		}
    
    		# 10-29
    		random_owned = {
    			limit = {
    			    owner = {
    				num_of_cities = 10
    				NOT = { num_of_cities = 30 }
    			    }
    			}
    			owner = { treasury = 6 }
    		}
    
    		# 30-79
    		random_owned = {
    			limit = {
    			    owner = {
    				num_of_cities = 30
    				NOT = { num_of_cities = 80 }
    			    }
    			}
    			owner = { treasury = 10 }
    		}
    
    		# 80+
    		random_owned = {
    			limit = {
    			    owner = {
    				num_of_cities = 80
    			    }
    			}
    			owner = { treasury = 25 }
    		}
    	}
    }
    And here are the results:

    Code:
    no known countries, trigger true for many countries, 5 mtth modifiers
    second run:	3:44	vanilla+1000 events with days = 58400
    third run:	3:40	vanilla+1000 events with years = 160
    A difference of less than 2%, in the early part of the game when everybody picks a fight with everybody, I'll consider this a wash.

    I did make a run with Cyprus to see if the event triggered often enough. 4-5 times per day is plenty enough.

    If anybody needs an event imperfectly cloned a few thousand times, don't call me.

  5. #5
    MM Dev Team
    EU3 Collectors Edition OwnerNapoleonic MarshalDeus Vult!Hearts of Iron 2: ArmageddonEuropa Universalis III: In Nomine
    Heir to the ThroneMount & Blade: WarbandSword of the StarsDarkest Hour

    Join Date
    Dec 2000
    Location
    Lisbon
    Posts
    18,694
    I respect your tests, but I continue to stand by my numbers.

    The numbers show the average yearly time for a Magna Mundi game in my machine was at release a bit more than 6 minutes and the last version compatible with patch 1.2.1 was a bit more than 4 minutes.
    == MAGNA MUNDI ==

    PAY GOLD,
    SHED BLOOD,
    INSTILL FEAR,
    PROMISE HOPE


    HISTORY IS YOURS!

  6. #6
    Well it seems I have a large audience. Just to complete the record, here is the answer to yesterday's trivia:

    What if the engine can recognize that 2 events have the same triggers and process them as 1?

    Anyone wants to take a guest at the final timer?
    Here is the anwser:

    Code:
    fourth run:	2:57	vanilla+4500 events with years = 1 and tag = ALI
    fifth run:	2:55	vanilla+4500 events with days = 1 and tag = ALI
    sixth run:	3:00	vanilla+5000 events + tag = ALI + varying trigger and effect
    I think it is safe to say the engine does not have special optimizations for matching events.

    Since yesterday, I found a much better tool to do massive "search and replace", so I did yet another test about MTTH type:

    Code:
    10000 events, trigger true for many countries including Japan, my only known country, 3 months run
    
    days = 58400	3:27	23 times for Japan, 3 option A	months = 1920
    years = 160	3:28	25 times for Japan, 6 option A	months = 1920
    months = 15000	3:26	20 times for Japan, 3 option A 	with a 0.5 factor changed to 10.0
    (The last test opens up another area of investigation, which I'll get back to later under Japan MTTH issue.)

    That test settles the MTTH issue for me. Base on these tests, and previous observations from my own modding effeorts, I formed the following theory:
    • For country events, every event is checked every day for every countries who currently exist in the game.
    • For province events, every event is checked every day for every OWNED provinces.
    • MTTH value and modifiers have no impact while the trigger is false, the number of modifiers do matter when the trigger is true.
    • Options have no impact until the event actually fires. Then they have an impact going from negligeable to noticeable depending on what the option does.
    • Untested hypothesis 1: some triggers make the engine scan a smaller list of candidates (example: tag = XXX).
    • Untested hypothesis 2: the engine stops processing a country/province as soon as one trigger is false.

    The general guidelines (linked post in my first post) are mostly correct. Some triggers have a big effect on performance, like 'tag = XXX'. I did not test these, but I suspect they will all have the same impact as 'tag = XXX'.

    Note: in the following lists, XXX refers to a specific country tag or province id, where applicable.

    List of trigger which can greatly reduce processing time of an event:
    • tag = XXX confirmed
    • is_emperor = yes
    • is_papal_controller = yes
    • owns = XXXX
    • controls = XXXX

    Any of the previous triggers will not help if used inside a 'NOT'. I don't think any other triggers will have as big an impact.

    I also suspect some triggers can somewhat reduce processing time because they can be checked in a much smaller list. Whether the engine uses the smaller list is unknown at this time. If I had to guess, I'd say the engine doesn't use the smaller list.
    • war = yes
    • has_discovered = XXXX
    • continent =
    • elector = yes
    • defender_of_faith = yes

    Everything else will get the engine to process every country/province. You can help reduce processing time by ordering the triggers from most likely to be false to least likely to be false. Of course, any triggers from the 'tag' list should always come before any other triggers.

    Now about the Japan MTTH issue. Refering to the test results, it appears that MTTH has little impact on the frequency of an event, once it gets over a certain value. My current setup allows me to do multiple tests about event frequency, does anybody have suggestions on the type of tests I should do? I am thinking of the following tests:
    • one run with a straight MTTH, comparing various values between months = 12 and months = 15000
    • one run with a fix MTTH, comparing various modifier values from 0.1 to 10.0

    Brought to you by the freeloaders from the Mad laboratory Inc.

    Ubik, if you can say with 100% certitude that all you did was to convert days = xxx to years = xxx with the exact same number of days in each cases, then I would say that days/months/years processing has been changed in version 1.3.

    On the other hand, I have been a programmer for over 25 years. I know that when you look over a piece of code, you feel compelled to "tweak" it when you see something wrong. That could have had a big impact on the results you got.

    Regardless, I can't say what the situation was in 1.2.1, I can only say those are the results I get in 1.3.

  7. #7
    MM Dev Team
    EU3 Collectors Edition OwnerNapoleonic MarshalDeus Vult!Hearts of Iron 2: ArmageddonEuropa Universalis III: In Nomine
    Heir to the ThroneMount & Blade: WarbandSword of the StarsDarkest Hour

    Join Date
    Dec 2000
    Location
    Lisbon
    Posts
    18,694
    Quote Originally Posted by JaxomCA
    [...]
    Ubik, if you can say with 100% certitude that all you did was to convert days = xxx to years = xxx with the exact same number of days in each cases, then I would say that days/months/years processing has been changed in version 1.3.

    On the other hand, I have been a programmer for over 25 years. I know that when you look over a piece of code, you feel compelled to "tweak" it when you see something wrong. That could have had a big impact on the results you got.

    Regardless, I can't say what the situation was in 1.2.1, I can only say those are the results I get in 1.3.

    No. I converted dozens of events that had a mtth of a few days to 1 month, a few who had a large number of days to the aproximate number of months/years and several dozens of events that were measured in months I converted to years.

    This reduced by about 20% the time taken to pass a year in my machine.
    The other 15% was due to the not systematic rework of triggers, where the ones who exclude most countries/provinces went top. Also, improbable triggers went top (like NOT YEAR = 1455).
    == MAGNA MUNDI ==

    PAY GOLD,
    SHED BLOOD,
    INSTILL FEAR,
    PROMISE HOPE


    HISTORY IS YOURS!

  8. #8
    Sort of kind of back dharper's Avatar
    EU3 Collectors Edition OwnerNapoleonic MarshalEuropa Universalis: RomeVictoria: RevolutionsEuropa Universalis III: In Nomine
    EU3 CompleteRome: Vae VictisHearts of Iron IIISupreme Ruler 2020 GoldFor The Glory
    Heir to the ThroneSemper FiVictoria 2Divine WindCrusader Kings II
    Pride of NationsFor the MotherlandVictoria II: A House Divided

    Join Date
    Aug 2002
    Location
    Province #989 (EU3)
    Posts
    12,467
    Quote Originally Posted by JaxomCA
    Now about the Japan MTTH issue. Refering to the test results, it appears that MTTH has little impact on the frequency of an event, once it gets over a certain value. My current setup allows me to do multiple tests about event frequency, does anybody have suggestions on the type of tests I should do?
    Check out the second page of my mod (posts 34-40) for a very amateurish attempt to solve this one.

    It turns out that, at least in my tests, I found no significant difference between events with a mean time of 5000-6000 months and events with a mean time of 500,000 months. Mean times of over 700,000 months or so caused the events to never fire. Changing mean times to years equivalent did not change these facts. Adding modifiers that would increase mean time did not change these facts. Modifiers DID change mean times as long as total mean time stayed under 5,000 or so.

    I would suggest comparing events with a mean time of 4,000 months, 5,000 months, 6,000 months, 7,000 months and 500,000 months.

    A mod for EU3: In Nomine and EU3: Complete that enhances religion
    Religious Minorities - More Religions - Religious Fervor - New Graphics - Hundreds of Events and Decisions
    New In Nomine version released December 31, 2011 (less than a month ago)

    Still playing EU3: Complete? Get my Magna Mundi Platinum 2 bugfix for religion and the Sengoku.

    Honor of Lancaster: A Magna Mundi IV AAR (finished)




  9. #9
    Allright, I cooked up the following event:

    Code:
    country_event = {
    
    	id = 97990000
    
    	trigger = {
    		tag = JAP
    		has_country_flag = testmtth
    	}
    
    	mean_time_to_happen = {
    		months = 1000
    		
    		modifier = {
    			factor = 0.1
    			has_country_flag = fast10
    		}
    		modifier = {
    			factor = 0.5
    			has_country_flag = fast2
    		}
    		modifier = {
    			factor = 2.0
    			has_country_flag = slow2
    		}
    		modifier = {
    			factor = 3.0
    			has_country_flag = slow3
    		}
    		modifier = {
    			factor = 4.0
    			has_country_flag = slow4
    		}
    		modifier = {
    			factor = 5.0
    			has_country_flag = slow5
    		}
    		modifier = {
    			factor = 6.0
    			has_country_flag = slow6
    		}
    		modifier = {
    			factor = 7.0
    			has_country_flag = slow7
    		}
    		modifier = {
    			factor = 8.0
    			has_country_flag = slow8
    		}
    		modifier = {
    			factor = 9.0
    			has_country_flag = slow9
    		}
    		modifier = {
    			factor = 10.0
    			has_country_flag = slow10
    		}
    		modifier = {
    			factor = 0.1
    			has_country_flag = afast10
    		}
    		modifier = {
    			factor = 0.5
    			has_country_flag = afast2
    		}
    	}
    
    	title = "TESTMTTH"
    	desc = "EVTDESC5077"
    
    	option = {
    		name = "EVTOPTA5077"		# Let them handle it
    		ai_chance = { factor = 20 }
    		treasury = 100
    	}
    	option = {
    		name = "EVTOPTB5077"		# Increase attempts
    		ai_chance = { factor = 80 }
    		treasury = 10
    	}
    }
    I'll setup the flags for Japan between runs, so I don't have to duplicate the event a million times! I'll duplicate the event 5000 times and run the game for 12 months. I'll extract from the game log how many times the event did fire and record that.

    Once I figure out when the mtth becomes meaningless, if ever, I'll do a run with 500000 months and one with 800000 months.

    Does anybody see anything wrong with the test case?

  10. #10
    Some results, rather surprizing at that.

    First, I did try to find out which triggers had a big impact on performance gains.

    Code:
    5000 events, trigger always true for a single country
    		Min	Secs	Extra secs/100 years/event
    vanilla		2:16	136
    has_flag=	6:40	400	5,28
    tag = XXX	3:00	180	0,88
    owns =	XXXX	3:02	182
    controls = XXXX	3:03	183
    is_emperor=yes	3:09	189
    is_papal=yes	3:01	181
    luck=yes	3:18	198
    That confirms my previous list, the nice surprize here is that 'luck' is one of the efficient triggers. If you have many events triggering on a lucky country to hide them from the player, do make sure the 'luck = yes' is at the top.

    Now some data about MTTH, this was my first batch of tests:

    Code:
    MTTH frequency tests: months = 1000
    			times triggered/AI a choice (20%)
    1000 events, no modifiers	12/2		exact match to expectation
    5000 events, no modifiers	57/12		close enough
    5000 events, factor 2.0		30/6		close enough
    5000 events, factor 3.0		41/12		hmm, anomaly?
    5000 events, factor 3.0		32/9		hmm, still outside expectations.
    Troubling results, ok let's try this again:

    Code:
    5000 events, trigger always true for Japan, running for 1 yea
    
    rmonths	factor	Normalized
    		Average		runs 1 to 12
    
    1000	none	52.1/11.9	57/12	49/12	48/10	39/15!	45/14	71/14	59/12	39/4	65/12	55/10	63/16	41/8
    1000	2.0	29.0/6.6	30/6	35/8	31/6	23/3	22/1	29/4	38/12	23/7	31/9	36/14	20/4	30/7
    1000	3.0	29.0/5.4	41/12	32/9	40/4	23/6	33/7	15/5?	17/3	31/5	25/3	34/4	28/4	27/7
    3000	none	27.0/5.7	33/12	28/7	23/6	23/2	31/6	29/9	25/5	26/4	25/7	31/6	28/3	24/4
    4000	none	27.8/6.1	28/6	26/5	25/5	27/6	27/9	20/6	31/5	32/4	28/5	26/7	39/7	28/9
    From these results, it appears that anything above 2000 months gives the same frequency. So, where I am going wrong?

  11. #11
    Aspiring Global Hegemon Zwackus's Avatar
    EU3 OwnerMajesty 2Magicka

    Join Date
    May 2005
    Location
    秩父市、埼玉県、日本
    Posts
    637
    From these results, it appears that anything above 2000 months gives the same frequency. So, where I am going wrong?
    I believe DHarper figured out something like this before . . . there is a really low effective cut off for MTTH. To hear that it's 2000, not 5000, is rather sad, though.
    Author of the ComboMod, the number 2 mod for Europa Universalis 3 in the three months or so just after release.

  12. #12
    Sort of kind of back dharper's Avatar
    EU3 Collectors Edition OwnerNapoleonic MarshalEuropa Universalis: RomeVictoria: RevolutionsEuropa Universalis III: In Nomine
    EU3 CompleteRome: Vae VictisHearts of Iron IIISupreme Ruler 2020 GoldFor The Glory
    Heir to the ThroneSemper FiVictoria 2Divine WindCrusader Kings II
    Pride of NationsFor the MotherlandVictoria II: A House Divided

    Join Date
    Aug 2002
    Location
    Province #989 (EU3)
    Posts
    12,467
    Quote Originally Posted by Zwackus
    I believe DHarper figured out something like this before . . . there is a really low effective cut off for MTTH. To hear that it's 2000, not 5000, is rather sad, though.
    I'd say "disturbing".

    A 2000-month limit for country events isn't too bad. A 2000-month limit for province events is bugged.

    A mod for EU3: In Nomine and EU3: Complete that enhances religion
    Religious Minorities - More Religions - Religious Fervor - New Graphics - Hundreds of Events and Decisions
    New In Nomine version released December 31, 2011 (less than a month ago)

    Still playing EU3: Complete? Get my Magna Mundi Platinum 2 bugfix for religion and the Sengoku.

    Honor of Lancaster: A Magna Mundi IV AAR (finished)




  13. #13
    I was about to do a handsoff game, so I added some events to do another test on MTTH.

    Each m= (months=) is duplicated 10 times, the trigger is always true for both countries. Only one province in each country pass the trigger of the province event. I ran 5 sessions of 20 years each, extracting the events from the game log is a pain.

    Code:
    			m=100	m=200	m=500	m=1000	m=2000	m=4000	m=5000	m=8000	m=10000	m=400k	m=800k
    --------------------------------------------------------------------------------------------------------------
    191 player country	 93	 45	 16	  4	  5	  6	  8	  8	  2	  4	  0
    193 japan country	 85	 36	 25	 13	  7	  7	  8	  5	  5	  2	  0
    			-----	-----	-----	-----	-----	-----	-----	-----	-----	-----	-----
    384 total country	178	 81	 41	 17	 12	 13	 16	 13	  7	  6	  0	
    --------------------------------------------------------------------------------------------------------------
    213 player province	102	 33	 13	 19	  7	  5	 11	  5	  6	 12	  0
    223 japan province	105	 49	 23	 13	  5	  6	  5	  5	  5	  7	  0
    			-----	-----	-----	-----	-----	-----	-----	-----	-----	-----	-----
    436 total province	207	 82	 36	 32	 12	 11	 16	 10	 11	 19	  0
    --------------------------------------------------------------------------------------------------------------
    			-----	-----	-----	-----	-----	-----	-----	-----	-----	-----	-----
    820 grand total		385	163	 77	 49	 24	 24	 32	 23	 18	 25	  0
    I don't know what to think now. I think there were not enough events to make this significant, at least after 2000 months. Maybe, just maybe, there is a good reason random events are 2000/5000 months.

    I might give it another try with 100 duplicates next time I need to run a handsoff game. I'll keep the focus on 1000-8000 months.

  14. #14
    It seems I am only talking to myself. Well maybe one day someone will say "Hey, wasn't there a thread with MTTH statistics?"

    It's a bit amazing what you can get the script engine to do. My biggest problem in the previous test was counting the number of times each event triggers. That is why I limited the test to 10 duplicates for each test case. I thought of a way of counting the events so I was able to do a test with more duplicates.

    I created a dummy country for each test case, and made the event put 1 ducat in the appropriate dummy country treasury. It was a simple matter to extract the treasury amount of each dummy countries after running for a 100 years. Now if there was a way to set a country's treasury to 0 by event, this technique could actually be usefull for generic modding.

    100 events for each test case, ran the game 100 years. In country events, the trigger is true for all lucky countries (8 countries). In province events, the trigger is true for the Japanese capital and its neighboring provinces (7 provinces). Incidently, it is very difficult to make an efficient province event even when you know exactly which provinces you want to target.

    This test confirms two things:
    - the country and provinces events follow the same rules for MTTH,
    - above 2000 months, there is very little difference in the effective mean time.

    Code:
    		m=100	m=200	m=500	m=1000	m=2000	m=4000	m=5000	m=8000	m=10000	m=400k	m=800k Total
    --------------------------------------------------------------------------------------------------------------
    country		 7189	 3557	 1771	  900	  457	  414	  517	  481	  435	  439 	   0	16160
    province	 6255	 3121	 1597	  725	  401	  389	  389	  360	  409	  396	   0	14042
    --------------------------------------------------------------------------------------------------------------
    grand total	13444	 6678	 3368	 1625	  858	  783	  906	  841	  844	  835	   0	30202
    The same thing, using percentages of total events.

    Code:
    		m=100	m=200	m=500	m=1000	m=2000	m=4000	m=5000	m=8000	m=10000	m=400k	m=800k Total
    --------------------------------------------------------------------------------------------------------------
    country		44.49	22.01	10.96	 5.57	 2.83	 2.56	 3.20	 2.98	 2.69	 2.72	 0.0	100%
    province	44.54	22.23	11.37	 5.16	 2.86	 2.77	 2.77	 2.56	 2.91	 2.82	 0.0
    --------------------------------------------------------------------------------------------------------------
    grand total	44.51	22.11	11.15	 5.38	 2.84	 2.59	 3.00	 2.78	 2.79	 2.76	 0.0	100%
    I have one last test I want to do before I put this matter to rest. Using a single mtth modifier, I'll give the same frequency to each test case to see if there are limits to MTTH modifiers.

  15. #15
    MM Dev Team
    EU3 Collectors Edition OwnerNapoleonic MarshalDeus Vult!Hearts of Iron 2: ArmageddonEuropa Universalis III: In Nomine
    Heir to the ThroneMount & Blade: WarbandSword of the StarsDarkest Hour

    Join Date
    Dec 2000
    Location
    Lisbon
    Posts
    18,694
    This is interesting stuff!

    Even if my observations regarding performance are not the same as yours, this MTTH cut at 2000 months is a very important info.

    A test you might want to do is to convert months to years and to days and check if the results are similar...
    == MAGNA MUNDI ==

    PAY GOLD,
    SHED BLOOD,
    INSTILL FEAR,
    PROMISE HOPE


    HISTORY IS YOURS!

  16. #16
    Quote Originally Posted by JaxomCA
    It seems I am only talking to myself. Well maybe one day someone will say "Hey, wasn't there a thread with MTTH statistics?"
    Sorry, I thought the OCD-ness of the testing regimen was reward enough.

    Really, this is great stuff. My own tentative conclusion after watching my long-term events fire too quickly was that the actual upper limit for any event was 2400 months. I think that either Paradox didn't extend the number of digits far enough when calculating mean times, or that there's a rounding error in their code for fractions below a certain size.

    In any event, it's nice to see that your empirical tests confirm my own wild-assed guess. Can you do a test between 2000 and 5000 to narrow down the gap further? Perhaps the upper limit is 3600 months rather than 2000 or 2400 months, especially if this is being plotted on a Bell curve rather than a simplistic 'divide by X' scheme.

    Edit: err, I mean half a Bell curve. The other half wouldn't actually be of much use.

    Max
    .
    Ponglish (Paradox-approved English): mistaking an apple tree for the word "penalty" - and insisting that Webster is an irrelevent authority on the matter.

  17. #17
    General The Arch Mede's Avatar
    EU3 OwnerEuropa Universalis: Rome (Collectors Edition)EU3 CompleteRome GoldVictoria 2
    EU3: ChroniclesVictoria II: A House Divided

    Join Date
    Jun 2004
    Location
    In a Turkish Bath
    Posts
    2,015
    If you need a MTTH significantly above the cutoff point you can play games with flags to get that effect.

    event a sets flag
    event b clears flag
    event c has trigger on the flag

    fiddle the mtth of a and b so that the flag is set an appropriately small fraction of the time, which will divide the effective mtth of c by that fraction.

  18. #18
    Sort of kind of back dharper's Avatar
    EU3 Collectors Edition OwnerNapoleonic MarshalEuropa Universalis: RomeVictoria: RevolutionsEuropa Universalis III: In Nomine
    EU3 CompleteRome: Vae VictisHearts of Iron IIISupreme Ruler 2020 GoldFor The Glory
    Heir to the ThroneSemper FiVictoria 2Divine WindCrusader Kings II
    Pride of NationsFor the MotherlandVictoria II: A House Divided

    Join Date
    Aug 2002
    Location
    Province #989 (EU3)
    Posts
    12,467
    Quote Originally Posted by maxpublic
    Really, this is great stuff.
    Agreed. This is really helpful for modders to know. Well, really enlightening, anyway.

    In any event, it's nice to see that your empirical tests confirm my own wild-assed guess. Can you do a test between 2000 and 5000 to narrow down the gap further? Perhaps the upper limit is 3600 months rather than 2000 or 2400 months, especially if this is being plotted on half a Bell curve rather than a simplistic 'divide by X' scheme.
    You sound like you know more math than me: perhaps this thread will answer your question. Johan posted the math that the game used (in 1.21) to convert mean time to a probability per day.

    A mod for EU3: In Nomine and EU3: Complete that enhances religion
    Religious Minorities - More Religions - Religious Fervor - New Graphics - Hundreds of Events and Decisions
    New In Nomine version released December 31, 2011 (less than a month ago)

    Still playing EU3: Complete? Get my Magna Mundi Platinum 2 bugfix for religion and the Sengoku.

    Honor of Lancaster: A Magna Mundi IV AAR (finished)




  19. #19
    100 events for each test case, ran the game 100 years. In country events, the trigger is true for all lucky countries (8 countries). In province events, the trigger is true for the Japanese capital and its neighboring provinces (7 provinces).

    Code:
    		m=100	m=200	m=500	m=1000	m=2000	m=4000	m=5000	m=8000	m=10000	Total
    		f=10.0	f=5.0	f=2.0	f=1.0	f=0.5	f=0.25	f=0.2	f=0.125	f=0.1	
    ---------------------------------------------------------------------------------------------
    country		 920	 883	 884	 918	 804	 888	 938	 902	 935	 8072
    province	 771	 807	 824	 778	 762	 804	 784	 753	 783	 7066
    ---------------------------------------------------------------------------------------------
    grand total	1691	1690	1708	1688	1562	1692	1721	1655	1718	15138
    Only 'm=2000 f=0.5' seems abnormaly low. I don't remember my statistics courses, but I'd say it is within acceptable variance for the total number of events.

    There doesn't seem to be a cutoff limit with modifiers, at least between 0.1 and 10.0.

    Maxpublic: OCD? No idea what that means. To get meaningful results for values between 2000 and 5000 months, I would have to use a thousand events over a thousand years. I have much time to waste, but not that much.

    Thank you DHarper for finding that thread. I knew I had read about that but I couldn't find it anywhere. Let's copy Johan's post here:

    MeanTimeToHappen = the value given after modifiers..
    noOfDays = basically, how many days are between checks.. (currently 1)

    Code:
    float daylyChance = float(1.0f - exp( log(0.5f) / MeanTimeToHappen ));
    float chance = float(1 - exp( noOfDays * log(1 - daylyChance)) );
    return chance; //0-1% chance of event happening that day
    __________________

    Johan Andersson
    Wizard
    This is not clearly stated here, but for this to work, 'days=', 'months=' and 'years=' have to be converted to a common base, most likely a number of days. Given this formula and the test results, I will go on a limb and say that the variable used to calculate 'MeanTimeToHappen' is an unsigned 16 bits integer, giving a cutoff of 65536 days or a bit under 2200 months.

    It is probably more complicated than a simple overflow, since we would see strange but varying results for values above 2000 months. Still, I'll make that my current theory and move on.

    Wait! I have a sudden doubt. What if the 'f' in '1.0f' comes from the factors regardless of them being used or not? That would throw off the results somewhat.

    Code:
    	mean_time_to_happen = {
    		months = XXXX
    
    		modifier = {
    			factor = y.y
    			has_country_flag = testmod
    		}
    	}
    All my events have that MTTH structure, replacing xxxx by the number of months and y.y by the correct factor to give a net value of 1000. In the first run, 'testmod' was not set for any countries/provinces. In the second run, it was set for all countries/provinces.

    Sigh, I guess I have one more round of tests to do. I think I can sefaly skip the province_events to make the game run faster.



    Ah, a small story about my hypothetical person who asked about this thread.

    random person 1: "Hey, wasn't there a thread about MTTH statistics somewhere?"

    random person 2: "Yes there was, but all of that is meaningless now since the whole system has changed. Ever since Dr. W. Rosenberg published her unified theory of the universe, it is well known that any event which can happen DOES happen in an infinite number of parallel universes. A quick study of the 'Star Trek' documentaries reveals that people of that era didn't know how to insulate themselves from the PASTAE (parallel artefacts spontaneous transference after-effects), thus negating any studies about random events."

    random person 1: "Oh, well it was worth a shot."
    Last edited by JaxomCA; 18-06-2007 at 18:19.

  20. #20
    Six-star scriptmaster
    EU3 OwnerNapoleonic MarshalDeus Vult!Europa Universalis III: In Nomine

    Join Date
    Mar 2003
    Location
    Betanzos, A Coruña, España
    Posts
    3,317
    Quote Originally Posted by dharper
    Agreed. This is really helpful for modders to know. Well, really enlightening, anyway.

    You sound like you know more math than me: perhaps this thread will answer your question. Johan posted the math that the game used (in 1.21) to convert mean time to a probability per day.
    Thank you by the link.
    Finally I thought correct. I always called to MTTH: Medium time to happen.


    JaxomCA. Can you test if 0.5 years is a valid MTTH and how it affect to the speed? Please
    MIEMBRO DEL MagnaMundi TEAM.
    Descargate la ultima version de MMP aqui
    Visita nuestro foro en Terranova.dk o nuestro sub-foro en los foros Paradox

    EU3+NA+IN+MagnaMundi Platinum+VariProject
    Traducciones de los archivos de comandos para eventos y pequeña guia

    EU2: parche 1.09 + WATK 1.3
    El bAAR del duque , mi AAR del EU2 con Lorena

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Posting Permissions

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