Someone in chat helped write an anydice program to calculate limit breaks in an RPG I’m developing, but after making some changes, it times out for dicepools > 7.
The system I have in mind, is that if any of the dice you roll is below a threshold, you can bank the sum of all failed rolls for later use, by converting it into a limit break token (currently, at an exchange rate of 1:4). I’m toying with requiring a certain number of successes before you can convert failed, which may or may not be slowing down the program.
function: sum X:s less than L with at least K successes { R: 0 S: 0 loop I over X { if I <= L { R: R + I } if I > L { S: S + 1 } } if S >= K { result: R/4 } if S < K { result: 0 } }
Is there a more efficient way of running this program? Initially before my tweaks, the same helpful person suggested this as an alternative to the function: output 3d{1..6, 0:6} named "Alt dice"
but I can’t figure a way of running that, which is probably less likely to time out, and still check for a minimum number of successes.
Here is the code that causes the time out:
output [sum 1d12 less than 7 with at least 0 successes] named "1 die limit break" output [sum 2d12 less than 7 with at least 1 successes] named "2 die limit break" output [sum 3d12 less than 7 with at least 1 successes] named "3 die limit break" output [sum 4d12 less than 7 with at least 1 successes] named "4 die limit break" output [sum 5d12 less than 7 with at least 1 successes] named "5 die limit break" output [sum 6d12 less than 7 with at least 1 successes] named "6 die limit break" \Times out around here\ output [sum 7d12 less than 7 with at least 1 successes] named "7 die limit break" output [sum 8d12 less than 7 with at least 2 successes] named "7 die limit break" output [sum 9d12 less than 7 with at least 2 successes] named "7 die limit break" output [sum 10d12 less than 7 with at least 2 successes] named "7 die limit break"
I found the timeout point by running each line individually.