Well wagon I've been testing it, so I landed my two children (1 daughter and one son) to see what they would do if I gave them the freedom to marry (testing it to the limit I guess). Surprising the first issue came from my son's branch of the family. He died as a young adult and only had one daughter, who inherited his county, and thus she became my new heir. I allowed her to make her own decisions on marriage, and she promptly betrothed herself for a regular-marriage with the son of an opposing duke. 
I'm afraid that the AI still values alliances and marriage status (even weak ones) more than continuing the dynasty, which is something that is probably beyond the reach of modders to fix, and is going to continue to be a problem so long as the devs think that it isn't important that the AI continues its dynasty.
I'll give a try to the one mediocre doctor posted above to see if there is any difference, but I appreciate all the work.
EDIT: I will add that I was using the one that monkbel put into a downloadable mod, so if his code is different from yours somehow maybe that is why I had issues.
I'm afraid that the AI still values alliances and marriage status (even weak ones) more than continuing the dynasty, which is something that is probably beyond the reach of modders to fix, and is going to continue to be a problem so long as the devs think that it isn't important that the AI continues its dynasty.
I'll give a try to the one mediocre doctor posted above to see if there is any difference, but I appreciate all the work.
EDIT: I will add that I was using the one that monkbel put into a downloadable mod, so if his code is different from yours somehow maybe that is why I had issues.
Last edited: