by Maurice76 » February 6th, 2019, 8:29 am
I've recently taken a look at the source code of my sheet to see what I needed to change to accomodate for rerolls. The main problem that I have is that a reroll is basically something that's evaluated after the roll is made. The reason for this is that:
a) One or more of the dice need to have an undesired result;
b) Based on which die or dice have the undesired result, a further subselection needs to be made based on preferred outcome to select which die or dice to reroll;
Especially the second one is tricky and simply implies that you need to evaluate all possible permutations to consider rerolls. My current code doesn't evaluate all permutations, it evaluates each die in sequence, totalling everything. My original code did consider all permutations, but from 7 or 8 dice onward, calculation times became quite prohibitive. At 10 dice, it ran for over an hour to get everything sorted - that's way too long.
I need to put some thought into optimizing this and maybe find a clever evaluation solution.