Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Looking for fast random number algorithms

 
Post new topic   Reply to topic Printable version
 View previous topic  Opinion on Alphabetic Sort Post :: Post TCP help  View next topic  
Author Message
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Mar 14, 2006 12:10 am    Post subject: Looking for fast random number algorithms Reply to topic Reply with quote

I'm currently working with a 16bit processor, and I am looking to find a simple random number generator that works well enough in a small range, such as between 0 and 1000, or the lower (or upper) 10 bits at least, but most importantly be able to get close to 50-50 on coin flips and 25-25-25-25 on a 4-way choice. Being 45-55 is perfectly acceptable, but more than 40-60 is pushing it.

It doesn't need to be fancy, as speed is much, much more important than randomness. Seeding of the random number generator will most likely be shitty, as its environmental sensory will be in a very binary world. Any ideas?
Back to top
View users profile Send private message Add User to Ignore List Send email
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Tue Mar 14, 2006 1:02 am    Post subject: Reply to topic Reply with quote

I've always used a LFSR for my PRNGs in embedded systems. I don't have any code handy, but it'd be in asm and probably worthless to you anyway.

Here's a wiki article to get you started: http://en.wikipedia.org/wiki/Linear_feedback_shift_register
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Mar 14, 2006 3:24 am    Post subject: Reply to topic Reply with quote

Thanks, works pretty damn well. Might as well put up a copy of the source here for anyone else interested. Has hard coded values in, though through random trial and error, was a pretty good initial seed value for 1 and 2 bit random numbers, which are the important ones. Don't want to do the math for finding an optimial starting seed value for a 10bit number to be random enough, as that will only be called rarely so will be random enough.



My code of Linear Feedback Shift Register for a 16bit processor

prng.c - 3.53 KB
File downloaded or viewed 47 time(s)
Back to top
View users profile Send private message Add User to Ignore List Send email
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 687 page(s) served in previous 5 minutes.

phpBB Created this page in 0.510765 seconds : 30 queries executed (81.1%): GZIP compression disabled