What I'm looking for is this: pools A and B roll Xd6 and Yd6, respectively. The result is determined as follows:

  1. The highest roll among all dice is rh, and the pool it comes from is Ph.

  2. The other pool is Pt, and the highest roll from that pool is rt.

  3. The magnitude of the result, R, is equal to the number of rolls in Ph that are higher than rt.

  4. If Ph is A, the result is +R. If Ph is B, the result is -R. (If rh = rt, the result is a tie.)


[6 6 5] vs [1 2] -> winner is A, with R = +3
[4 4 3] vs [6 6] -> winner is B, with R = -2
[4 4] vs [4 4 2] -> tie, R = 0
  • \$\begingroup\$ Just to be 100% sure, that case you just removed would have been a tie, yes? \$\endgroup\$
    – nitsua60
    Nov 28, 2021 at 21:10

1 Answer 1


If I'm reading your question correctly (which is not guaranteed: I've read through it a half-dozen times, and I'm still not 100% sure I've got it, but maybe that's what afternoon naps on snowy days do...), then the solution-function is almost the same as Ilmari's answer from the linked post. The only change is what to do in case of a tie. (Nothing special!)

function: A:s vs B:s {
  result: (A > 1@B) - (B > 1@A)

Recall that a group of dice stored as a sequence (A:s) automatically sorts high-to-low and elements are @-accessed, so 1@A outputs the first (i.e. highest) roll of group A. The comparison operator acting on a sequence vs. a number will generate a truth-count as its output, so A>1@B produces "the number of rolls in A greater than the highest of B". And in the case of a tie, we know (by construction) that A>1@B and B>1@A will both be zero, so we get the result you want =)

Function defined, if you want to see it in action a simple call like

output [6d6 vs 4d6] named "6 vs 4"


loop X over {3..6} {
  output [Xd6 vs 4d6] named "[X]d6 vs 4d6" 

will do the trick. It's pretty time-intensive, though, so you may end up running lots of "combats" individually.

I will be donating all rep from this answer to a post of Ilmari's choice or, absent such a choice, to a post of Ilmari's that I choose (via bounty). Because this code is basically just theirs, with one tweak to fit your tie-condition.


You must log in to answer this question.

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