My friend came up with this equation:

( -1 + SquareRootOf (1 + ( 8 * Stat ) ) ) / 2 = Number of dice (round them down)

So —

1) does that work?

2) how do I do that in PHP?

- Thread starter Morrus
- Start date

My friend came up with this equation:

( -1 + SquareRootOf (1 + ( 8 * Stat ) ) ) / 2 = Number of dice (round them down)

So —

1) does that work?

2) how do I do that in PHP?

I threw your formula, with a minor tweak or two { =TRUNC((SQRT((1+(8*Stat)))-1)/2, 0) } into Excel and the results match up to the numbers shown in the attributes table on p. 17 in WOIN:NOW book. But I'm no math whiz, so I don't know by looking at this if the formula will break at some point, like at a very high number. The key change to the formula is that you need to truncate/floor, not round, the result to get the number of dice.

I'm a Java programmer, don't really know PHP, but after a quick Google search I have come up with the following:

<?php

floor(((sqrt((1+(8*Stat))))-1)/2);

?>

You can test it out here: PHP Tryit Editor v1.2 (just replace the "pi()" in the page with my blue text above, and replace "Stat" with actual numbers to test). Hope this helps.

I'm a Java programmer, don't really know PHP, but after a quick Google search I have come up with the following:

<?php

floor(((sqrt((1+(8*Stat))))-1)/2);

?>

You can test it out here: PHP Tryit Editor v1.2 (just replace the "pi()" in the page with my blue text above, and replace "Stat" with actual numbers to test). Hope this helps.

Last edited:

Now to work out how to do the reverse - what's the minimum stat needed to get a specified number of dice?

Which it turns out my GCSE algebra was sufficient to calculate!