So I've done some experimenting with game saves and I think I've reverse-engineered the post-1.10-patch Gavelkind algorithm. At least almost entirely, and most importantly it's developed to the point where I can legitimately plan my successions. So I thought I'd share. The current beta/upcoming patch only makes one little change which I'll also address.
Please keep in mind I'm not reading code, I'm looking at game results and trying to decipher the algorithm that produced it, so it's really easy to mix up causation with correlation. Plus what I describe below is explaining about 95% of what I see in succession results but not all of it so I know I'm missing something. So don't gripe if this algorithm doesn't always predict every detail of every succession. It's very close though; the only place it sometimes misses the mark is when it comes to who gets what independent counties. I'll try to be clear distinguishing what I know from what I suspect. Along the way I'll note where I think the algorithm could use some improvement. Also:
***TL; DR below***
Here's roughly how it works, if you want the details:
* Greater (non-holding) titles - Emperor, King, and Duke - are distributed first. They appear to be distributed by title class (empires then kingships then duchies) and in inheritance order starting with the primary title. So if you have two sons and your only greater titles are the King of England and the Duke of Jorvik, your first son will be a King with no duchies, and the second will be Duke of Jorvik.
This distribution mechanism has been a bit problematic so far. The titles of Emperor and King do not come with land - at least, not until the current beta patch, which I'll address shortly - but Duchy titles also come with all the lesser titles owned within their borders. The best duchies typically contain the best counties and all their holdings, especially in the early game, and we've been seeing those prime properties (usually including the Capital) commonly passed on to pretender-level heirs instead of the primary heir.
* Within each class I believe they are distributed in order of maximum combined possible holdings. For instance: The Duchy of Mercia has four counties, each with 4 maximum holdings, for a total of 16. The Duchy of Lancaster has four counties, three with 4 max holdings and one with 3, for a total of 15. Thus if upon death you own those two duchies and their counties and have two sons, the eldest would inherit Mercia and its counties and the youngest would inherit Lancaster and its counties.
There are three exceptions. First, for each kingdom, the de jure capital county and its associated duchy title (if it exists) will be handed down to its inheriting king. Any non-capital counties owned within the de jure duchy will NOT be given to the inheriting King at this point - they will be distributed as independent counties later in the process.
Second, as of the beta patch the county containing the actual capital you hold will also be set aside for the primary heir if it isn't the de jure capital. Please note the primary heir WILL NOT get the duchy title associated with the actual capital, if it exists and isn't the duchy title of the de jure capital already given to the heir. Once this happens, then all your remaining duchies will be handed out in order of max holdings, and then independent counties will be distributed.
Third, if you are a king and have a secondary heir who is already a Duke vassal in your kingdom, that vassal duchy will be treated the same as an inherited duchy by the algorithm. Meaning, that heir will not get another duchy via inheritance until every other heir gets one and the line for a second wraps back around to his inheritance position.
Also note: the algorithm appears to use the combined max holdings of all a duchy's de jure counties even when you do not actually own all the counties in a duchy. For instance, in the above example imagine you held only three of four counties in Mercia instead of all four. Your first heir would still get the Duchy of Mercia and those three counties while the second gets all four counties of Lancaster, even though the max number of holdings being passed along is now 12 and 15, respectively. I think they'd get more balanced results by using "max holdings of counties owned in duchy" instead of "max holdings in each de jure duchy", or better yet the sum of the two, since both seem appropriate measures of property value but in different and complementary ways.
* Once all the heirs have one greater title each, the inheritance order wraps. The primary heir gets the next title, the second heir gets the next one, etc., until all the greater titles are given out.
* Independent county-level ("lesser") titles are handed out next, and they're handed out quite differently.
First, they're only handed out to the primary heir and all the secondary heirs who do not own or inherit duchies, with one exception we'll look into shortly. Please note: own or inherit. Meaning, if you are a king and have a secondary heir who is already a Duke vassal in your kingdom, he is not any more eligible to inherit independent counties than heirs who inherit their duchies. Thus if you want to guide your succession in a way the algorithm doesn't favor, you can do so by granting duke titles before death; you can rest assured that if the recipients aren't your primary heir they won't get much (often none) of the remaining inheritance.
Once the algorithm determines who is eligible, it goes through a set list of counties (always in the same order, organized by duchy, which themselves are ordered geographically - in England, roughly NE to SW) and hands the counties out, one by one, to the qualified heir with the lowest value of independent counties already inherited, ties going to the oldest. In this case, the value of independent counties is not compared strictly by max number of holdings; that's not a granular-enough metric to compare individual counties. I believe the algorithm uses the total tax value of each province or something very strongly correlated with it. It keeps a running tally, and as each county comes up on the list to be given out, the algorithm gives it to the heir with the lowest total tax value accumulated so far. Kings start with the value of their de jure capital as part of their tally.
This is complex, I know. So here's an example to chew on:
Let's say you are the King of England, you have four sons, the Duchies of Essex, Mercia and Lancaster and all their counties, plus the three counties of Northumberland for which no duchy has been created (Northumberland, Dunham, and Cumberland). Your capital is in the county of Lancaster even though the de jure capital is in Middlesex (in Essex, so you own that too). In addition you're running the new Beta patch. And you die. Here's what should happen:
The first son gets the Kingdom of England.
The Duchy of Essex title, plus the de jure and actual capital counties of Middlesex and Lancaster, respectively, are now given to the first son as inheriting King. The remaining three Essex counties will be handed out as if they were independent and the primary heir will be in the mix for those as well.
The second son gets the Duchy of Mercia (16 max holdings).
The third son gets the Duchy of Lancaster, minus the capital of Lancaster (15 max holdings de jure).
The six independent counties - three from Essex, three from Northumberland - will now be split between the primary heir and the duchy-less fourth son. The set order for those six counties to be given out is Northumberland - Dunham - Cumberland - Bedford - Essex - Northampton.
The King starts with the tax value of Middlesex in his tally. So the algorithm gives the first county, Northumberland, to the youngest since the youngest has the smallest tally to start out. Still, Northumberland isn't as valuable as Middlesex so the youngest also gets the next county (Dunham). Now the youngest has a higher property value tally so Cumberland goes to the eldest. The rest go in alternate order.
So the new King will also get Cumberland and Essex to go with Middlesex, Lancaster, his kingship and his duchy title. The youngest will get Northumberland, Dunham, Bedford, and Northampton.
See? That was EASY. Pffffft.
* The only exception to this process can be caused by a rule that applies to kings (perhaps emperors?): whoever inherits a kingship will not be qualified to inherit independent counties outside their de jure territory. This rule also appears to be the binding one when it comes into conflict with the "if your secondary heir gets a duchy, he gets no independent counties" rule.
The way the game handles this is by processing the independent counties in groups, sorted by de jure kingship, primary kingship first. And inheriting Kings are removed from the list of eligible heirs when the groups outside their kingdom are processed.
For example: imagine the King of England has two sons and holds one duchy in Essex, with all its four counties including the capital in Middlesex, plus the Duchy of Mercia and its four counties, plus six more English counties, and the three counties of Lothian in Scotland (but no duchy).
When he dies:
The first son gets the Kingship plus the duchy of Essex plus the county of Middlesex (the actual and de jure capital and its associated duchy).
The second son receives the Duchy of Mercia and its four counties.
Since the only eligible heir of the remaining 9 English counties (three from Essex, six independent) is the King since the second son got a duchy, the King gets all nine.
Then the three independent counties from Scotland are processed. Since the King of England cannot inherit these counties all three must go to the second son even though he already has a duchy.
So in the end the King gets the Kingdom, the Duchy of Essex and its counties, plus the six English independents. The second son gets the Duchy of Mercia and the three Scottish counties.
One more twist: what happens if before death the King creates the Duchy of Lothian? As opposed to independent counties, duchies are NOT given out with preference to kingdom and thus kings ARE allowed to inherit duchies from outside their kingdom; that restriction is ONLY for independent counties (why? beats me). Since the Duchy of Lothian ranks lower than Mercia in the number of max holdings, it would go after Mercia - i.e., to the King, since there's more duchies than inheritors and the duchy handout process jumps back up to the primary heir when it reaches the end of the eligible heir list.
(EDIT: there used to be a lot more written here...but it has been fixed with the beta patch, so nevermind)
- With the new beta patch, the King inheritor will always get the capital county, plus the de jure capital and its duchy, if you own them.
- If you have as many duchies as eligible heirs, each son will end up with a duchy and its counties. The primary heir will get the kingship if you own it and the independent counties. If the primary heir is also an inheritor king, he only gets independent counties within the kingdom, and independent counties outside the kingdom will be distributed among the other heirs.
- If you have more duchies than heirs, same as above, and the extra duchies will be given out roughly in inheritance order.
- If you have fewer duchies than heirs, things get more complicated. Independent counties within the kingdom will be divided between the primary heir and any secondary heirs that both (a) did not inherit duchies and (b) did not already own duchies as vassals of the deceased King. Independent counties from outside the kingdom will be split only among the secondary heirs that have no duchies.
- If you have heirs who are already landed Dukes and your vassals, they will not get anything from your inheritance (except possibly under the foreign independent county exception, see details above). So if you want to limit a bad son to one crappy duchy and the succession process won't give the right duchy to him, you can grant the title to him directly before you die and he usually won't get anything else.
- Among the eligible inheritors of independent counties, the system will try to distribute those counties evenly and according to total tax value (or something very similar).
- If you want to keep not only your non-de-jure capital but also its duchy and its counties, you're still probably best off not incorporating the duchy title of your capital until after succession, even with the new beta patch.
- If you want to know how any of this works in more detail, read above. Leave questions and feedback below and I'll respond periodically.