: : : One way, that isn't as ellegant as the post before me, is to do a reverse sorting function, set up the cards in order, then run a loop a hundred times that swaps two cards. The result should be more real, couse when I sort, I don't do it good, and this algorithm is also bad...
: : :
: : : The one and only
Niklas Ulvinge aka IDK
: : :
: : : Your card shuffling method is fine, except for the part that says, "set up the cards in order." If you do this, then the final order of the cards after looping 100 times, will be shuffled, but every time you run the program you will get the same shuffled order. If the order or the cards change during the game, then just apply your loop 100 times logic to whatever order they are in. Then it will work.
: :
: : Because of the RANDOMIZE TIMER instruction in my method, you will get different random numbers on each program run. The RND instruction uses the TIMER to select random numbers. The RANDOMIZE TIMER insures that they be different.
: : *****
: :
: :
: I wrote: ,then run a loop a hundred times that swaps two cards.
: I didn't say the swaping process shouldn't be random.
:
: The one and only
Niklas Ulvinge aka IDK
:
:
Guys:
for n=1 to 52 do {
tempbyt=rnd(52)+1;
tempcard=card[n];
card[n]=card[tempbyt];
card[tempbyt]:=tempcard
}
As you can see it is not in BASIC and not in any other language though I dunno what elements you would like to implement in the prog, and the way you want to do it. I hope you find it flexible enough and that you are able to convert it into BASIC easily.
****************
Any questions? Just ask!
GAASHIUS