BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Ripple Shuffle"
, by thepict
This code ripple shuffles a pack of cards
Code
; it has been mathematically proven that the best way to shuffle a pack of cards is the ripple shuffle. ; this program takes a pack of cards in oerder and ripple shuffles them 10 times ; first we define 52 cards a$="AH 2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH AC 2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC AD 2D 3D 4D 5D 6D 7D 8D 9D TD JD QD KD AS 2S 3S 4S 5S 6S 7S 8S 9S TS JS QS KS " ; start a loop - how many times should we ripple shuffle the pack? For n=1 To 10 ; create an empty string to put the shuffled cards into b$="" ; then we decide where to split them - very roughly in the middle split=Rnd(20,32) split=split*3 ; then we split the pack into two piles p$=Left$(a$,split) q$=Right$(a$,156-split) ; repeat the next two steps until all the cards are in the new pack Repeat ; pick a number from 1 to 3 num=Rnd(1,3) ; check there are enough cards in pile two - if not adjust number If Len(q$)
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations