RichardBerg : FirstProgrammerManual

FavoriteLinksCondensed :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings
9/12/03

Our program has already grown pretty complex, so I'll give an overview of the various class families and leave detailed documentation to in-code comments (look in the superclass .h files, especially).

card.h
- Card class, which is little more than a struct for holding values (0-51) that know their rank, suit, etc.
- Shoe class represents the stack of decks. Shuffling it initializes lots of Cards up to the specified depth.

bjhand.h
- BJHand class is a smart wrapper for Hand, a simple vector of Cards. It knows how to store multiple subhands (resulting from splits) in a Hand, and get card & full hand values gracefully.

strategy.h
- Strategy is an abstract class. The interface has two functions for adding to its history of seen cards (the rationale behind each is kind of complex, see the code), and a mechanism for getting recommendations given a hand situation. Strategies also know how to print a short description of themselves via the
operator.

rules.h
- Rules is another abstract class. The interface returns a set of flags (defined therein, with silly helper functions) telling you what choices are possible given a hand situation. It also does win/loss calculations, and can print itself like Strategy.

player.h
- Player is/was an abstract class, but the functionality I needed in its derived class Gambler couldn't really be represented by the virtual methods I initially came up with in the Bowler era, so it has junk tacked on that looks out of place. Gambler itself is rather well-behaved, though -- it doesn't actually do anything other than print its score, but it's still useful for wrapping a Strategy.

game.h
- Game is another abstract class left over from Bowler, whose fate fared much better. The superclass methods, which include the main loop of execution, are unchanged. The BlackjackGame subclass is quite similar to BowlingGame, with a little twist found in its inner loop: through the magic of well-planned (lucky?) BJHand methods and a bit of recursion, splits are handled by just two lines in processSubHand. I think.

Exception, Random, and PromptUser are very small helper classes entirely unchanged from Bowling. Everything else is a subclass of Strategy or Rules.


Back to BlackjackDesign

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.4
Page was generated in 1.0981 seconds