I've coded up an incomplete simulation of your rule set in Python. From my strategy, it looks like about an eighty percent chance of buying the Priest card with seven dice. I've tested the code on TiO so you can run it without installing Python locally.
Here's an example of the debug output:
Reqs: [Sword_4, Sword_1, Political, Castle]
Rolls: [Wizard, Sword_1, Sword_3, Sword_1, Castle, Wizard, Sword_1]
Matched: Castle
4 matched by 3, 1
Sword_1 Matched exactly
No matches with: [Wizard, Sword_1, Wizard, Sword_1], still need [Political]
Rerolling 4
Reqs: [Political]
Rolls: [Castle, Wizard, Sword_3, Castle]
Current Matches: [Castle, Sword_3, Sword_1, Sword_1]
No matches with: [Castle, Wizard, Sword_3, Castle], still need [Political]
Rerolling 3
Reqs: [Political]
Rolls: [Sword_2, Sword_1, Sword_3]
Current Matches: [Castle, Sword_3, Sword_1, Sword_1]
No matches with: [Sword_2, Sword_1, Sword_3], still need [Political]
Rerolling 1
Reqs: [Political]
Rolls: [Sword_3]
Current Matches: [Castle, Sword_3, Sword_1, Sword_1]
No matches with: [Sword_3], still need [Political]
Rerolling -2
Failed to acquire Priest remaining:
Chance to buy card Priest is about 78.39% after 10000 iterations
Here's a successful attempt:
Reqs: [Sword_4, Sword_1, Political, Castle]
Rolls: [Castle, Sword_1, Sword_1, Wizard, Sword_1, Sword_1, Sword_3]
Matched: Castle
4 matched by 3, 1
Sword_1 Matched exactly
No matches with: [Sword_1, Wizard, Sword_1, Sword_1], still need [Political]
Rerolling 4
Reqs: [Political]
Rolls: [Political, Sword_2, Castle, Sword_1]
Current Matches: [Castle, Sword_3, Sword_1, Sword_1]
Matched: Political
Unneeded: [Sword_2, Castle, Sword_1]
Successfully acquired Priest
You can define new cards by modifying the line:
priest = card("Priest", dice.Sword_4, dice.Sword_1, dice.Political, dice.Castle)
Apologies for the verbosity, I was making sure that the strategy was working properly.
One example where my implementation falls short is failing to match a Sword 4 with a Sword 2 and two Sword 1s. That it relatively trivial to add, but it's probably something you'd choose if the Sword 4 was your only remaining requirement.
Actually, I just reviewed your rules and I've implemented the penalties wrong. I've just given the first re-roll free and added an increasing penalty for each subsequent round. It is relatively simple to track the matches within a round and apply penalties then, I suspect it'll make things easier to recruit the Priest.
Let me know if this approach is interesting or useful and I'll fix it up or feel free to give it a go yourself.
Edit: Okay, it was gnawing at me so I fixed the implementation here.
As suspected the chance to acquire a Priest increases, to about eighty-five percent. Here's a new log showing an example including rerolls:
Reqs: [Sword_4, Sword_1, Political, Castle]
Rolls: [Sword_1, Sword_1, Wizard, Sword_1, Wizard, Sword_2, Wizard]
Sword_1 Matched exactly
No matches with: [Sword_1, Sword_1, Wizard, Sword_1, Wizard, Sword_2, Wizard], still need [Sword_4, Political, Castle]
Rerolling 7
Reqs: [Sword_4, Political, Castle]
Rolls: [Castle, Castle, Wizard, Sword_2, Castle, Sword_2, Sword_1]
Current Matches: [Sword_1]
Matched: Castle
4 matched by 2, 2
No matches with: [Castle, Wizard, Castle, Sword_1], still need [Political]
Rerolling 4
Reqs: [Political]
Rolls: [Sword_3, Sword_1, Sword_1, Sword_2]
Current Matches: [Sword_1, Castle, Sword_2, Sword_2]
No matches with: [Sword_3, Sword_1, Sword_1, Sword_2], still need [Political]
Rerolling 3
Reqs: [Political]
Rolls: [Sword_2, Sword_3, Political]
Current Matches: [Sword_1, Castle, Sword_2, Sword_2]
Matched: Political
Unneeded: [Sword_2, Sword_3]
Successfully acquired Priest
Unfortunately this shows another problem, I wasn't removing the sword dice from the pool when it matched exactly. Also I wasn't allowing two Sword 3s to fulfil a Sword 4 requirement. A quick fix here which gets us back around to an eighty-one percent chance to acquire the Priest.
Here's a failed acquisition attempt which looks correct:
Reqs: [Sword_4, Sword_1, Political, Castle]
Rolls: [Wizard, Sword_1, Sword_1, Sword_1, Sword_2, Political, Wizard]
Matched: Political
Sword_1 Matched exactly
No more matches with: [Wizard, Sword_1, Sword_1, Sword_2, Wizard], still need [Sword_4, Castle]
Rerolling 5
Reqs: [Sword_4, Castle]
Rolls: [Sword_1, Wizard, Sword_1, Castle, Wizard]
Current Matches: [Political, Sword_1]
Matched: Castle
No more matches with: [Sword_1, Wizard, Sword_1, Wizard], still need [Sword_4]
Rerolling 4
Reqs: [Sword_4]
Rolls: [Sword_1, Political, Sword_1, Political]
Current Matches: [Political, Sword_1, Castle]
No more matches with: [Sword_1, Political, Sword_1, Political], still need [Sword_4]
Rerolling 3
Reqs: [Sword_4]
Rolls: [Political, Political, Sword_3]
Current Matches: [Political, Sword_1, Castle]
No more matches with: [Political, Political, Sword_3], still need [Sword_4]
Rerolling 2
Reqs: [Sword_4]
Rolls: [Sword_3, Castle]
Current Matches: [Political, Sword_1, Castle]
No more matches with: [Sword_3, Castle], still need [Sword_4]
Rerolling 1
Reqs: [Sword_4]
Rolls: [Sword_3]
Current Matches: [Political, Sword_1, Castle]
No more matches with: [Sword_3], still need [Sword_4]
Rerolling 0
Failed to acquire Priest remaining:
Although it does show that perhaps I should have included the 2,1,1 match for Sword 4.
Last Edit:
Okay I've made some modifications and now the code supports arbitrary Sword requirements up to twelve. It was a little finicky to get working correctly and my generic sword matching algorithm isn't quite as good as the manual implementation - 36.5% compared to 40% for 3 Sword_4 requirements. One failure of my generic algorithm is that it will match four 1 Swords to a 4 Swords requirement, even if there are additional Sword requirements. I doubt that's the entire cause of the discrepancy.
In any case the code is available here.
The chance to acquire a card with a requirement of 12 Swords is about 11.5% when rolling seven dice.