I'm trying to get the probabilities for the following:
1:Roll xd6 vs xd6
2: The first pool is a regular pool, the second pool rerolls 1s(even on rerolls) and explodes on 6s(The exploding die does not reroll on a 1, but it can explode again)
3: Starting with the highest die in the 1st pool, check it vs the highest die in the 2nd pool If the second pool die is equal or higher, eliminate both dice.
4: Continue until there are no dice in the one of the pools, or every dice in the first pool is larger than the dice remaining in the second pool
5: Output the odds for the highest die remaining in the first pool.
Basically checking the highest single result in the 1st pool after using the 2nd pool to "cover" dice in the first pool.
I have the following function written that appears to work (When running on a local anydice interpreter).
```
function: attack ADICE:s vs DDICE:s RR:s {
ATTACK:{}
DEFENSE:{}
DROLLS: {}
RRINDEX: 0
loop N over {1..#DDICE + 25}
{
if (#DROLLS - RRINDEX + 1)@DDICE = 1
{
if #DROLLS = 0
{
DROLLS: {DROLLS, RR}
RRINDEX: RRINDEX + 1
}else{
DROLLS: {{0..(#DROLLS - 1)}@DROLLS, RR}
RRINDEX: RRINDEX + 1
}
}else{
DROLLS: {DROLLS, (#DROLLS - RRINDEX + 1)@DDICE}
}
}
loop N over {1..(#DROLLS + 25)}
{
if N@DROLLS = 6{DROLLS: {DROLLS, RR }}
}
DROLLS: [sort DROLLS]
loop N over {1..#ADICE}
{
if #DEFENSE >= #DROLLS {ATTACK: {ATTACK, N@ADICE}}
else
{
if N@ADICE > (#DEFENSE + 1)@DROLLS {ATTACK: {ATTACK, N@ADICE}}
if N@ADICE <= (#DEFENSE + 1)@DROLLS {DEFENSE: {DEFENSE, (#DEFENSE + 1)@DROLLS}}
}
}
result: 1@ATTACK
}
```
I originally had the rerolling and exploding loops iterate an extra 20 times(for "depth"), but I ended up with discrepancies in odds (6d6 vs 5d6 had lower odds than 6d6 vs 6d6).
I increased the loops to iterate an extra 5 times further(25 depth) and it fixed my discrepancy, but it's also altering odds for lower pools more than I had anticipated.
I am not really a coder, so I would appreciate some more experienced eyes taking a look at this function to see if my logic is correct. I don't want to keep waiting for my output and redoing my spreadsheets if I screwed something up