OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Sep 22, 2017 7:27 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Simple Random Number Generator
PostPosted: Wed Feb 15, 2017 4:18 pm 
Offline
Member
Member

Joined: Thu May 19, 2011 5:13 am
Posts: 194
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

http://mikegonta.com


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Thu Feb 16, 2017 9:15 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 718
Location: Tallinn, Estonia
It's a PRNG, not an RNG, right?

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Thu Feb 16, 2017 10:11 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2071
Location: Bucharest, Romania
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 ]


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Thu Feb 16, 2017 10:19 am 
Offline
Member
Member
User avatar

Joined: Tue Aug 02, 2016 1:52 pm
Posts: 286
Location: East Riding of Yorkshire, UK
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


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Thu Feb 16, 2017 10:47 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2071
Location: Bucharest, Romania
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 ]


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Thu Feb 16, 2017 11:01 am 
Offline
Member
Member
User avatar

Joined: Tue Aug 02, 2016 1:52 pm
Posts: 286
Location: East Riding of Yorkshire, UK
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


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Thu Feb 16, 2017 3:33 pm 
Offline
Member
Member

Joined: Tue Nov 08, 2011 11:35 am
Posts: 452
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/


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Fri Feb 17, 2017 2:45 pm 
Offline
Member
Member

Joined: Thu May 19, 2011 5:13 am
Posts: 194
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:
  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

http://mikegonta.com


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Fri Feb 17, 2017 7:56 pm 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 205
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...


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Wed Mar 15, 2017 12:38 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
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://DawnOS.tk


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Wed Mar 15, 2017 1:45 pm 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 718
Location: Tallinn, Estonia
I'm quite curious as to what you do to the time to offend the profanity filter.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Simple Random Number Generator
PostPosted: Fri Mar 17, 2017 2:53 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
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://DawnOS.tk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group