Simple Random Number Generator

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
mikegonta
Member
Member
Posts: 229
Joined: Thu May 19, 2011 5:13 am
Contact:

Simple Random Number Generator

Post 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
Mike Gonta
look and see - many look but few see

https://mikegonta.com
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Simple Random Number Generator

Post by dozniak »

It's a PRNG, not an RNG, right?
Learn to read.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Simple Random Number Generator

Post 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?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

Re: Simple Random Number Generator

Post 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
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Simple Random Number Generator

Post by Love4Boobies »

I don't see the relevance of that story.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

Re: Simple Random Number Generator

Post 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.
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Simple Random Number Generator

Post 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/
mikegonta
Member
Member
Posts: 229
Joined: Thu May 19, 2011 5:13 am
Contact:

Re: Simple Random Number Generator

Post 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
Mike Gonta
look and see - many look but few see

https://mikegonta.com
User avatar
dchapiesky
Member
Member
Posts: 204
Joined: Sun Dec 25, 2016 1:54 am
Libera.chat IRC: dchapiesky

Re: Simple Random Number Generator

Post 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...
Plagiarize. Plagiarize. Let not one line escape thine eyes...
User avatar
Geri
Member
Member
Posts: 442
Joined: Sun Jul 14, 2013 6:01 pm

Re: Simple Random Number Generator

Post by Geri »

in the Dawn operating system, i **** the time, shuffle it with previous results, add pixels from screen, and mouse position.
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Simple Random Number Generator

Post by dozniak »

I'm quite curious as to what you do to the time to offend the profanity filter.
Learn to read.
User avatar
Geri
Member
Member
Posts: 442
Joined: Sun Jul 14, 2013 6:01 pm

Re: Simple Random Number Generator

Post 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
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
Post Reply