PyBaccarat
visit the ministry of silly walks
Public Member Functions | List of all members
pybaccarat.playingcards.Shoe Class Reference

The Shoe class represents a playing card shoe. More...

Inheritance diagram for pybaccarat.playingcards.Shoe:

Public Member Functions

def __init__ (self, number_decks=None)
 Create a shoe of a specified number of decks of playing cards. More...
 
def reset (self)
 Reset the shoe to start a new shoe. More...
 
def shuffle (self)
 Shuffle cards in the shoe. More...
 
def set_cut_card (self, position)
 Assign the cut card position in the shoe. More...
 
def cut_card_seen (self)
 Return has the cut card been seen? More...
 
def deal (self)
 Deal a Card from the Shoe. More...
 
def discard_adjust_baccarat (self, type)
 The discard pile is our shoe prior to the next_card index. More...
 
def save_shoe (self, filespec)
 Save this shoe to a disk file specified.
 
def load_shoe (self, filespec)
 Load a shoe from a disk file specified.
 
def __init__ (self, number_decks=None)
 Create a shoe of a specified number of decks of playing cards. More...
 
def reset (self)
 Reset the shoe to start a new shoe. More...
 
def shuffle (self)
 Shuffle cards in the shoe. More...
 
def set_cut_card (self, position)
 Assign the cut card position in the shoe. More...
 
def cut_card_seen (self)
 Return has the cut card been seen? More...
 
def deal (self)
 Deal a Card from the Shoe. More...
 
def discard_adjust_baccarat (self, type)
 The discard pile is our shoe prior to the next_card index. More...
 
def save_shoe (self, filespec)
 Save this shoe to a disk file specified.
 
def load_shoe (self, filespec)
 Load a shoe from a disk file specified.
 

Detailed Description

The Shoe class represents a playing card shoe.

That is, a device designed to hold a large number of playing cards, and deliver them to a card game as requested.

The Shoe is normally not changed. Once created, it can be reused many times. Normal operation would use the reset() method to start a new shoe process. The cards within the shoe are shuffled and reused. But once created, a shoe will normally remain until end of game(s).

Example usage:

# create an 8 deck shoe for playing Baccarat
shoe = Shoe(8)
shoe.shuffle()
shoe.set_cut_card(-14)
# deal one card to player and one card to banker
player1 = shoe.deal()
banker1 = shoe.deal()
See also
Card

Constructor & Destructor Documentation

◆ __init__() [1/2]

def pybaccarat.playingcards.Shoe.__init__ (   self,
  number_decks = None 
)

Create a shoe of a specified number of decks of playing cards.

The default value for number_decks is one.

Different card games use a shoe composed of a different number of decks of cards. Normally a game of Baccarat would use 8 decks. Blackjack might use 1 or 2 or 6. War would use 6.

Example usage:

import playingcards
shoe = playingcards.Shoe(8) #create 8 deck shoe
shoe.reset()
shoe.shuffle()

An alternative syntax has been added. That allows you to create a shoe based on the constructor being passed an array of Cards. That is, each element of the array must be of type Card class. This will allow you to create your own unique shoe.

Example usage:

# Create a shoe that consists of only 6 cards specified below.
# In this case we are running a blackjack tournament, so a special
# deck with just these 6 cards are shuffled and dealt out to assign
# tournament starting positions for a 6 spot tournament table.
import playingcards
shoe = playingcards.Shoe([ Card(1,'s'), Card(2,'s'),
Card(3,'s'), Card(4,'s'), Card(5,'s'), Card(6,'s') ])
shoe.reset()
shoe.shuffle()
for i in range(6):
print(shoe.deal())
Parameters
selfthis object pointer reference
number_decksinteger number of decks. The default value is 1. Legal range is 1 to 12. The alternate constructor will allow you to pass in an arraay of Cards instead of just a single integer for the number of decks.
Exceptions
ValueErrorIf the input parameter number_decks is not a legal integer.
Todo:
need a finite limit to number_decks

◆ __init__() [2/2]

def pybaccarat.playingcards.Shoe.__init__ (   self,
  number_decks = None 
)

Create a shoe of a specified number of decks of playing cards.

The default value for number_decks is one.

Different card games use a shoe composed of a different number of decks of cards. Normally a game of Baccarat would use 8 decks. Blackjack might use 1 or 2 or 6. War would use 6.

Example usage:

import playingcards
shoe = pybaccarat.playingcards.Shoe(8) #create 8 deck shoe
shoe.reset()
shoe.shuffle()

An alternative syntax has been added. That allows you to create a shoe based on the constructor being passed an array of Cards. That is, each element of the array must be of type Card class. This will allow you to create your own unique shoe.

Example usage:

# Create a shoe that consists of only 6 cards specified below.
# In this case we are running a blackjack tournament, so a special
# deck with just these 6 cards are shuffled and dealt out to assign
# tournament starting positions for a 6 spot tournament table.
shoe = pybaccarat.playingcards.Shoe([ Card(1,'s'), Card(2,'s'),
Card(3,'s'), Card(4,'s'), Card(5,'s'), Card(6,'s') ])
shoe.reset()
shoe.shuffle()
for i in range(6):
  print(shoe.deal())
Parameters
selfthis object pointer reference
number_decksinteger number of decks. The default value is 1. Legal range is 1 to 12. The alternate constructor will allow you to pass in an arraay of Cards instead of just a single integer for the number of decks.
Exceptions
ValueErrorIf the input parameter number_decks is not a legal integer.
Todo:
need a finite limit to number_decks

Member Function Documentation

◆ cut_card_seen() [1/2]

def pybaccarat.playingcards.Shoe.cut_card_seen (   self)

Return has the cut card been seen?

Example usage:

import playingcards
shoe = new playingcards.Shoe()
shoe.set_cut_card(1)
# Query before first card dealt
print(shoe.cut_card_seen()) #False
card1 = shoe.deal()
# Query after first card dealt
print(shoe.cut_card_seen()) #True
Parameters
selfthis object pointer reference
Returns
True if yes, False if no.
See also
set_cut_card

◆ cut_card_seen() [2/2]

def pybaccarat.playingcards.Shoe.cut_card_seen (   self)

Return has the cut card been seen?

Example usage:

import playingcards
shoe = new playingcards.Shoe()
shoe.set_cut_card(1)
# Query before first card dealt
print(shoe.cut_card_seen()) #False
card1 = shoe.deal()
# Query after first card dealt
print(shoe.cut_card_seen()) #True
Parameters
selfthis object pointer reference
Returns
True if yes, False if no.
See also
set_cut_card

◆ deal() [1/2]

def pybaccarat.playingcards.Shoe.deal (   self)

Deal a Card from the Shoe.

Example usage:

import playinycards
shoe = playinycards.Shoe()
#shoe.shuffle() #no shuffle here
card = shoe.deal()
print(card) #displays 'Ac'
# Since a brand new shoe was not shuffled I know ace of clubs is first.
Parameters
selfthis object pointer reference
Returns
the next card from the Shoe, or None if no card is available.

◆ deal() [2/2]

def pybaccarat.playingcards.Shoe.deal (   self)

Deal a Card from the Shoe.

Example usage:

import playinycards
shoe = playinycards.Shoe()
#shoe.shuffle() #no shuffle here
card = shoe.deal()
print(card) #displays 'Ac'
# Since a brand new shoe was not shuffled I know ace of clubs is first.
Parameters
selfthis object pointer reference
Returns
the next card from the Shoe, or None if no card is available.

◆ discard_adjust_baccarat() [1/2]

def pybaccarat.playingcards.Shoe.discard_adjust_baccarat (   self,
  type 
)

The discard pile is our shoe prior to the next_card index.

Some games will discard the used cards in a specific manor (i.e. Baccarat). They do that so that when a player complains about the last hand after the dealer has swept the cards away, the pit card back the cards out of the discard pile to show the prior hands.

2P2B: deal: p1 b1 p2 b2 = -4 -3 -2 -1 ^-----—^ swap -4 -1 ^–^ swap -2 -1 sweep: b2 b1 p1 p2(top) 3P2B: deal: p1 b1 p2 b2 p3 ^-----—^ swap -5 -2 ^–^ swap -3 -2 sweep: b2 b1 p1 p2 p3(top) 2P3B: deal: p1 b1 p2 b2 b3 ^--------—^ swap -5 -1 ^--—^ swap -4 -2 ^–^ swap -3 -2 ^–^ swap -2 -1 sweep: b3 b2 b1 p1 p2(top) 3P3B: deal: p1 b1 p2 b2 p3 b3 ^-----------—^ swap -6 -1 ^--—^ swap -5 -3 ^–^ swap -4 -3 ^--—^ swap -3 -1 ^–^ swap -2 -1 sweep: b3 b2 b1 p1 p2 p3(top)

◆ discard_adjust_baccarat() [2/2]

def pybaccarat.playingcards.Shoe.discard_adjust_baccarat (   self,
  type 
)

The discard pile is our shoe prior to the next_card index.

Some games will discard the used cards in a specific manor (i.e. Baccarat). They do that so that when a player complains about the last hand after the dealer has swept the cards away, the pit card back the cards out of the discard pile to show the prior hands.

2P2B: deal: p1 b1 p2 b2 = -4 -3 -2 -1 ^-----—^ swap -4 -1 ^–^ swap -2 -1 sweep: b2 b1 p1 p2(top) 3P2B: deal: p1 b1 p2 b2 p3 ^-----—^ swap -5 -2 ^–^ swap -3 -2 sweep: b2 b1 p1 p2 p3(top) 2P3B: deal: p1 b1 p2 b2 b3 ^--------—^ swap -5 -1 ^--—^ swap -4 -2 ^–^ swap -3 -2 ^–^ swap -2 -1 sweep: b3 b2 b1 p1 p2(top) 3P3B: deal: p1 b1 p2 b2 p3 b3 ^-----------—^ swap -6 -1 ^--—^ swap -5 -3 ^–^ swap -4 -3 ^--—^ swap -3 -1 ^–^ swap -2 -1 sweep: b3 b2 b1 p1 p2 p3(top)

◆ reset() [1/2]

def pybaccarat.playingcards.Shoe.reset (   self)

Reset the shoe to start a new shoe.

This method will not shuffle the cards nor assign the cut card position.

import playingcards
shoe = playingcards.Shoe()
shoe.reset()
Parameters
selfthis object pointer reference

◆ reset() [2/2]

def pybaccarat.playingcards.Shoe.reset (   self)

Reset the shoe to start a new shoe.

This method will not shuffle the cards nor assign the cut card position.

import playingcards
shoe = playingcards.Shoe()
shoe.reset()
Parameters
selfthis object pointer reference

◆ set_cut_card() [1/2]

def pybaccarat.playingcards.Shoe.set_cut_card (   self,
  position 
)

Assign the cut card position in the shoe.

Example usage:

import playingcards
shoe = playingcards.Shoe()
shoe.set_cut_card(-14)
Parameters
selfthis object pointer reference
positioninteger index position within the shoe. 0 means at the very start of the shoe. A position of 0 would mean that even before the first card has been dealt the cut card has been seen. The max value is the length of the shoe (the very end). For a 6 deck shoe that would mean a maximum value of 312 (6 times 52). A cut card position at the very end of the shoe would mean the cut card would never be seen. A negative value is allowed and means position from the end of the shoe. So a value of -14 would mean count 14 from the end of the shoe.
Exceptions
ValueErrorIf the input parameter position is not a legal integer value, then throw a ValueError exception.
See also
cut_card_seen()

◆ set_cut_card() [2/2]

def pybaccarat.playingcards.Shoe.set_cut_card (   self,
  position 
)

Assign the cut card position in the shoe.

Example usage:

import playingcards
shoe = playingcards.Shoe()
shoe.set_cut_card(-14)
Parameters
selfthis object pointer reference
positioninteger index position within the shoe. 0 means at the very start of the shoe. A position of 0 would mean that even before the first card has been dealt the cut card has been seen. The max value is the length of the shoe (the very end). For a 6 deck shoe that would mean a maximum value of 312 (6 times 52). A cut card position at the very end of the shoe would mean the cut card would never be seen. A negative value is allowed and means position from the end of the shoe. So a value of -14 would mean count 14 from the end of the shoe.
Exceptions
ValueErrorIf the input parameter position is not a legal integer value, then throw a ValueError exception.
See also
cut_card_seen()

◆ shuffle() [1/2]

def pybaccarat.playingcards.Shoe.shuffle (   self)

Shuffle cards in the shoe.

Uses the standard Python random package shuffle method.

Example usage:

import playingcards
shoe = playingcards.Shoe()
shoe.shuffle()
Parameters
selfthis object pointer reference
See also
random.shuffle()
Todo:
Find a way to attach a user's shuffle method instead of our own default.

◆ shuffle() [2/2]

def pybaccarat.playingcards.Shoe.shuffle (   self)

Shuffle cards in the shoe.

Uses the standard Python random package shuffle method.

Example usage:

import playingcards
shoe = playingcards.Shoe()
shoe.shuffle()
Parameters
selfthis object pointer reference
See also
random.shuffle()
Todo:
Find a way to attach a user's shuffle method instead of our own default.

The documentation for this class was generated from the following file: