2
\$\begingroup\$

I am trying to determine the math for beating a DC with the sum of two sufficient dices of a pool of three to five polyhedral dice. The challenging part is that you try to maximise the sum of the dice you did not pick.

For example on a DC of 12, you roll a d12, 2d8 and a d6 for 8,6,6 and 4. You can beat the DC with 8+6 or 6+6 but only the latter would maximise the sum of the remaining dice.

Sadly this surpasses my skill using anydice by far.

\$\endgroup\$
5
  • \$\begingroup\$ 6 + 4 doesn't meet the DC, do you mean to have a DC of 10? \$\endgroup\$ Commented Oct 29 at 3:40
  • \$\begingroup\$ @HighDiceRoller I think they are trying to maximise the value of dice left over. Voting to close until they clarify. \$\endgroup\$
    – Dale M
    Commented Oct 29 at 4:57
  • \$\begingroup\$ @HighDiceRoller I think that they mean that for just maximizing the sum of the remaining dice you should choose 4 and 6, but these do not overcome the DC of 12. \$\endgroup\$
    – Eddymage
    Commented Oct 29 at 6:11
  • \$\begingroup\$ Sorry for beeing unclear - the assumption by Dale M and eddymage was correct, I edited it for clarity's sake. \$\endgroup\$
    – Em Harung
    Commented Oct 29 at 9:41
  • \$\begingroup\$ @HighDiceRoller Thanks! \$\endgroup\$
    – Em Harung
    Commented Oct 29 at 9:53

1 Answer 1

1
\$\begingroup\$

AnyDice

To choose the best numbers to reach the DC, we can use an exhaustive search. There are only ten ways to choose two of five dice, which is pretty manageable by itself.

function: remaining A:n and B:n and C:n and D:n and E:n vs DC:n {
 ROLLS: {A, B, C, D, E}
 RESULT: -1
 loop I over {1..5} {
  loop J over {I+1..5} {
   if I@ROLLS & J@ROLLS & {I,J}@ROLLS >= DC {
    RESULT: [highest of RESULT and ROLLS - {I,J}@ROLLS]
   }
  }
 }
 result: RESULT
}

output [remaining d12 and d8 and d8 and d6 and 0 vs 10]

AnyDice link.

Here we loop over all possible choices of two dice to use to reach the DC, and pick the one that has the highest sum of remaining dice. We use arguments of zero to represent rolling fewer than five dice, and exclude using them to reach the DC. (I interpret your question as meaning you must choose exactly two dice to use to reach the DC, even if just one would have been sufficient.) ROLLS - {I,J}@ROLLS implicitly sums ROLLS and the two selected dice before finding the difference.

Icepool

Unfortunately, while AnyDice is capable of efficiently expanding pools of one type of die into sorted sequences, it can't store mixed pools in variables (which is why we used a separate parameter for each die), nor efficiently expand them. As such, if you use the 5th die it's likely it will time out. My Icepool Python probability package can efficiently expand mixed pools from a single variable:

from icepool import d, map_function, Pool
from itertools import combinations

@map_function
def remaining(rolls, dc):
    used = [sum(t) for t in combinations(rolls, 2)]
    return max((sum(rolls) - x for x in used if x >= dc), default=-1)

pool = Pool([d(12), d(8), d(8), d(6)])

output(remaining(pool, 10))

Here we use itertools.combinations to pick two of the numbers but not the same die twice. Then the next line picks the optimal sum. Finally, the map_function decorator causes the function to run over all possible multisets of numbers that could come out of the pool, similar to how AnyDice expands pools to sequences.

You can try this in your browser here.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .