What goes at the top of the list for what to play with a KC/TR? Wait, I know the answer to that, it's King's Court. Followed by Throne Room.
But what comes next? Followers? Familiar? Grand Market? In other words, if you have the choice of playing any action card with a King's Court, how would you decide? (Checking for things like whether there are curses left makes sense, of course.)
+1 for the problems with TR. Despite this you often also want TR>KC, as TR->KC is 2x3 vs 3x2 for KC->TR. When you only have 5 hands and no at least +2 better +3 cards in hand, it's very likely that you don't get 3 actions on hand for playing with KC->TR.
And also for KC only it's very dependend on the rest. Often after KC->KC, highest priority has the Smithy(+), for finding more KCs and more actions. Of course that's not true when playing KC->? without more actions left.
So for some very pseudo Pseudocode
// Here stood some TR, which was not really correct. Ignore TRs for the moment.
KC
If (actionsLeft or (more KCs open) ) and (I want to draw more cards*) Smithies.
If (needmoreActions**) Cantrips*** > Villages > whatevergivesActions
else defaultActionPriorities
*,**,*** of course being the hard part. And that's still not how you would really play it.
*: Check if there's something left to draw at all, and what's left in your piles.
**: If there's something in your hand that you still want to play but there is no KC's left, or if it's very likely that you would draw something of it if the action also draws
***: Including Conspirator, even when it's not (yet) activated.
That would be a first try, that would play a lot cards and probably generated a lot coins, one now still must care for getting enough buys for all these coins, probably by getting +buys a higher prio in the default list if there is much money avaiable, which would be reasonable anyway.
But I'm not sure if I would like to code something like that...