1. Gavelkind: EXPLAINED! (mostly)

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)

***TL; DR***

• 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.

2. Thanks for the research on this matter. Gavelkind seemed to have been improved.

3. It gets really annoying when you hold multiple kingdoms (without an empire title) and have 3 or more heirs - At 2 you still keep the kingdoms, but at 3 onward they break away from you. Probably the biggest worry of your typical Norse conqueror pre-reformation (and change from Gavelkind*)

4. Tried to limit my viable heirs to 1, didn't quite work out as planned.

If you disinherit a son by granting them a temple holding, if the disinherited son dies prematurely his sons will also inherit with their uncle who is the righteous heir.

Therefore I ended up from 6/6
Duchy of Greater Poland (all counties, 4)
Krakow
Kiev

To
My nephew: Duchy of greater Poland all 4 counties
Me: Krakow, Kiev

Guess I wanted to know if I eliminate this problem and my one heir son happens to die... Let's say we have a situation where I only have daughters and their sons, who will inherit? Daughters? Grandsons? Running the standard agnatic-cognatic gavelkind.

• 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.
You could, I assume, also use it in a more positive fashion though. For instance roleplaying purposes, your current ruler has a brilliant younger, who also is his favourite, then you might grant him a better duchy than he would have got otherwise.

There even is one historic precedent I know of. (Valois) King John the Good of France gave the prestigious (as in old and not a more recent elevation) duchy of Burgundy to his youngest and favourite son Philip the Bold (in exchange he did have to give up the appanage he had at the time, Touraine), who had fought bravely and stayed with his father at the French defeat at Poitiers by the English.

Still France used an agnatic primogeniture succession, but they did have the practice to give appanages to younger sons. (Rarely regular titles, though they could gain these by inheritance.) Maybe in game the game concept of appanage could be added, though it would have to be discovered first and would only be really suited for the second half of the period covered by the game.

5. So in theory if I have say 6 sons and I am a king. All I need to do is grant each of them piece of land (duchy to each) except my heir and my problem of succession will be solved?

6. How are duchies I have no holdings in processed?

As king, I frequently find no use in owning e.g. duchy that I have all holdings in - so I create duchy that gives me direct control over 3-4 vassals instead. If I have only duchies I have no land in, how will those be processed?

7. Originally Posted by Velg
How are duchies I have no holdings in processed?

As king, I frequently find no use in owning e.g. duchy that I have all holdings in - so I create duchy that gives me direct control over 3-4 vassals instead. If I have only duchies I have no land in, how will those be processed?
Good question, I wonder that too. Either you keep them, but maybe these are distributed between all brothers to assure they keep a certain rank befitting their station?

8. Love the thread. Still say we should get a say in who gets what.

9. Originally Posted by Zireael
Love the thread. Still say we should get a say in who gets what.
Yes, though the standard outcome generated by the algorithm should still remain a starting point. That is, maybe each title should get a value attached to it; and that in terms of value, heirs should not be too much worse or better off, if the players decides or when the standard algorithm is used.

10. We should at least be able to retain our capital or try to minimise bizzare successions where counties are shifted around in bothersome ways.

11. Originally Posted by Ruwaard
Yes, though the standard outcome generated by the algorithm should still remain a starting point. That is, maybe each title should get a value attached to it; and that in terms of value, heirs should not be too much worse or better off, if the players decides or when the standard algorithm is used.
It would be as easy as the EUIII victory negotiation panel. You have 100 score and everything holding as a related value that adds to 100. Your primary heir can get X% and the rest [(100 -X%)/#heirs] each. That would be the perfect solution since I imagine back then the King decided who gets what and sometimes he was not fair about it.

12. Originally Posted by Klarum
It would be as easy as the EUIII victory negotiation panel. You have 100 score and everything holding as a related value that adds to 100. Your primary heir can get X% and the rest [(100 -X%)/#heirs] each. That would be the perfect solution since I imagine back then the King decided who gets what and sometimes he was not fair about it.
Kings in medieval times had less power than people might think, especially with the various estates all valuing and cherish their respective privileges.

Firstly I also suggest some limitation to prevent it from becoming too gamey. Secondly distinctive entities might have value the fact to have their own lord (who might be a vassal). Thirdly a king might have had a favourite, which he could have granted a slightly larger share, but even that would be within certain limits.

So like I wrote earlier, ever heir starts out with the standard value, they would receive, but the, within a certain range, deviations from this are possible. It might also be linked to the tiers of certain titles. If a king has four sons and 1 kingdom and 3 duchies, the oldest should get the kingdom and all the younger sons a duchy, unless one duchy is from the capital province.

13. Originally Posted by Zireael
Love the thread. Still say we should get a say in who gets what.
Well, I think that possibility to grant titles to children before death is a good start - at least to minimalize risk of Mercia in Essex.

14. Aerrae - Interesting. Looks like once the pie is divided between sons, when one of them dies their piece will pass along to their heirs if eligible. Haven't noticed that yet but it hasn't come up. I'll keep an eye out for similar circumstances to see if I can shed a bit more light on it.

Nithus - yes, exactly.

Velg and Ruwaard - great questions, so I went back to check. Two discoveries:

* If you hold an empty duchy - that is, you hold the duchy title but give away all the lesser titles to non-inheritor vassals - it appears that upon inheritance the empty duchy will be passed on to a son just the same as the other duchies, but if that heir gets nothing else he will be granted exactly one extra county. I can't figure out how the game is deciding which county to give away, but that's what it's doing. In other words, heirs that receive titles will *always* be granted at least one title that comes with holdings.

* If you try to give that heir a single county within his inherited duchy in advance, that won't work (what DOES work is giving away all the counties except one, so the heir gets the duchy plus one county within the duchy). I want to research this more but it appears that landholding secondary heirs will get skipped in favor of non-landholding secondary heirs when it comes time to hand out the duchies. I thought this only applied to dukes but it seems to include counts/earls too, so giving a secondary heir a single county in advance will move him all the way to the back of the duchy inheritance line (but if he doesn't end up with a duchy he will still be eligible to inherit more independent counties, unlike Duke vassals of the dead King). If that's a complete description of how it works that's definitely exploitable and should probably be patched. I'll look into this more over the next day or two.

15. Originally Posted by Ruwaard
Yes, though the standard outcome generated by the algorithm should still remain a starting point. That is, maybe each title should get a value attached to it; and that in terms of value, heirs should not be too much worse or better off, if the players decides or when the standard algorithm is used.
Agreed.

16. +1 great read. I wish there was a better in game description for Gavelkind.

17. That was fantastic, cheers Your suggestions for improvement are pretty solid too.

Originally Posted by DaggaRoosta
(a) One of the triggers is NOT the destruction of a title. Meaning, you can create a duchy and the algorithm triggers so that one son gets all that duchy's counties and no independents...then you can destroy the duchy title, and the succession tooltip won't update the distribution of counties. The second son will still get the evaporated duchy's counties, and usually no more, and you won't have to hold on to an extra duchy title to make that happen. Or you can give a son a duchy title and literally give away all but one of the counties within the duchy before you die (and even grant independence to the new owners!) but if the duchy title isn't bought away from you before death and no other triggers are hit, the tooltip will still show the duchy (with only one associated county) given to your disfavored imbecilic brat.
Unless I'm mistaken, doesn't 1.101 stop you from destroying titles under Gavelkind anyway?

18. MutantPenguin - great name btw - yes you're absolutely right, I first noticed that before the beta patch and didn't notice it had changed. I'll edit the main post momentarily.

19. I had one more thought for improvement but it's really fundamental so rather than including it in the post I'll leave it here as a comment.

A huge part of the confusion around Gavelkind is that the algorithm is supposed to divide up kingdoms equally but it doesn't always accomplish that. One big reason for that is because of the bizarre decision to hand out duchies in a completely separate process from independent counties and to virtually disallow sons with duchies from ever inheriting independent counties.

It seems to me that independent counties should be distributed generally to whomever heir has less valuable land holdings (as measured by total tax income) once the capital and duchy disbursement is complete. If that's not enough - if, let's say, the gap between the smallest landholders and largest one is still larger than two times the value of the smallest county owned by the deceased - then land should be peeled off of duchies with 3+ counties, one at a time in reverse order of which they were given, and added to the smallest inheritance until either the balancing is complete or until every duchy is stripped to the minimum counties needed to hold the duchy.

Take the last example in the main post, at the very end when the king creates the Duchy of Lothian. At that point the algorithm would give Essex, Lothian, and six independent counties to the primary heir and only the Duchy of Mercia to the second heir. That's not remotely balanced (Essex by itself is worth more than Mercia). Seems to me that the independent counties should be going to the younger son (by probably 5-1 or so) in order to balance the inheritances. And if giving all six isn't enough to balance it out, maybe Durham should also be split off of Lothian and given to the younger son.

That would be rougher for the player and create more contention between heirs, sure. And that's the point. Gavelkind isn't conducive to big peaceful kingdoms.

It also occurs to me that the development team must've thought of this and chose a different path after playtesting, so there's probably something I'm missing. But who knows.