Finally a good random number generator -- #xorshift, specifically Brad Forschinger's adaptation to 16 bits: https://b2d-f9r.blogspot.com/2010/08/16-bit-xorshift-rng-now-with-more.html. It works a treat in Pygmy 1.7.

Frustration with Turbo Pascal 2.0's stock random number generator was one factor that got me considering other languages to begin with, so this is very satisfying to have running!

Those runs of 1-bit shifts annoy me... need to add assembler words to access the 80186's barrel shifter. Stock Pygmy only knows about plain 8086 instructions.

( RANDOM NUMBERS - 16 BIT XORSHIFT )
VARIABLE RX VARIABLE RY 1 RX ! 1 RY !
: SRAND ( -) T0@ RX ! 1 RY ! ;
: T ( -N) RX @ DUP 2* 2* 2* 2* 2* XOR ;
: RAND ( -N) T RY @ RX ! DUP 2/ 2/ 2/ XOR
RY @ DUP 2/ XOR XOR DUP RY ! ;
: CHOOSE ( N-N') RAND SWAP 1 MAX U/MOD DROP ;
16 bit xorshift rng (now with more period)

So, in Marsaglia's paper , the basic xorshift rng the code is: yˆ=(y<<a); y^=(y>>b); return (yˆ=(y<<c)); I looked at this in my last post, ...