Skip to main content

Simulate Human Card Shuffling Techniques for use with Python Lists

Project description

A simple python module that is meant to simulate the action of shuffling a python List as if it were a deck of cards.

Types

Riffle

http://en.wikipedia.org/wiki/Shuffling#Riffle

Predictable behaviours that make a human riffle shuffle imperfect

Once a deck of cards is divided to each hand, the amount of cards in each hand is not (likely) equal. As each thumb releases from it’s half of the deck, sometimes more than one card drops from a single hand at a time. As the deck in each hand gets more and more thin, the probability of larger chucks of cards dropping from each hand increases.:

shuffle.riffle(List original[, int shuffles])

Overhand

http://en.wikipedia.org/wiki/Shuffling#Stripping_or_overhand

Predictable behaviours that make a human overhand shuffle imperfect

Random amounts of cards (chunks) are taken from the top and placed placed in the opposite hand in reverse order (retaining the order within each chunk):

shuffle.overhand(List original[, int shuffles])

Mongean

http://en.wikipedia.org/wiki/Shuffling#Mongean_shuffle

A very predictable shuffle, alternating placing the top card on the bottom/top of the new deck.:

shuffle.mongean(List original[, int shuffles])

Pile

http://en.wikipedia.org/wiki/Shuffling#Pile_shuffle

Predictable shuffle, dealing items into N piles and then rejoining the piles.:

shuffle.pile(List original, int piles[, int shuffles])

Installation

pip install shuffle

Or

git clone git://github.com/jondavidjohn/Card-Shuffle-for-Python.git shuffle
cd ./shuffle
sudo python setup.py install

Linux Users - Make sure you have the python-dev package installed.

Usage

import shuffle
riffled_list = shuffle.riffle(original_list, 3)  # riffles the list 3 times
overhanded_list = shuffle.overhand(original_list, 2)  #overhand's the list 2 times
mongeaned_list = shuffle.mongean(original_list, 5)  #mongean shuffle 5 times
piled_list = shuffle.pile(original_list, 3, 6)  #pile shuffle, using 3 piles, 6 times

Project details


Release history Release notifications | RSS feed

This version

0.9

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shuffle-0.9.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file shuffle-0.9.tar.gz.

File metadata

  • Download URL: shuffle-0.9.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for shuffle-0.9.tar.gz
Algorithm Hash digest
SHA256 df599946faa144baf84e141dbf99da75421617fdf1f82d60374a1f3d01b273b6
MD5 bfc8ed18c4d65abf3c241fe1292b19b0
BLAKE2b-256 cd84c643f957e2ec26a784b931c2cf9896c1a2b0093dffc29d701cb2062581e5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page