File indexing completed on 2025-10-12 04:59:55

0001 // bjgb_state.cpp                                                     -*-C++-*-
0002 #include <bjgb_state.h>
0003 
0004 namespace bjgb {
0005 
0006 // ------------
0007 // struct State
0008 // ------------
0009 
0010 static_assert(11 == State::e_SBJ);
0011 static_assert(12 == State::e_HZR);
0012 static_assert(13 == State::e_S_A);
0013 static_assert(22 == State::e_H_T);
0014 
0015 static_assert(State::e_H_T == State::e_S_A + 9);
0016 static_assert(State::e_PTT == State::e_PAA + 9);
0017 
0018 // CLASS METHODS
0019 const char *State::stateId2String(int stateId)
0020 {
0021     static const char names[k_NUM_STATES][3] = {// soft count
0022                                                 "S1",
0023                                                 "S2",
0024                                                 "S3",
0025                                                 "S4",
0026                                                 "S5",
0027                                                 "S6",
0028                                                 "S7",
0029                                                 "S8",
0030                                                 "S9",
0031                                                 "ST",
0032                                                 "SA",
0033 
0034                                                 // blackjack
0035                                                 "BJ",
0036 
0037                                                 // zero cards
0038                                                 "ZR",
0039 
0040                                                 // one card
0041                                                 "_A",
0042                                                 "_2",
0043                                                 "_3",
0044                                                 "_4",
0045                                                 "_5",
0046                                                 "_6",
0047                                                 "_7",
0048                                                 "_8",
0049                                                 "_9",
0050                                                 "_T",
0051 
0052                                                 // hard count
0053                                                 "02",
0054                                                 "03",
0055                                                 "04",
0056                                                 "05",
0057                                                 "06",
0058                                                 "07",
0059                                                 "08",
0060                                                 "09",
0061                                                 "10",
0062                                                 "11",
0063                                                 "12",
0064                                                 "13",
0065                                                 "14",
0066                                                 "15",
0067                                                 "16",
0068                                                 "17",
0069                                                 "18",
0070                                                 "19",
0071                                                 "20",
0072                                                 "21",
0073 
0074                                                 // over
0075                                                 "OV",
0076 
0077                                                 // two identical cards
0078                                                 "AA",
0079                                                 "22",
0080                                                 "33",
0081                                                 "44",
0082                                                 "55",
0083                                                 "66",
0084                                                 "77",
0085                                                 "88",
0086                                                 "99",
0087                                                 "TT"};
0088 
0089     assert(0 <= stateId);
0090     assert(stateId < k_NUM_STATES);
0091 
0092     return names[stateId];
0093 }
0094 
0095 } // namespace bjgb