123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|460|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> Card shuffling?

Thu, 15 Feb 2018, 13:42
spinal

Card shuffling?


So I've started working on a solitaire game, however for some reason I seem to have 2 of my '0' cards, in the case of my current gfx, that's the ace of spades.
I wonder if the shuffle routine has something to do with it? Can anyone see some stupidity in the following?



-=-=-
Check out my excellent homepage!
Thu, 15 Feb 2018, 13:51
spinal
Found it! (I think)...

should be

I think I was shuffling a non-existing card into the deck...

-=-=-
Check out my excellent homepage!
Thu, 15 Feb 2018, 14:07
GfK
Sounds reasonable.

I'd probably run that For loop multiple times to get extra shufflage. Guessing it's a one shot deal, not every frame, so even if it takes a few millisecs it's no issue.
Thu, 15 Feb 2018, 14:23
Jayenkai
Surprisingly, I've found that this sort of shuffle works best if done only once. Since it's shuffling every single card in the deck, it's not like a human shuffle where you miss out clumps at a time.
If you start with a stacked deck and shuffle more than once with this method, you'll see some really freaky shit happening!!

Not really sure why that is.

-=-=-
''Load, Next List!''
Thu, 15 Feb 2018, 16:42
therevillsgames
Constants are your friends...
Fri, 16 Feb 2018, 00:11
spinal
They may be, but it would have still taken me an hour to figure out that I needed NUMBEROFCARDS-1...

-=-=-
Check out my excellent homepage!
Fri, 16 Feb 2018, 01:06
therevillsgames
Should be MAX_CARDS = 51...


Fri, 16 Feb 2018, 01:57
Jayenkai
Eeeuw.. Horrible number complications!!!

I've always been one to hardcode lots of numbers. Doing this framework, I'm really trying my best to switch to using const/define values, but even still..

.. Max_Cards = 52!! It should always be 52 cards!!!

-=-=-
''Load, Next List!''
Fri, 16 Feb 2018, 02:53
therevillsgames
But zero is also a card in Spinal's example, so you will have 53 cards... unless you want to do MAX_CARDS - 1 everywhere which is double eeuw!

I use a list to store my cards anyway, so I do have MAX_CARDS set at 52