Challenge: Open-ended Dice on the HP-41 - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Challenge: Open-ended Dice on the HP-41 (/thread-155850.html) |
Challenge: Open-ended Dice on the HP-41 - Geir Isene - 09-06-2009 This challenge is derived from creating applications for the Amar role-playing game. It is a challenge involving the extension of the normal dice with 6 sides - a so called open-ended dice throw. Definition: Take a dice with 6 sides. Now we would like to extend the range of the numbers beyond the intrinsic 1 to 6. A way to accomplish that is to make the 1 and the 6 special cases. Whenever you throw a 6, you can extend the range by making another throw. A throw of 4 to 6 (50%) will add 1 to the original 6. Throw again and a result of 4 to 6 will again add 1 to the number (making it 8) etc. Every throw of 4 to 6 will add one until you get a 1, 2 or 3, then it stops. Conversely, throwing a 1 on the first throw is a special case. Throw again, and a result of 1 to 3 will subtract 1 from the original number. Keep throwing 1, 2 or 3 to subtract one... until you throw a 4, 5 or 6 - then it stops. Now we add a dimension; Whenever you throw two 6's consecutively it is marked as a "critical". A throw of two consecutive 1's is a "fumble". All this is called an "open-ended" dice throw. A normal dice roll is termed a D6, an open-ended roll is O6. Challenge: Create a program for the HP-41 that does open-ended dice rolls. It should show whether the roll also includes a "critical"/"fumble". Do this without using any storage registers - i.e. only using the stack (and the Alpha register if you wish).
I will publish my solution for dissection in a few days :-)
Re: Challenge: Open-ended Dice on the HP-41 - hugh steers - 09-06-2009
the first column is the value and the second the percentage of trials hitting that value.
1 8.2905 So we have a [2,4] plateau (1/6 as expected), then 50% falloff each side. However, it's interesting to note that the "critical" and "fumble" percentages are almost 1 in 36. This indicates that you don't really get much difference tracking consecutive 1's and 6's after the first go. Consequently, i modified my simulator to count a "critical" as 2 6's at the start and a "fumble" as 2 1's. here's what i get:
1 8.2841 Similar story. So i would say, for the purposes of generating values for Amar, you could simplify your algorithm on the 41c and not track consecutive values. which should shorten the program. here are my two versions. o6() is the "real" algorithm and "os6plain" is my hacked one.
function d6()
Re: Challenge: Open-ended Dice on the HP-41 - hugh steers - 09-06-2009 Uh-oh! i made a mistake tracking the consecutive values. The difference is actually more - about 3% instead of 2.7 should be,
function o6() so, it depends on whether you really want to track consecutive values or not.
|