Posted By
|
Message
|
 Fish20
Registered 03/12/2007
Points 263
     
|
7th February, 2008 at 19:04:06 -
In card games the computer picks a random card. How could u make it so that when it randomly picks a number it destroys it and can't be used again?
All your base are in another castle, take this.
|
 Dustin Gunn Gnarly Tubular Way Cool Awesome Groovy Mondo
Registered 15/12/2004
Points 2659
    
|
7th February, 2008 at 20:46:23 -
I think the magicdeque object does exactly that, but I've never used it
n/a
|
 Cecilectomy noPE
Registered 19/03/2005
Points 305
         
|
7th February, 2008 at 21:05:59 -
store ones that have already been used and keep generating a random one till it is one that hasn't been used yet
n/a
|
![]() ~Zigzag~
Registered 13/03/2007
Points 292

|
9th February, 2008 at 20:35:34 -
This is like identical to the other topic... Including the reply...
http://www.SilverNova.co.uk
|
 Cecilectomy noPE
Registered 19/03/2005
Points 305
         
|
9th February, 2008 at 20:39:29 -
i know. its such a simple thing to do too.
n/a
|
 Fifth Quadruped
Registered 07/05/2003
Points 5819
   
|
9th February, 2008 at 20:58:53 -
You could also use a list object.
Fill it up with the values you need, then generate a random number based on the number of lines in the list, retrieve the appropriate value, and remove the line from the list.
It's handy for the fact that the lines will automatically compress to not leave any holes.
Go Moon!
|
 Cecilectomy noPE
Registered 19/03/2005
Points 305
         
|
9th February, 2008 at 21:33:36 -
but then youd need a way to load all the values back into the list if you wanna shuffle all the cards and start over. also if you save all values somewhere (like an array) you can remember where all the cards are in the deck at any time. which would probably be a better way of shuffling cards. randomly fill the list with numbers without repeating any numbers and then youd have a truly shuffled deck.
n/a
|
 Peblo Custom ratings must be 50 characters or less
Registered 05/07/2002
Points 185
         
     
|
9th February, 2008 at 21:38:55 -
Unless you figure out the seed, which people usually leave as -1
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath
|
|
|