(12C Platimun) Roll Two Dice at Random - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (12C Platimun) Roll Two Dice at Random (/thread-11877.html) |
(12C Platimun) Roll Two Dice at Random - Gamo - 11-30-2018 10:36 AM This two dice roller program is similar to my previous post at http://www.hpmuseum.org/forum/thread-10565.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 RE: (12C Platimun) Roll Two Dice at Random - Gamo - 12-24-2018 01:54 AM 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 RE: (12C Platimun) Roll Two Dice at Random - Dieter - 12-30-2018 09:36 AM (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 RE: (12C Platimun) Roll Two Dice at Random - Gamo - 03-07-2019 01:40 AM 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 |