Page 1 of 1

Simple Random Number Generator

Posted: Wed Feb 15, 2017 4:18 pm
by mikegonta
Simple Random Number Generator
Here is a simple 16 bit real mode (8086 code) RNG.
It's an implementation of the KISS RNG
I'm using it in Space Invaders
The simple_rng_init uses 2 of the 3 RNG's used in simple_rng to generate the 4 seeds and then calls simple_rng to get the first number in the series
which is saved for later. simple_rng compares each generated number and when the series repeats calls simple_rng_init to begin a new series. Obviously
with only a 64 bit seed the period will be short but none the less suitable for small systems.

simple_rng.asm

Re: Simple Random Number Generator

Posted: Thu Feb 16, 2017 9:15 am
by dozniak
It's a PRNG, not an RNG, right?

Re: Simple Random Number Generator

Posted: Thu Feb 16, 2017 10:11 am
by Love4Boobies
I don't understand why you didn't just settle for a LCG or a LFSR. Are you afraid that people will pause the game, pull out their calculators, and try to predict the events in the game?

Re: Simple Random Number Generator

Posted: Thu Feb 16, 2017 10:19 am
by matt11235
Love4Boobies wrote:I don't understand why you didn't just settle for a LCG or a LFSR. Are you afraid that people will pause the game, pull out their calculators, and try to predict the events in the game?
This happens

Re: Simple Random Number Generator

Posted: Thu Feb 16, 2017 10:47 am
by Love4Boobies
I don't see the relevance of that story.

Re: Simple Random Number Generator

Posted: Thu Feb 16, 2017 11:01 am
by matt11235
Love4Boobies wrote:I don't see the relevance of that story.
Somebody got their calculator out (because of the insecure PRNG) and predicted the winning numbers of a gambling game.

Re: Simple Random Number Generator

Posted: Thu Feb 16, 2017 3:33 pm
by Nable
matt11235 wrote:
Love4Boobies wrote:I don't understand why you didn't just settle for a LCG or a LFSR. Are you afraid that people will pause the game, pull out their calculators, and try to predict the events in the game?
This happens
+1 more story, more RNG hardcore: https://www.wired.com/2017/02/russians- ... os-no-fix/

Re: Simple Random Number Generator

Posted: Fri Feb 17, 2017 2:45 pm
by mikegonta
Love4Boobies wrote:I don't understand why you didn't just settle for a LCG or a LFSR.
Good suggestion.
Here is a simple real mode (80386 code) PRNG with a period of (2^64)-1.
It's an optimized implementation (only 4 instructions) of the Galois LFSR PRNG.
There's an LCG in simple_prng_init to process the entropy.
I'm using it in Space Invaders

Code: Select all

  shr edx, 1
  rcr eax, 1
  jnc .1
  xor edx, 0xD0000000 ; 0xD000000000000000 is maximal tap for 64 bit
.1:
dozniak wrote:It's a PRNG, not an RNG, right?
Obvious here, but maybe not so further up the ivory tower.

simple_prng.asm

Re: Simple Random Number Generator

Posted: Fri Feb 17, 2017 7:56 pm
by dchapiesky
Perhaps said PRNG could be run through the gauntlet?

http://simul.iro.umontreal.ca/testu01/tu01.html

should be easy to add as another prng in the testkit...

Re: Simple Random Number Generator

Posted: Wed Mar 15, 2017 12:38 pm
by Geri
in the Dawn operating system, i **** the time, shuffle it with previous results, add pixels from screen, and mouse position.

Re: Simple Random Number Generator

Posted: Wed Mar 15, 2017 1:45 pm
by dozniak
I'm quite curious as to what you do to the time to offend the profanity filter.

Re: Simple Random Number Generator

Posted: Fri Mar 17, 2017 2:53 pm
by Geri
dozniak wrote:I'm quite curious as to what you do to the time to offend the profanity filter.
https://i.ytimg.com/vi/fvf_gwQCcUg/maxresdefault.jpg