Table of Contents
This section will introduce a simple subclass of
Player who bets at random.
One possible betting strategy is to bet completely randomly. This serves as an interesting benchmark for other betting strategies.
We'll write a subclass of Player which
steps through all of the bets available on the
Wheel, selecting one or more of the available
outcomes at random. This Player, like others,
will have a fixed initial stake and a limited amount of time to
play.
The Wheel class can provide an
Iterator over the collection of
Bin instances. We could revise
Wheel to provide a
binIterator method that we can use to return
all of the Bins. From each
Bin, we will need an iterator we can use to
return all of the Outcomes.
To collect a list of all possible
Outcomes, we would use the following
algorithm:
Procedure 16.1. Locating all Outcomes
Empty List of Outcomes. Create an empty list of all
Outcomes,
allOC.
Get Bin Iterator. Get the Iterator from the Wheel
that lists all Bins.
For Each Bin
Get Outcome Iterator. Get the Iterator that lists all
Outcomes.
For Each Outcome
Save Outcome. Save a reference to each
Outcome in the list of all
known outcomes, allOC.
To place a random bet, we would use the following algorithm: