cards is python 3 module that simulates a deck of cards. It's main feature is realShuffle()
which attempts to simulate human shuffling. It is available under the MIT License.
to create a Deck:
from cards import Deck, Card
deck = Deck() #creates a new standard Deck
#or
deck = Deck(cards=tuple_of_cards) #creates a deck from a Card array
to create a card:
from cards import Card
card = Card(Card.ACE,Card.SPADES)
#or
card = Card(2,Card.SPADES)
for more, check out the wiki
realshuffle() tries to simulate a riffle shuffle
realShuffle() uses 3 constants:
CUT_ERROR = 10
SHUFFLE_START_ERROR = 4
SHUFFLE_ERROR = 1
CUT_ERROR
: this is how far from the middle the deck it cut. 3 ±randoms are averaged for the used result.
SHUFFLE_START_ERROR
: this is how many cards can be dropped initially. it is a random range.
SHUFFLE_ERROR
: this is how many cards are dropped each time. a random between 1 and SHUFFLE_ERROR
+1.