(12C Platimun) Roll Two Dice at Random
|
12-30-2018, 09:36 AM
(This post was last modified: 12-30-2018 01:52 PM by Dieter.)
Post: #3
|
|||
|
|||
RE: (12C Platimun) Roll Two Dice at Random
(12-24-2018 01:54 AM)Gamo Wrote: This program use a "Virtual Subroutine" to run Random Routine Twice. Hmm... instead of a virtual subroutine this looks more like a loop with a counter. Here is another version that comes closer to a "pseudo subroutine call". It works on a regular 12C as well as the Platinum in RPN mode. Code: 01 f 2 It works like this: the "subroutine" (i.e. the random number generator in line 03...16) is called with either 1 or 0 in X. The result is then multiplied by this 1 or 0. At the first call this leaves the generated random number unchanged (1...6), while after the second call the result is zero (while the random number is still in LastX). So the program does an x=0? test and jumps to the one or other "virtual return address". Edit: I just noticed that I posted a program with the same approach for the same calculator back in April: here it is. #-) The output is s.xy where s is the dice sum and x and y are the two individual scores. If you prefer an output like in your original program simply change the first line to f 0 and replace the final steps like this: Code: 01 f 0 The random number generator uses the formula r := frac[(r + √19)²]. I can't say anything about its statistical properties, but it seems to work well enough for this purpose. ;-) You may place a seed in R0 before the program is run for the first time (but you don't have to). Example: 0,12345 STO 0 [R/S] 6,15 [R/S] 7,52 [R/S] 11,56 [R/S] 7,34 [R/S] 5,41 ... Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(12C Platimun) Roll Two Dice at Random - Gamo - 11-30-2018, 10:36 AM
RE: (12C Platimun) Roll Two Dice at Random - Gamo - 12-24-2018, 01:54 AM
RE: (12C Platimun) Roll Two Dice at Random - Dieter - 12-30-2018 09:36 AM
RE: (12C Platimun) Roll Two Dice at Random - Gamo - 03-07-2019, 01:40 AM
|
User(s) browsing this thread: 2 Guest(s)