Should send this off to All in Play.

I keep getting the same cards.  Smiles.

Their three lines of code that they show on their site, don't account for 
waiting.  They don't want to admit the trueth about getting a random number 
from what time it is.

Thanks for your code on how to randomize a value Tom.

Gary
----- Original Message ----- 
From: "Thomas Ward" <[EMAIL PROTECTED]>
To: "Gamers Discussion list" <gamers@audyssey.org>
Sent: Sunday, November 26, 2006 12:20 PM
Subject: Re: [Audyssey] randomising


> Hi Nicol,
>
> Nicol wrote:
>> I would  very much like to know how its possible for the computer to
>> randomise.
> End Quote
>
> Well, actually it isn't very complex, but you will have rto write a
> function which does a few things such as seed the randomize function you
> are making with the computers time, select a number, and then return it
> to the variable calling it. In C#.NET a function to randomly select a
> random number would look like this. Make sure say all punctuation is on
> and your message window is maximized.
>
>        public int RandomNumber(int low, int high)
>        {
>
>            // First we need a temperary random seed object
>            // to seed our generator.
>            Random seed = new Random();
>
>            // Now, we will advance the seed with the system time
>            // and store it in the time variable.
>            int time = seed.Next();
>
>            // At this point we will create a random object for
>            // randomly generating numbers,
>            // and seed it with the time.
>            Random select = new Random(time);
>
>            // Now, we will select a number from the low and high numbers,
>            // and then add 1.
>            int number = select.Next(low, high) + 1;
>
>            // Return our random number.
>            return number;
>        }
>
> A couple of notes is in .net apps you can also make an call to the
> active thread to sleep or wait for so many milliseconds so as to allow
> the time on the clock to change. Without changing the time you will
> return the same number over and over again. To pause the thread in C#
> .net you would use
> Thread.Sleep(10;
> which would grab the active thread and pause it for 10 ms.
> So to use this function it would look like
>
> Thread.Sleep(10);
> dice1 = RandomNumber(1, 6);
> Thread.Sleep(10);
> dice2 = RandomNumber(1, 6);
>
>
> Which would roll to dice for you and all you need from there is display
> or do something based on the dice roll.
>
>
>
>
> _______________________________________________
> Gamers mailing list .. Gamers@audyssey.org
> To unsubscribe send E-mail to [EMAIL PROTECTED] You can 
> visit
> http://audyssey.org/mailman/listinfo/gamers_audyssey.org to make
> any subscription changes via the web. 


_______________________________________________
Gamers mailing list .. Gamers@audyssey.org
To unsubscribe send E-mail to [EMAIL PROTECTED] You can visit
http://audyssey.org/mailman/listinfo/gamers_audyssey.org to make
any subscription changes via the web.

Reply via email to