-
Notifications
You must be signed in to change notification settings - Fork 5
*Donjon* / *Sorcerer* mechanic #248
Description
The mechanic
Two sides each roll a pool of dice and sort them highest to lowest. Starting from the top, set aside ties until a non-matching pair is found. The side with the higher die in that pair wins, scoring one success for each of their dice (including the set-aside high-ties) that are greater than the losing die in that pair.
Other efforts to compute probability
Possible APIs
If iterating in the favorable direction (descending in the above case), we could make this an expression where we emit elements until we find an unpaired element, then keep emitting until we find the corresponding paired element. However, the expression doesn't know who wins until later, so we would still have to separately specify the winner. So the solution in this case would look like
@multiset_function
def example(a, b):
return a.donjon(b).size(), a.leximax('>', b)Could this be done using existing components?
@multiset_function
def donjon(a, b):
return a.versus_all('>', b - a).size(), b.versus_all('>', a - b).size()doesn't quite work, since the highest losing die could be erroneously deleted by a winning die down the line.
Variations
- Emit from pairs meeting a comparison, until the first time another comparison is met.
- Same, but starting from the first time another comparison is met.
- Annoyingly we may need to specify whether this is inclusive of the triggering pair. So we might not want to jam them all into the same method.
- What should be the default behavior with extra elements?
- Separate expression / evaluator type with a
next_statethat takes pairs etc.?- Unfortunately I don't think this works from an efficiency perspective: if one side appears much later than the other, the earlier side is going to pile up an
expand()-sized amount of state. The comparators are efficient because they only need to know that one side appeared earlier or later without knowing the exact value of the other side. - What if we only emitted
cmpfor each pair?
- Unfortunately I don't think this works from an efficiency perspective: if one side appears much later than the other, the earlier side is going to pile up an
- A version of
sort_pairthat accepts and/or returns a 2-tuple? I'm not sure how I feel about more tuples outside ofmultiset_function.