I’m by no stretch of the imagination any sort of programming type, but I’ve been trying to use AnyDice to rank all the possible ways the die rolls can be modified in the board game HeroQuest. The basic mechanics of the use a roll and count die pool with opposed rolls using a base die that could be represented as {3:3, 2:2, 1} with three being used to attack, two being used for hero defense, and one being used for monster defense. Though the dice themselves are symboled dice using skulls, white shields and black shields respectively.
Using variables and custom dice I was able to cover most of the modifiers (that I could think of) which could be applied to the rolls. For example, a popular fan modification is to add colored dice with alternate distributions and doubled icons on some faces. To make these I just added three to the icon’s value to represent doubles and made new dice/variables for the alternate distribution (example: {6, 3:2, 5, 2, 1})
By some miracle of mess ups I managed to somehow get a function which when combined with the variables is able to produce all of the basic rolls as well as rolls where all the dice can be rerolled. But it cannot reroll a single die from the pool if X was rolled. I’ve spent days trying to figure this out (actually longer as this is something I have tried multiple times) and it keeps seeming like I’m almost there but whenever I run the function and then do actual math to compare (or run a control die in the program) the results do not match. With my extremely limited understanding of how AnyDice works it seems like my current function should have worked but if that was the case I wouldn’t be looking for help.
Here are a few of the variables and the functions that I’ve gotten (will only post variables for purple dice as they have doubles and serve as one of the worst testers):
PURPLE: {6, 3:2, 5, 2, 1}
SK: 3
WS: 2
BS: 1
NA: -3 (used if no rerolls allowed)
BRPR: {6:7, 3:14, 5:7, 4:7, 1}
BRPR is a consolidated purple die rerolling black shields for control purposes or global rerolls.
There is also a COLOR, ACTION, and REROLL variable just above the output section and below the functions where I edit which dice I want to emulate and which die roll to test for.
Functions copied from AnyDice:
function: roll DICE:s for ICON:n no
reroll
{SUCCESSES: DICE = ICON
DOUBLE: DICE = ICON + 3
if SUCCESSES > 0 {result: SUCCESSES
+ DOUBLE*2} if DOUBLE >0 {result:
DOUBLE*2}
else {result:0}}
function: roll DICE:s for ICON:n
reroll SINGLE
{SUCCESSES: DICE = ICON
DOUBLE: DICE = ICON + 3
if DICE != SINGLE|SINGLE+3
{result: SUCCESSES + DOUBLE*2}
result: SUCCESSES + DOUBLE*2 +
[roll 1dDICE for ICON no reroll]}
\Edit your roll here\
COLOR: PURPLE
ACTION: SK
REROLL: BS
\End edits here\
loop MAX over {1..4} {
output [roll MAX d COLOR for ACTION
reroll REROLL] named "[MAX]d Test"}
loop DICE over {1..4} {
output DICEd{1:2,2,0:3} named
"[DICE]d No reroll Control"}
output [roll 1dBRPR for ACTION no
reroll] named "Single Reroll
Control"
The results as I’m understanding should be checking for the reroll first and if it is negative it counts successes and doubles, then if there is a reroll rolling a single die and adding those successes to the successes already rolled. Instead I’m getting the same results as if there are no rerolls allowed. Can some please explain what I’m doing wrong here? Please explain it as if you’re talking to a five year old child as they’re probably more proficient at this than I am.
Link to the function with full variables if necessary: https://anydice.com/program/2ea73