I am translating a Word document into LaTeX as a learning experience. Now there is this table, that already has hard-coded values. However, I would like to have it generic, so that changing a single number inside the .tex file changes the number of rows of the column. All values are calculated based on the key of the row, by the following algorithm.
Given a real number, calculate a number a dice (6-sided) and an integer modifier, which is no larger than +- 3. The expected value of the resulting modified dice throw should equal the input number with error no higher that 0.5. Make the algorithm deterministic.
Can this be done? Please propose further reading.
Something in the lines of:
[dice, mod] foo(expected) dice = floor(expected / 3.5) mod = floor(expected - dice * 3.5)
But an algorithm, that balances the use of positive and negative modifiers would be better. Also, gracefully handling values below 3.5 would be great (always including at least one die).
As an example, 12 would output 3 dice +1 modifier for a total expected value of 11.5.
The source table is this, but it needn't be followed precisely.