Cancellation Player Class

This section will describe a player who has a complex internal state that can be modeled using existing library classes.

In Cancellation Player Analysis we’ll look at what this player does.

We’ll turn to how the player works in PlayerCancellation Design.

In Cancellation Player Deliverables we’ll enumerate the deliverables for this player.

Cancellation Player Analysis

One method for tracking the lost bets is called the “cancellation” system or the “Labouchere” system.

The bets are designed around an ascending sequence of values, [1, 2, 3, 4, 5, 6]. The sum, 21, is the total budget. Each bet will be a multiple of the table minimum, b. The core principle is to bet on the sum of the numbers at the end of the sequence.

In this example, the end values of of the sequence are 1+6, leading the player to bet 7 \times b.

On a win, the player cancels the two numbers used to make the bet. In the event that all the numbers are cancelled, the player has doubled their money, and can retire from the table happy.

For each loss, however, the player adds the amount of the bet to the end of the sequence; this is a loss to be recouped. The next bet is designed to recoups the most recent loss and provide a small gain. Multiple winning bets will recoup multiple losses, supplemented with small gains.

Example. Here’s an example of the cancellation system using a budget of 21 times the base bet, decomposed to [1, 2, 3, 4, 5, 6].

  1. Bet 1+6. A win. Cancel 1 and 6, leaving [2, 3, 4, 5].

  2. Bet 2+5. A loss. Add 7, leaving [2, 3, 4, 5, 7].

  3. Bet 2+7. A loss. Add 9, leaving [2, 3, 4, 5, 7, 9].

  4. Bet 2+9. A win. Cancel 2 and 9, leaving [3, 4, 5, 7].

  5. Next bet will be 3+7.

State. The player’s state is the list of multipliers. This list grows and shrinks; when it is empty, the player leaves the table. The bet amount will be the first and last elements of this list. Wins will remove elements from the collection; losses will add elements to the collection.

Note

Alternative Budgets

The system of betting shown above can involve large numbers, since the betting starts at 7 \times the table minimum. The numbers are smaller when working with a list of smaller numbers.

Consider a starting list of [1, 1]. The bet is 2. A win cancels both numbers and resets the betting.

A loss, however, appends the bet to the sequence, leaving us with [1, 1, 2]. The next bet becomes 3.

A win will leave one uncancelled value, this can be dropped, the list reset to [1, 1], and betting can resume.

A subsequent loss appends 3, leaving us with [1, 1, 2, 3]. The next bet becomes 4.

Almost any starting sequence will work as long as the values are positive integers.

PlayerCancellation Design

class PlayerCancellation

PlayerCancellation uses the cancellation betting system. This player allocates their available budget into a sequence of bets that have an accelerating potential gain as well as recouping any losses.

Fields

PlayerCancellation.sequence

This List keeps the bet amounts; wins are removed from this list and losses are appended to this list. THe current bet is the first value plus the last value.

PlayerCancellation.outcome

This is the player’s preferred Outcome instance.

Constructors

PlayerCancellation.__init__(self, table: Table) → None

This uses the PlayerCancellation.resetSequence() method to initialize the sequence of numbers used to establish the bet amount. This also picks a suitable even money Outcome, for example, black.

Parameters

table (Table) – The Table object which will accept the bests.

Methods

PlayerCancellation.resetSequence(self) → None

Puts the initial sequence of six values, [1, 2, 3, 4, 5, 6] into the sequence variable. The sequence [1, 1, 1, 1, 1, 1] will also work, and the bets will be smaller.

PlayerCancellation.placeBets(self) → None

Creates a bet from the sum of the first and last values of sequence and the preferred outcome.

PlayerCancellation.win(self, bet: Bet) → None
Parameters

bet (Bet) – The bet which won

Uses the superclass method to update the stake with an amount won. It then removes the fist and last element from sequence.

PlayerCancellation.lose(self, bet: Bet) → None
Parameters

bet (Bet) – The bet which lost

Uses the superclass method to update the stake with an amount lost. It then appends the sum of the first and list elements of sequence to the end of sequence as a new value.

Cancellation Player Deliverables

There are three deliverables for this exercise.

  • The PlayerCancellation class.

  • A unit test of the PlayerCancellation class. This test should synthesize a fixed list of Outcome instances, Bin s, and calls a PlayerCancellation instance with various sequences of reds and blacks. There are 16 different sequences of four winning and losing bets. These range from four losses in a row to four wins in a row. This should be sufficient to exercise the class and see the changes in the bet amount.

  • An update to the overall Simulator class that uses the PlayerCancellation class.

Looking Forward

In the SevenReds subclass of Player, the state was a simple count. In the Player1326 subclass, the state was a more complex hierarchy of classes. In this case, a built-in list object could maintain the player’s state. In the next chapter we’ll look at one more way to maintain state of a player, using a pair of integer values.