Files Classes Functions Hierarchy
#include <playerGame.h>
Public Member Functions | |
| playerGameSimulate (uintc _nsamples=8000) | |
| void | calculate (double &win, double &loss, uintc dealer0, uintc player0) |
| void | tableCalculateRowPrint (uintc dealer0) |
| void | tableCalculatePrint () |
| void | calculateHit (double &win, double &loss, uintc dealer0, uintc player0) |
| void | tableCalculateHitRowPrint (uintc dealer0) |
| void | tableCalculateHitPrint () |
Public Attributes | |
| uint | nsamples |
Definition at line 55 of file playerGame.h.
| playerGameSimulate::playerGameSimulate | ( | uintc | _nsamples = 8000 |
) |
Definition at line 167 of file playerGame.cpp.
References hand::hasAce, and hand::value.
Referenced by tableCalculateRowPrint(), and test03().
00173 { 00174 dealerWins = 0; 00175 playerWins = 0; 00176 bet = 1; 00177 00178 hand & dh(deal->hnd); 00179 00180 if (dealer0==1) 00181 { 00182 for (uint i=0; i<nsamples; ++i) 00183 { 00184 player.value = player0; 00185 dh.value = 0; 00186 dh.hasAce = true; 00187 alive = true; 00188 alive_hold(); 00189 } 00190 } 00191 else 00192 { 00193 for (uint i=0; i<nsamples; ++i) 00194 { 00195 player.value = player0; 00196 dh.value = dealer0; 00197 dh.hasAce = false; 00198 alive = true; 00199 alive_hold(); 00200 } 00201 } 00202 00203 loss = (double)dealerWins / (double) nsamples; 00204 win = (double)playerWins / (double) nsamples; 00205 }
Definition at line 117 of file playerGame.cpp.
References hand::hasAce, and hand::value.
Referenced by tableCalculateHitRowPrint().
00123 { 00124 dealerWins = 0; 00125 playerWins = 0; 00126 bet = 1; 00127 00128 hand & dh(deal->hnd); 00129 00130 if (dealer0==1) 00131 { 00132 for (uint i=0; i<nsamples; ++i) 00133 { 00134 player.value = player0; 00135 dh.value = 0; 00136 dh.hasAce = true; 00137 alive = true; 00138 00139 alive_play(); 00140 if (alive) 00141 alive_hold(); 00142 } 00143 } 00144 else 00145 { 00146 for (uint i=0; i<nsamples; ++i) 00147 { 00148 player.value = player0; 00149 dh.value = dealer0; 00150 dh.hasAce = false; 00151 alive = true; 00152 00153 alive_play(); 00154 if (alive) 00155 alive_hold(); 00156 } 00157 } 00158 00159 loss = (double)dealerWins / (double) nsamples; 00160 win = (double)playerWins / (double) nsamples; 00161 }
| void playerGameSimulate::tableCalculateHitPrint | ( | ) |
Definition at line 224 of file playerGame.cpp.
References tableCalculateHitRowPrint().
Referenced by test05().
00225 { 00226 for (uint k=1; k<=10; ++k) 00227 tableCalculateHitRowPrint(k); 00228 }
| void playerGameSimulate::tableCalculateHitRowPrint | ( | uintc | dealer0 | ) |
Definition at line 208 of file playerGame.cpp.
References calculateHit().
Referenced by tableCalculateHitPrint().
00209 { 00210 double win; 00211 double loss; 00212 00213 //cout << "(dealer0,player)=<dealer win,player win>" << endl; 00214 cout << "(dealer0,player)=<dealer win,player win>" << endl; 00215 00216 for (uint i=7; i<19; ++i) 00217 { 00218 calculateHit(win,loss,dealer0,i); 00219 //cout << "(" << dealer0 << "," << i << ")=<" << loss << "," << win << ">" << endl; 00220 cout << "(" << dealer0 << "," << i << ")=<" << loss << "," << win << ">" << endl; 00221 } 00222 }
| void playerGameSimulate::tableCalculatePrint | ( | ) |
Definition at line 249 of file playerGame.cpp.
References tableCalculateRowPrint().
Referenced by test04().
00250 { 00251 for (uint k=1; k<=10; ++k) 00252 tableCalculateRowPrint(k); 00253 }
| void playerGameSimulate::tableCalculateRowPrint | ( | uintc | dealer0 | ) |
Definition at line 233 of file playerGame.cpp.
References calculate().
Referenced by tableCalculatePrint().
00234 { 00235 double win; 00236 double loss; 00237 00238 //cout << "(dealer0,player)=<dealer win,player win>" << endl; 00239 cout << "(dealer0,player)=<dealer win,player win>" << endl; 00240 00241 for (uint i=12; i<21; ++i) 00242 { 00243 calculate(win,loss,dealer0,i); 00244 //cout << "(" << dealer0 << "," << i << ")=<" << loss << "," << win << ">" << endl; 00245 cout << "(" << dealer0 << "," << i << ")=<" << loss << "," << win << ">" << endl; 00246 } 00247 }
Definition at line 59 of file playerGame.h.
1.5.8