Warning, file /sdk/codevis/project_tests/bjg_wrong_cmake/groups/bjg/bjgc/bjgc_dealertable.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // bjgc_dealertable.cpp                                               -*-C++-*-
0002 #include <bjgc_dealertable.h>
0003 
0004 #include <iomanip>
0005 #include <ostream>
0006 
0007 // STATIC HELPER FUNCTIONS
0008 static void printDealerColumnLines(std::ostream& stream)
0009 {
0010     stream << "____ "; // card column
0011 
0012     for (int i = 0; i < bjgb::DealerCount::k_NUM_FINAL_COUNTS; ++i) {
0013         stream << "_________ ";
0014     }
0015 
0016     stream << '\n';
0017 }
0018 
0019 namespace bjgc {
0020 
0021 // -----------------
0022 // class DealerTable
0023 // -----------------
0024 
0025 // MANIPULATORS
0026 void DealerTable::clearRow(int hand)
0027 {
0028     assert(0 <= hand);
0029     assert(hand < bjgb::State::k_NUM_STATES);
0030 
0031     for (int i = 0; i < bjgb::DealerCount::k_NUM_FINAL_COUNTS; ++i) {
0032         prob(hand, i) = 0.0;
0033     }
0034 }
0035 
0036 void DealerTable::reset()
0037 {
0038     for (int j = 0; j < bjgb::State::k_NUM_STATES; ++j) {
0039         for (int i = 0; i < bjgb::DealerCount::k_NUM_FINAL_COUNTS; ++i) {
0040             prob(j, i) = -9999.99;
0041         }
0042     }
0043 }
0044 
0045 } // namespace bjgc
0046 
0047 // FREE OPERATORS
0048 std::ostream& bjgc::operator<<(std::ostream& stream, const DealerTable& table)
0049 {
0050     const int k_COL_WID = 9; // change long underline to match
0051 
0052     //         =========_
0053     stream << "HAND "
0054               "   17     "
0055               "   18     "
0056               "   19     "
0057               "   20     "
0058               "   21     "
0059               "   BJ     "
0060               "  OVER    "
0061               "\n";
0062 
0063     printDealerColumnLines(stream);
0064 
0065     for (int j = bjgb::State::k_NUM_STATES - 1; j >= 0; --j) {
0066         stream << ' ' << std::setw(2) << bjgb::State::stateId2String(j) << ": ";
0067 
0068         for (int i = 0; i < bjgb::DealerCount::k_NUM_FINAL_COUNTS; ++i) {
0069             stream << std::setw(k_COL_WID) << table.prob(j, i) << ' ';
0070         }
0071         stream << '\n';
0072 
0073         if (bjgb::State::e_HZR == j || bjgb::State::hard(2) == j || bjgb::State::pair(1) == j) {
0074             printDealerColumnLines(stream);
0075         }
0076     }
0077 
0078     printDealerColumnLines(stream);
0079 
0080     return stream;
0081 }