Chapter 18. Player Cancellation

Table of Contents

Overview
Design
Fields
Constructors
Methods
Deliverables

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

Overview

One method for tracking the lost bets is called the “cancellation” system or the “Labouchere” system. The player starts with a betting budget allocated as a series of numbers. The usual example is 1, 2, 3, 4, 5, 6. Each bet is sum of the first and last numbers in the last. In our example, the end values of 1+6 leads the player to bet 7. When the player wins, they cancel the two numbers used to make the bet. In the event that all the numbers are cancelled, the player resets the sequence of numbers and starts again. 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. This adds the loss to the amount bet to assure that the next winning bet both recoups the most recent loss and provides a gain. Multiple winning bets will recoup multiple losses, supplemented with small gains.

Here's an example of the cancellation system using 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 a list of individual bet amounts. This list grows and shrinks; when it is empty, the player leaves the table. We can keep a List of individual bet amounts. The total bet will be the first and last elements of this list. Wins will remove elements from the collection; losses will add elements to the collection. Since we will be accessing elements in an arbitrary order, we will want to use an ArrayList. We can define the player's state with a simple list of values.