"""Ordered list of face cards.
"""
-DECK = [(c/4, c%4) for c in range(52)]
-"""Cards in the deck are stored as (n,m), where `n` is the rank number
-`n=[0,12]`, and `m` is the suit `m=[0,3]`.
+def new_deck():
+ """Generate a new deck.
-Examples:
- (0,1) is a two of hearts,
- (11,0) is a king of spades,
- (12,3) is an ace of clubs
+ Cards in the deck are stored as `(n,m)`, where `n` is the rank
+ number `n=[0,12]`, and `m` is the suit `m=[0,3]`.
->>> DECK[:5]
-"""
+ Examples:
+ * `(0,1)` is a two of hearts,
+ * `(11,0)` is a king of spades,
+ * `(12,3)` is an ace of clubs
+
+ >>> deck = new_deck()
+ >>> deck[:6]
+ [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1)]
+ >>> [pp_card(c) for c in deck[:6]]
+ ['2s', '2h', '2d', '2c', '3s', '3h']
+ """
+ return [(c/4, c%4) for c in range(52)]
def pp_card(card):
"""Pretty-print a card.
"""
from table import Player, Blinds, Table
-from deck import DECK
+from deck import new_deck
def run(players, blinds, start_stack, hand_limit, tournaments, verbose=False):
for n in xrange(tournaments):
for player in players:
player.cash = start_stack
- table = Table(deck=DECK, players=players, blinds=blinds,
+ table = Table(deck=new_deck(), players=players, blinds=blinds,
verbose=verbose)
while len(table.players) > 1 and table.hand_count < hand_limit:
table.play_round()