----- "Virgo Pärna" <virgo.pa...@mail.ee> schreef: > On Fri, 09 Dec 2011 09:19:53 +0100, Florian Klaempfl > <flor...@freepascal.org> wrote: > > > > Oops, mails crossed. The assignment to randseed is indeed the > problem. > > Why is it done? Bad random generator of delphi :)? > > > > I don't know, how bad Delphis random generator is, but I once > years ago did make a mistake > of calling randomize before random. It was a school assignment for > using Turbo Pascal graphics. > So I made program, that was supposed to fill screen with random dots > (colour was also set with > random). Anyway, when I called randomize before random, then as a > result dots didn't fill the > screen, but were mostly along the diagonal of the screen. So I'd > guess, that setting randseed > multiple times could be actually bad for randomness of results. Or > maybe modern algorithms are > better at situations like this? >
Randomize() is supposed to be called only once to seed the generator with an initial value. If you made it something like so: begin for i := 0 to 1000 do begin randomize(); pixel[random(screenwidth),random(screenheight)]:= clSomeColor; end; end; then you seed with a timestamp before randoming and your distribution does not change much with a lcg. Not the fault of the algorithm itself, just your mistake of doing the randomize in the loop itself (like you mentioned yourself). kind regards, Dimitri Smits _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal