ID:266293
Nov 12 2001, 2:55 pm (Edited on Nov 12 2001, 3:23 pm)
|
|
how would i make a proc that would take a stack of objects and shuffle them?
|
In response to Jmurph
|
|
Jmurph wrote:
What the heck do you mean "shuffle them"? Mix them up. |
In response to Air _King
|
|
Um, well, if you follow Jmurph's advice, you'll find that is probably what you need. No need to mix up the list of cards, just have the pick() select a card at random. Then remove that card from the list so it won't be picked agian. Pretty straightforward if you ask me....
~X |
In response to Xooxer
|
|
Xooxer wrote:
Um, well, if you follow Jmurph's advice, you'll find that is probably what you need. No need to mix up the list of cards, just have the pick() select a card at random. Then remove that card from the list so it won't be picked agian. Pretty straightforward if you ask me.... then i would have to pick what cards would be in the list, but I want the cards in the list to be randomly generated. Oh Well. |
Air _King wrote:
how would i make a proc that would take a stack of objects and shuffle them? proc/Shuffle(list/cards) That ought to do the trick. Lummox JR |
In response to Air _King
|
|
That would be a seperate operation alltogether. I assumed that you had a set deck, like in Una, or Spades, or whatever...
But if you are using dynamic decks (like in Magic, etc...) Then you'll need to make a proc to add the individual cards to the list. I suppose you could make another list for this proc to pick from, and simply re-use the first proc to do both things, create the deck, and randomly give out cards from that deck... It all depends on how your game is going to behave. I was simply pointing out that the advice given to you previously was valid, and should (with perhaps slight alterations) do what you need it to. ~X |
In response to Xooxer
|
|
Xooxer wrote:
That would be a seperate operation alltogether. I assumed that you had a set deck, like in Una, or Spades, or whatever... So like under obj card monster New() list+=monster is that the idea? |
In response to Air _King
|
|
then i would have to pick what cards would be in the list, but I want the cards in the list to be randomly generated. Oh Well. The list would represent the deck. For normal playing cards, the deck isn't random--the same 54 cards are always in there. See LummoxJR's example in this thread. On the other hand, if you're trying to do a CCG, you just build a random deck out of master lists of common/uncommon/rare cards. |
Generally, you can get a randomized result by using rand(), pick(), etc. If you are trying to simulate cards, I suggest you just assign them to a list, use pick to select them (when drawn or whatever), the move the "card" out of the list.
-James