🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: att.lang.c++
Article #17

Re: random number generator

#17
From: lovens weche
Date: Mon, 02 Jun 2003 02:45
30 lines
2022 bytes
...snip snip...

> >
>
> This is a linear congruential generator. With the values you've given
> above it will do a very bad job of producing random numbers. But even
> with good values it will repeat. And it should. Think about it: if you
> threw a die and in every six throws you got all six faces exactly once
> you'd be very suspicious. And you'd have a game that was very easy to
> beat.
>
> You need a second step beyond the random number generator, to supply a
> random sequence:
>
> for (i = 0; i < NumElem; i++)
> VectCurrPtr[i] = i;
> for (i = NumElem; 1 < i; i--)
> {
> int j = rand() % (i - 1);
> int temp = VectCurrPtr[j];
> VectCurrPtr[j] = VectCurrPtr[i - 1];
> VectCurrPtr[i - 1] = temp;
> }
>
> --

ok thanx Pete.. I'll try to implement it...


Lovens
Technical Details
Message-ID: <oSyCa.13381$g33.211097@weber.videotron.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!c03.atl99!news.webusenet.com!wesley.videotron.net!weber.videotron.net.POSTED!not-for-mail
References: <SikCa.1506$Z83.788@wagner.videotron.net> <3ED9FD62.2B70E8DD@acm.org>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1014db,da54b5a763359bc3
X-Google-Attributes: gid1014db,public
X-Google-Thread: 109fba,da54b5a763359bc3
X-Google-Attributes: gid109fba,public
X-Google-Thread: 10d4ba,da54b5a763359bc3
X-Google-Attributes: gid10d4ba,public
X-Google-ArrivalTime: 2003-06-01 19:44:47 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!c03.atl99!news.webusenet.com!wesley.videotron.net!weber.videotron.net.POSTED!not-for-mail
From: "lovens weche" <fw1803@videotron.ca>
Newsgroups: att.lang.c++,comp.lang.c,comp.lang.c++
References: <SikCa.1506$Z83.788@wagner.videotron.net> <3ED9FD62.2B70E8DD@acm.org>
Subject: Re: random number generator
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <oSyCa.13381$g33.211097@weber.videotron.net>
Date: Sun, 1 Jun 2003 22:45:10 -0400
NNTP-Posting-Host: 66.131.83.25
X-Complaints-To: abuse@videotron.ca
X-Trace: weber.videotron.net 1054521876 66.131.83.25 (Sun, 01 Jun 2003 22:44:36 EDT)
NNTP-Posting-Date: Sun, 01 Jun 2003 22:44:36 EDT