Chapter 7. Bin Builder Class

Table of Contents

Overview
Algorithms
Design
Constructors
Methods
Deliverables

This is a rather long chapter, which describes a number of design considerations surrounding Outcome, Bin and Wheel. The second section presents a number of algorithms to group Outcomes based on the geometry of the table. These algorithms are presented at a high level, leaving much of the detailed design to the student.

Overview

It is clear that enumerating each Outcome in the 38 Bins is a tedious undertaking. Most Bins contain about fourteen individual Outcomes. It is often helpful to create a class that is used to build an instance of another class. This is a design pattern sometimes called a Builder. We'll design an object that builds the various Bins and assigns them to the Wheel. This will fill the need left open in the design of the Wheel class.

Additionally, we note that the complex algorithms to construct the Bins are only tangential to the operation of the Wheel object. While not essential to the design of the Wheel class, we find it is often helpful to segregate these rather complex builder methods into a separate class.

The BinBuilder class will have a method that enumerates the contents of each of the 36 number Bins, building the individual Outcome instances. We can then assign these Outcome objects to the Bins of a Wheel instance. We will use a number of steps to create the various types of Outcomes, and depend on the Wheel to assign each Outcome object to the correct Bin.

Looking at the layout of a Roulette table gives us a number of geometric rules for determining the various Outcomes that are combinations of individual numbers. These rules apply to the numbers from one to thirty-six. A different -- and much simpler -- set of rules applies to 0 and 00. First, we'll survey the table geometry, then we'll develop specific algorithms for each kind of bet.

  • Split Bets. Each number is adjacent to two, three or four other numbers. The four corners (1, 3, 34, and 36) only participate in two split bets. The center column of numbers (5, 8, 11, ..., 32) each participate in four split bets. The remaining “edge” numbers participate in three split bets. While this is moderately complex, the bulk of the layout (from 4 to 32) can be handled with a simple rule to distinguish the center column from the edge columns. The ends (1, 2, 3, 34, 35 and 36) are a little more complex.

  • Street Bets. Each number is a member of one of the twelve street bets.

  • Corner Bets. Each number is a member of one, two or four corner bets. As with split bets, the bulk of the layout can be handled with a simple rule to distinguish the column, and hence the “corners”. A number in the center column (5, 8, 11, ..., 32) is a member of four corners. At the ends, 1, 3, 34, and 36, are members of just one corner. All of the remaining numbers are along an edge and are members of two corners.

  • Line Bets. Six numbers comprise a line; each number is a member of one or two lines. The ends (1, 2, 3 and 34, 35, 36) are each part of a single line. The remaining 10 rows are each part of two lines.

  • Dozen Bets. Each number is a member of one of the three dozens. The three ranges are from 1 to 12, 13 to 24 and 25 to 36, making it very easy to associate numbers and ranges.

  • Column Bets. Each number is a member of one of the three columns. Each of the columns has a number numeric relationship. The values are 3c+1, 3c+2, and 3c+3, where c varies from 0 to 11.

  • The Even-Money Bets. These include Red, Black, Even, Odd, High, Low. Each number has three of the six possible even money Outcomes. An easy way to handle these is to create the 6 individual Outcome instances. For each number, n, individual if-statements can be used to determine which of the Outcome objects are associated with the given Bin.

The Bins for zero and double zero can easily be enumerated. Each bin has a straight number bet Outcome, plus the Five Bet Outcome (00-0-1-2-3, which pays 6:1).

One other thing we'll probably want are handy names for the various kinds of odds. While can define an Outcome as Outcome( "Number 1", 35 ), this is a little opaque. A slightly nicer form is Outcome( "Number 1", RouletteGame.StraightBet ). These are specific to a game, not general features of all Outcomes. We haven't designed the game yet, but we can provide a stub class with these these outcome odds definitions.