Post Reply 
(PC-1211) Multiple Dice Throw
03-23-2021, 03:34 PM
Post: #7
RE: (PC-1211) Multiple Dice Throw
(03-23-2021 02:43 PM)robve Wrote:  
(03-20-2021 11:48 AM)SlideRule Wrote:    70: B=997B+π :B=B-INT B:C=INT 6B+1

Thank you for sharing this code!

Line 70 uses an interesting pseudo-random number generator. The PRNG is very simple, yet seems to be good enough to reliably simulate multiple dice throws, perhaps. It passes the spectral test when I tested this with a simple program on a PC-1350 (select image to view):

10 "A" CLS: WAIT 0: B=0
20 FOR I=1 TO 32*150
30 B=997*B+π,B=B-INT B:X=150*B
40 B=997*B+π,B=B-INT B:Y=32*B
50 PSET (X,Y)

Disclaimer: this spectral test code may not meet official test requirements.

By comparison, the PC-1350 RND function spectacularly fails the spectral test, so I would not use it to throw dice for example (select image to view):

10 "A" CLS: WAIT 0: FOR I=1 TO 32*150: PSET (RND 150-1,RND 32-1): NEXT I: WAIT: GPRINT: END

The number 997 is used by other PRNGs. See also previous HP Forum threads on this subject:

- Rob

Shouldn't you use RANDOM before invoking RND, unless you want to use the same seed each time?


-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
(PC-1211) Multiple Dice Throw - SlideRule - 03-20-2021, 11:48 AM
RE: (PC-1211) Multiple Dice Throw - C.Ret - 03-21-2021, 09:29 AM
RE: (PC-1211) Multiple Dice Throw - robve - 03-23-2021, 02:43 PM
RE: (PC-1211) Multiple Dice Throw - Massimo Gnerucci - 03-23-2021 03:34 PM
RE: (PC-1211) Multiple Dice Throw - robve - 03-23-2021, 03:56 PM
RE: (PC-1211) Multiple Dice Throw - pyedog - 03-23-2021, 04:06 PM

User(s) browsing this thread: