Author: Don Dailey
Date: 18:59:10 10/22/98
Go up one level in this thread
On October 18, 1998 at 05:46:50, Ed Schröder wrote: >Since ages I use the following formula for creating a set of random >integers for hashing at program start: > >#define LENGTH 64*12 > >int random [LENGTH]; > >int a,b,c,d,x; > >srand(9); // initialize prime number > >for (x=0; x<LENGTGH; x++) > { a=rand(); b=rand(); if (b & 1) a=a | 0x8000; > c=rand(); d=rand(); if (d & 1) c=c | 0x8000; > random[x]=(a<<16)+c; > } > >I wonder how good such a system is and how others do it. > >- Ed - Hi Ed, I noticed this question generated a lot of responses. The way I actually generated my random number table (I use 64 bit entries) was using the random number generator that comes with gcc and then I xor each entry with the "true random number generator" supplied by most linux distributions. I guess I am paranoid and liked the combination of doing both! But I precomputed the table and declare it somewhere in the code. The "true random generator" in linux is based on lots of chaotic state changes inside your computer. It looks like a device in unix and you just read them from a file. They look at things like disk latency, interupts keyboard presses and anything they can find to act as a source of random state to seed into their generator. I don't know how random it actually is but I'm happy. The hamming stuff though is probably the right way to do it if you are willing to have a precomputed table. You could probably get away with any lousy generator if you are doing the right hamming measurements. Since the hamming technique throws out numbers that don't pass, you will probably get a better distribution anyway. - Don
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.