Files Classes Functions Hierarchy
00001 #ifndef PLAYERGAME_H 00002 #define PLAYERGAME_H 00003 00004 #include <hand.h> 00005 #include <deck.h> 00006 #include <dealer.h> 00007 00008 class playerGame 00009 { 00010 public: 00011 00012 // The deck of cards. 00013 deck * cards; 00014 // The dealer. 00015 dealer * deal; 00016 // The players hand, the player is this whole class. 00017 hand player; 00018 00019 // Tracking the dealers wins. 00020 uint dealerWins; 00021 // Tracking the players wins. 00022 uint playerWins; 00023 // The size of the bet can change during play. Whoever wins has 00024 // the bet added to their total wins. 00025 uint bet; 00026 00027 // There are two states : alive and not alive. 00028 // The game is a state machine so only call the functions alive_... when 00029 // alive is true. Similarly call notalive_... when alive is false. 00030 bool alive; 00031 00032 // One card is delt to the player and dealer. 00033 void notalive_dealCards(); 00034 00035 00036 // The player sits on their current hand and then dealer plays. 00037 void alive_hold(); 00038 // The player draws another card to either go bust or better their position. 00039 void alive_play(); 00040 // The bet is doubled by the player and a normal play occures. 00041 void alive_doubleAndPlay(); 00042 00043 //void printGameState(); 00044 //void menu(); 00045 00046 // Constructor - starts game in notalive state. 00047 playerGame(); 00048 00049 // Destructor 00050 ~playerGame(); 00051 00052 }; 00053 00054 00055 class playerGameSimulate : public playerGame 00056 { 00057 public: 00058 00059 uint nsamples; 00060 00061 playerGameSimulate( uintc _nsamples=8000 ); 00062 00063 // The player stands and the dealer plays. 00064 void calculate 00065 ( 00066 double & win, double & loss, 00067 uintc dealer0, // 1..10 where 1 is an ace. 00068 uintc player0 00069 ); 00070 // Use the calculate(...) routine to have the dealer fixed 00071 // and vary the players position 12..20 . 00072 void tableCalculateRowPrint(uintc dealer0); 00073 // Apply tableCalculateRowPrint(...) for dealer 1..10 00074 void tableCalculatePrint(); 00075 00076 00077 // The calculateHit routine is like a derivative. It it one 00078 // timestep away from the future. 00079 00080 // From this position the player hits and stands. 00081 // eg player on 17 and dealer has 10, what are the chances 00082 // of winning and loosing if the player hits. 00083 void calculateHit 00084 ( 00085 double & win, 00086 double & loss, 00087 uintc dealer0, // 1..10 where 1 is an ace. 00088 uintc player0 00089 ); 00090 // Vary the player positions 7..18. 00091 void tableCalculateHitRowPrint(uintc dealer0); 00092 // Apply tableCalculateHitRowPrint(...) for dealer 1..10 00093 void tableCalculateHitPrint(); 00094 00095 }; 00096 00097 00098 #endif 00099 00100
1.5.8