(12C Platimun) Roll Two Dice at Random

11302018, 10:36 AM
Post: #1




(12C Platimun) Roll Two Dice at Random
This two dice roller program is similar to my previous post at
http://www.hpmuseum.org/forum/thread10565.html Only different Random Algorithm and program on ALG mode. Procedure: 1. Store Seed on Register 0 2. [R/S] 3. to continue press [R/S] Example: FIX 0 ,287103 [STO] 0 [R/S] "2" "6" 8 [R/S] "1" "1" 2 [R/S] "6" "1" 7 [R/S] "5" "4" 9 Program: Roll Two Dice in Random (ALG mode) Code:
Gamo 

12242018, 01:54 AM
Post: #2




RE: (12C Platimun) Roll Two Dice at Random
Updated Version
This program use a "Virtual Subroutine" to run Random Routine Twice. Procedure is the same as program above. Program: FIX 0 (ALG Mode) Code:
Program: FIX 0 (RPN Mode) Code:
Gamo 

12302018, 09:36 AM
(This post was last modified: 12302018 01:52 PM by Dieter.)
Post: #3




RE: (12C Platimun) Roll Two Dice at Random
(12242018 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 

03072019, 01:40 AM
(This post was last modified: 03072019 02:44 AM by Gamo.)
Post: #4




RE: (12C Platimun) Roll Two Dice at Random
Roll One Dice in Random without using any store registers.
Procedure: 0 < Seed < 1 [R/S] display Random Dice Face between 1 to 6 [R/S] continue.... Example: .456789 [R/S] display 5 [R/S] 3 [R/S] 5 [R/S] 6...1...3...2...3...5..........  Program: ALG mode Code:
Program: RPN mode Code:
Gamo 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)