CString CWhiteInfoBox::InfoText() { double sym_bblind = p_symbol_engine_tablelimits->bblind(); double sym_sblind = p_symbol_engine_tablelimits->sblind(); double sym_ante = p_symbol_engine_tablelimits->ante(); int sym_lim = p_symbol_engine_gametype->gametype(); CString sym_handnumber = p_handreset_detector->GetHandNumber(); double sym_pot = p_symbol_engine_chip_amounts->pot(); CString result, s; // handnumber if (sym_handnumber != "") { s.Format(" Hand #: %s\n", sym_handnumber); } else { s.Format(" Hand #: -\n"); } result.Append(s); // blinds, game-type CString format_string; if (IsInteger(sym_sblind) && IsInteger(sym_bblind)) { // Display as integer numbers format_string = " %s %.0f/%.0f/%.0f\n"; } else { // Fractional nunbers: use 2.00 digits format_string = " %s %.2f/%.2f/%.2f\n"; } s.Format(format_string, p_symbol_engine_gametype->GetGameTypeAsString(), sym_sblind, sym_bblind, p_symbol_engine_tablelimits->bigbet()); result.Append(s); // ante if (sym_ante != 0) { s.Format(" Ante: %s\n", Number2CString(sym_ante)); result.Append(s); } // Pot s.Format(" Pot: %s\n", Number2CString(sym_pot)); result.Append(s); // logged symbols if (kMaxLogSymbolsForWhiteBox > 0) { result.Append(" "); result.Append(_custom_log_message); } return result; }
void CPreferences::ReadReg(const LPCTSTR registry_key, double *registry_value) { CString value; value = AfxGetApp()->GetProfileString(_preferences_heading, registry_key); if (!value.IsEmpty()) *registry_value = atof(value); write_log(debug_preferences(), "[CPreferences] %s = %s\n", registry_key, Number2CString(*registry_value)); }
CString CParseTreeTerminalNodeNumber::Serialize() { if (_node_type == kTokenNumber) { return Number2CString(_constant_value); } else { // Unhandled note-type, probably new and therefore not yet handled write_log(k_always_log_errors, "[CParseTreeTerminalNode] ERROR: Unhandled node-type %i in serialization of parse-tree\n", _node_type); return ""; } }
void CSymbolEngineRaisersCallers::CalculateRaisers() { _nopponentstruelyraising = 0; if (p_symbol_engine_chip_amounts->call() <= 0.0) { // There are no bets and raises. // Skip the calculations to keep the raischair of the previous round. // http://www.maxinmontreal.com/forums/viewtopic.php?f=156&t=16806 write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] No bet to call, therefore no raises\n"); return; } // Raischair, nopponentstruelyraising, raisbits int first_possible_raiser = FirstPossibleRaiser(); int last_possible_raiser = LastPossibleRaiser(); double highest_bet = LastOrbitsLastRaisersBet(); write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] Searching for raisers from chair %i to %i with a bet higher than %.2f\n", first_possible_raiser, last_possible_raiser, highest_bet); for (int i=first_possible_raiser; i<=last_possible_raiser; ++i) { int chair = i % p_tablemap->nchairs(); double current_players_bet = p_symbol_engine_chip_amounts->currentbet(chair); write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] chair %d bet %.2f\n", chair, current_players_bet); // Raisers are people // * with a higher bet than players before them // * who are still playing, not counting people who bet/fold in later orbits // * either betting/raising postflop or truely raising preflop // (not counting the infamous "blind raisers") if (!p_table_state->_players[chair].HasAnyCards()) { write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] chair %d has no cards.\n", chair); continue; } else if (current_players_bet <= highest_bet) { write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] chair %d is not raising\n", chair); continue; } else if ((p_betround_calculator->betround() == k_betround_preflop) && (current_players_bet <= p_symbol_engine_tablelimits->bblind())) { write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] chair %d so-called \"blind raiser\". To be ignored.\n", chair); continue; } highest_bet = current_players_bet; write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] Opponent %i raising to %s\n", chair, Number2CString(highest_bet)); _raischair = chair; int new_raisbits = _raisbits[BETROUND] | k_exponents[chair]; _raisbits[BETROUND] = new_raisbits; assert(chair != USER_CHAIR); ++_nopponentstruelyraising; } AssertRange(_raischair, k_undefined, k_last_chair); _lastraised[BETROUND] = _raischair; write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] nopponentstruelyraising: %i\n", _nopponentstruelyraising); write_log(preferences.debug_symbolengine(), "[CSymbolEngineRaisersCallers] raischair: %i\n", _raischair); }
double CAutoplayerFunctions::BetSizeForPercentagedPotsizeBet(double decision) { double percentage_0_100 = -100 * decision; write_log(preferences.debug_formula(), "[CAutoplayerFunctions] Calculate f$betsize for %.2f percent potsize\n", percentage_0_100); assert(p_symbol_engine_chip_amounts != NULL); assert(p_symbol_engine_userchair != NULL); assert(p_symbol_engine_userchair->userchair_confirmed()); double betsize = p_table_state->User()->_bet + p_symbol_engine_chip_amounts->call() + (-1 * decision) * (p_symbol_engine_chip_amounts->pot() + p_symbol_engine_chip_amounts->call()); write_log(preferences.debug_formula(), "[CAutoplayerFunctions] f$betsize is %s\n", Number2CString(betsize, 2)); return betsize; }
void CPreferences::SetValue(int index_of_variable, double value) { ENT AssertRange(index_of_variable, 0, k_prefs_last_numerical_value); prefs_numerical_values[index_of_variable] = value; if (IsInteger(value)) { WriteReg(k_registry_keys_for_numerical_values[index_of_variable], int(value)); } else { WriteReg(k_registry_keys_for_numerical_values[index_of_variable], value); } write_log(debug_preferences(), "[CPreferences] %s = %s\n", k_registry_keys_for_numerical_values[index_of_variable], Number2CString(value)); }
CString CParseTreeNode::Serialize() { if (_node_type == kTokenIdentifier) { return _terminal_name; } else if (_node_type == kTokenNumber) { return Number2CString(_constant_value); } else if (TokenIsBracketOpen(_node_type)) { return ("(" + _first_sibbling->Serialize() + ")"); } else if (TokenIsUnary(_node_type)) { assert(_first_sibbling != NULL); return TokenString(_node_type) + "(" + _first_sibbling->Serialize() + ")"; } else if (TokenIsBinary(_node_type)) { assert(_first_sibbling != NULL); assert(_second_sibbling != NULL); return "(" + _first_sibbling->Serialize() + " " + TokenString(_node_type) + " " + _second_sibbling->Serialize() + ")"; } else if (_node_type == kTokenOperatorConditionalIf) { assert(_first_sibbling != NULL); assert(_second_sibbling != NULL); assert(_third_sibbling != NULL); return "(" + _first_sibbling->Serialize() + " ? " + _second_sibbling->Serialize() + " : " + _third_sibbling->Serialize() + ")"; } else if (IsOpenEndedWhenCondition()) { return "WHEN: " + _first_sibbling->Serialize() + "\n" + (_second_sibbling? _second_sibbling->Serialize(): "") // No third sibbling to serialize, because this is the next open-ender // and TWO pointers point to it (one from a normal "when") + "WEND"; } else if (IsWhenConditionWithAction()) { return " WHEN: " + _first_sibbling->Serialize() + "WRETURN: " + (_second_sibbling? _second_sibbling->Serialize(): "") + "\n" // Third sibbling: either next when-condition or next open-ended when-condition + (_third_sibbling? _third_sibbling->Serialize(): ""); } else { // Unhandled note-type, probably new and therefore not yet handled write_log(k_always_log_errors, "[CParseTreeNode] ERROR: Unhandled node-tzpe %i in serialiyation of parse-tree\n", _node_type); return ""; } }
CString CReplayFrame::GeneralInfo() { // Get current time time_t ltime = 0; tm now_time = {0}; char now_time_str[100] = {0}; time(<ime); localtime_s(&now_time, <ime); strftime(now_time_str, 100, "%Y-%m-%d %H:%M:%S", &now_time); CString result; result += "<table border=4 cellpadding=1 cellspacing=1>\n"; // Table title result += "<tr><td>\n"; result += p_table_state->TableTitle()->Title(); result += "</td></tr>\n"; // Session, result += "<tr><td>\n"; result += "Session: "; result += Number2CString(p_sessioncounter->session_id(), 0); result += "</td></tr>\n"; // Frame number result += "<tr><td>\n"; CString next_frame; next_frame.Format("Frame: %06d", _next_replay_frame); result += next_frame; result += "</td></tr>\n"; // Time result += "<tr><td>\n"; result += now_time_str; result += "</td></tr>\n"; // Version result += "<tr><td>\n"; result += "OpenHoldem "; result += VERSION_TEXT; result += "</td></tr>\n"; // Finish table result += "</table>\n"; return result; }
bool CAutoplayer::AnyPrimaryFormulaTrue() { for (int i=k_autoplayer_function_beep; i<=k_autoplayer_function_fold; ++i) { double function_result = p_autoplayer_functions->GetAutoplayerFunctionValue(i); if (i == k_autoplayer_function_betsize) { write_log(preferences.debug_autoplayer(), "[AutoPlayer] AnyPrimaryFormulaTrue(): [%s]: %s\n", k_standard_function_names[i], Number2CString(function_result)); } else { write_log(preferences.debug_autoplayer(), "[AutoPlayer] AnyPrimaryFormulaTrue(): [%s]: %s\n", k_standard_function_names[i], Bool2CString(function_result)); } if (function_result) { write_log(preferences.debug_autoplayer(), "[AutoPlayer] AnyPrimaryFormulaTrue(): yes\n"); return true; } } write_log(preferences.debug_autoplayer(), "[AutoPlayer] AnyPrimaryFormulaTrue(): no\n"); return false; }
void COpenHoldemView::DrawPlayerBet(const int chair) { CPen *pTempPen = NULL, oldpen; CBrush *pTempBrush = NULL, oldbrush; RECT textrect = {0}, drawrect = {0}; CFont *oldfont = NULL, cFont; CString t = ""; static RECT bet_rect_last[10] = {0}; int xcenter = 0, ycenter = 0, xadj = 0, yadj = 0; CDC *pDC = GetDC(); // Draw background colored rectangle over position of previous bet to erase it pTempPen = (CPen*)pDC->SelectObject(&_null_pen); oldpen.FromHandle((HPEN)pTempPen); // Save old pen pTempBrush = (CBrush*)pDC->SelectObject(&_gray_brush); oldbrush.FromHandle((HBRUSH)pTempBrush); // Save old brush pDC->Rectangle(bet_rect_last[chair].left, bet_rect_last[chair].top, bet_rect_last[chair].right, bet_rect_last[chair].bottom); pDC->SelectObject(oldpen); pDC->SelectObject(oldbrush); // Background color pDC->SetBkColor(COLOR_GRAY); // Figure placement xcenter = _client_rect.right * pc[p_tablemap->nchairs()][chair][0]; ycenter = _client_rect.bottom * pc[p_tablemap->nchairs()][chair][1]; xadj = pcbet[p_tablemap->nchairs()][chair][0]; yadj = pcbet[p_tablemap->nchairs()][chair][1]; // Set font basics _logfont.lfHeight = -12; _logfont.lfWeight = FW_NORMAL; cFont.CreateFontIndirect(&_logfont); oldfont = pDC->SelectObject(&cFont); pDC->SetTextColor(COLOR_BLACK); // Format text if (p_table_state->_players[chair]._bet != 0) { t = Number2CString(p_table_state->_players[chair]._bet); } else { t = ""; } // Calc rectangle size for text textrect.left = 0; textrect.top = 0; textrect.right = 0; textrect.bottom = 0; pDC->DrawText(t.GetString(), t.GetLength(), &textrect, DT_CALCRECT); // Figure out placement of rectangle if (xadj<0) { drawrect.left = xcenter + xadj - textrect.right; drawrect.top = ycenter + yadj - textrect.bottom/2; drawrect.right = xcenter + xadj; drawrect.bottom = ycenter + yadj + textrect.bottom/2; } else if (xadj>0) { drawrect.left = xcenter + xadj; drawrect.top = ycenter + yadj - textrect.bottom/2; drawrect.right = xcenter + xadj + textrect.right; drawrect.bottom = ycenter + yadj + textrect.bottom/2; } else // xadj==0 { drawrect.left = xcenter + xadj - textrect.right/2; drawrect.top = ycenter + yadj - textrect.bottom/2; drawrect.right = xcenter + xadj + textrect.right/2; drawrect.bottom = ycenter + yadj + textrect.bottom/2; } // Draw it pDC->SetBkMode(OPAQUE); pDC->DrawText(t.GetString(), t.GetLength(), &drawrect, DT_CENTER | DT_SINGLELINE | DT_VCENTER); bet_rect_last[chair].left = drawrect.left; bet_rect_last[chair].top = drawrect.top; bet_rect_last[chair].right = drawrect.right; bet_rect_last[chair].bottom = drawrect.bottom; cFont.DeleteObject(); ReleaseDC(pDC); }
void COpenHoldemView::DrawBalanceBox(const int chair) { CPen *pTempPen = NULL, oldpen; CBrush *pTempBrush = NULL, oldbrush; RECT textrect = {0}, drawrect = {0}; CFont *oldfont = NULL, cFont; CString t = ""; int left = 0, top = 0, right = 0, bottom = 0; CDC *pDC = GetDC(); static RECT balance_rect_last[10] = {0}; // Background color pDC->SetBkColor(COLOR_GRAY); // Figure placement of box left = _client_rect.right * pc[p_tablemap->nchairs()][chair][0] - 26; top = _client_rect.bottom * pc[p_tablemap->nchairs()][chair][1] + 30; right = _client_rect.right * pc[p_tablemap->nchairs()][chair][0] + 25; bottom = _client_rect.bottom * pc[p_tablemap->nchairs()][chair][1] + 45; // Set font basics _logfont.lfHeight = -12; _logfont.lfWeight = FW_NORMAL; cFont.CreateFontIndirect(&_logfont); oldfont = pDC->SelectObject(&cFont); pDC->SetTextColor(COLOR_BLACK); if (p_scraper_access->IsPlayerSeated(chair) || p_scraper_access->IsPlayerActive(chair)) { pTempPen = (CPen*)pDC->SelectObject(&_black_pen); oldpen.FromHandle((HPEN)pTempPen); // Save old pen pTempBrush = (CBrush*)pDC->SelectObject(&_white_brush); oldbrush.FromHandle((HBRUSH)pTempBrush); // Save old brush // Format Text if (p_table_state->_players[chair]._active) { t = Number2CString(p_table_state->_players[chair]._balance); } else { t.Format("Out (%s)", Number2CString(p_table_state->_players[chair]._balance)); } } else { pTempPen = (CPen*)pDC->SelectObject(&_white_dot_pen); oldpen.FromHandle((HPEN)pTempPen); // Save old pen pTempBrush = (CBrush*)pDC->SelectObject(&_gray_brush); oldbrush.FromHandle((HBRUSH)pTempBrush); // Save old brush t = ""; } // Calc rectangle size for text textrect.left = 0; textrect.top = 0; textrect.right = 0; textrect.bottom = 0; pDC->DrawText(t.GetString(), t.GetLength(), &textrect, DT_CALCRECT); // Figure out placement of rectangle drawrect.left = left < (left+(right-left)/2)-textrect.right/2-3 ? left : (left+(right-left)/2)-textrect.right/2-3; drawrect.top = top; drawrect.right = right > (left+(right-left)/2)+textrect.right/2+3 ? right : (left+(right-left)/2)+textrect.right/2+3; drawrect.bottom = bottom; // Invalidate everything if the balance has decreased in width if (balance_rect_last[chair].right - balance_rect_last[chair].left != drawrect.right - drawrect.left) { InvalidateRect(NULL, true); } // Draw it pDC->SetBkMode(OPAQUE); pDC->Rectangle(drawrect.left, drawrect.top, drawrect.right, drawrect.bottom); pDC->SetBkMode(TRANSPARENT); pDC->DrawText(t.GetString(), t.GetLength(), &drawrect, DT_CENTER | DT_SINGLELINE | DT_VCENTER); balance_rect_last[chair].left = drawrect.left; balance_rect_last[chair].top = drawrect.top; balance_rect_last[chair].right = drawrect.right; balance_rect_last[chair].bottom = drawrect.bottom; // Restore original pen and brush pDC->SelectObject(oldpen); pDC->SelectObject(oldbrush); pDC->SelectObject(oldfont); cFont.DeleteObject(); ReleaseDC(pDC); }
bool CCasinoInterface::EnterBetsize(double total_betsize_in_dollars) { POINT cur_pos = {0}; bool lost_focus = false; POINT point_null = {-1, -1}; CString swag_amt; write_log(preferences.debug_autoplayer(), "[CasinoInterface] Starting DoBetsize...\n"); // In some cases only call and fold are possible. // Then a betsize should be skipped. // We detect this situation by missing min-raise button. // No backup-action here: // OH-script doesn't provide that and OPPL eill do that automatically. // http://www.maxinmontreal.com/forums/viewtopic.php?f=117&t=18125 if (!p_scraper_access->available_buttons[k_autoplayer_function_raise]) { write_log(preferences.debug_autoplayer(), "[CasinoInterface] ...ending DoBetsize early (no (min-)raise possible).\n"); return false; } // swag regions are hard coded as #3 for now, due to legacy WH standard if (!p_scraper_access->i3_edit_defined || !p_scraper_access->i3_button_available) { write_log(preferences.debug_autoplayer(), "[CasinoInterface] ...ending DoBetsize early (no edit field or no i3button).\n"); return false; } SelectSwagText(); // First sleep(), THEN check for stolen focus, then act // NOT the other way: http://www.maxinmontreal.com/forums/viewtopic.php?f=120&t=14791 write_log(preferences.debug_autoplayer(), "[CasinoInterface] Sleeping %dms.\n", preferences.swag_delay_1()); Sleep(preferences.swag_delay_1()); // Check for stolen , and thus misswag if (TableLostFocus()) { lost_focus = true; } DeleteSwagText(); write_log(preferences.debug_autoplayer(), "[CasinoInterface] Sleeping %dms.\n", preferences.swag_delay_2()); Sleep(preferences.swag_delay_2()); // Check for stolen focus, and thus misswag if (TableLostFocus()) { lost_focus = true; } // SWAG AMOUNT ENTRY double swag_adjusted = AdjustedBetsize(total_betsize_in_dollars); swag_amt = Number2CString(swag_adjusted); // Also adapt f$betsize for correct logging later-on // http://www.maxinmontreal.com/forums/viewtopic.php?f=156&t=18648 p_function_collection->SetAutoplayerFunctionValue(k_autoplayer_function_betsize, swag_adjusted); write_log(preferences.debug_autoplayer(), "[CasinoInterface] betsize (not adjusted): %.2f\n", total_betsize_in_dollars); write_log(preferences.debug_autoplayer(), "[CasinoInterface] calling keyboard.dll to enter betsize (adjusted): %s %d,%d %d,%d\n", swag_amt, i3_edit_region.left, i3_edit_region.top, i3_edit_region.right, i3_edit_region.bottom); bool use_comma_instead_of_dot = p_tablemap->use_comma_instead_of_dot(); (theApp._dll_keyboard_sendstring) (p_autoconnector->attached_hwnd(), i3_edit_region, swag_amt, use_comma_instead_of_dot, NULL, point_null); write_log(preferences.debug_autoplayer(), "[CasinoInterface] Sleeping %dms.\n", preferences.swag_delay_3()); Sleep(preferences.swag_delay_3()); // Check for stolen focus, and thus misswag if (TableLostFocus()) { lost_focus = true; } // BET CONFIRMATION ACTION if (lost_focus) { // Print a very verbose warning in the log // Experience tell that beginenrs (and veterans) need that. write_log(k_always_log_errors, "[CasinoInterface] WARNING! Betsizing failed because of lost focus.\n"); write_log(k_always_log_errors, "[CasinoInterface] Another window popped up and receives mouse and keyboard input.\n"); write_log(k_always_log_errors, "[CasinoInterface] This might be caused by bad casino, bad hopper or by user-interaction.\n"); } else { if (p_tablemap->swagconfirmationmethod() == BETCONF_ENTER) { write_log(preferences.debug_autoplayer(), "[CasinoInterface] Confirmation; calling keyboard.dll to press 'Enter'\n"); (theApp._dll_keyboard_sendkey) (p_autoconnector->attached_hwnd(), r_null, VK_RETURN, GetFocus(), cur_pos); } else if (p_tablemap->swagconfirmationmethod() == BETCONF_CLICKBET && p_scraper_access->available_buttons[k_autoplayer_function_raise]) { write_log(preferences.debug_autoplayer(), "[CasinoInterface] Bet Confirmation: Using raise button\n"); if (p_tablemap->buttonclickmethod() == BUTTON_DOUBLECLICK) { ClickButtonSequence(k_autoplayer_function_raise, k_autoplayer_function_raise, k_double_click_delay); } else { ClickButton(k_autoplayer_function_raise); } } else if (p_tablemap->swagconfirmationmethod() == BETCONF_NOTHING) { } else { write_log(preferences.debug_autoplayer(), "[CasinoInterface] ...ending DoBetsize early (invalid betsizeconfirmationmethod).\n"); write_log(preferences.debug_autoplayer(), "[CasinoInterface] Valid options are: \"enter\", \"click bet\", \"nothing\"\n"); return false; } p_autoplayer_trace->Print(ActionConstantNames(k_autoplayer_function_betsize), true); } int betround = p_betround_calculator->betround(); write_log(preferences.debug_autoplayer(), "[CasinoInterface] ...ending DoBetsize, 'didbetsize' now: %d\n", p_symbol_engine_history->didswag(betround)); return (!lost_focus); }
void COpenHoldemStatusbar::ComputeCurrentStatus() { CardMask Cards; CString temp; int userchair = p_symbol_engine_userchair->userchair(); // Player cards CardMask_RESET(Cards); int nCards = 0; _status_plcards = ""; if (p_table_state->User()->HasKnownCards()) { for (int i=0; i<k_number_of_cards_per_player; i++) { // This condition got already checked: "playing" Card card = p_table_state->User()->_hole_cards[i]; // Assertion removeed, because the scraper runs in a different thread. // assert(card.IsKnownCard()); _status_plcards.Append(card.ToString()); CardMask_SET(Cards, card.GetValue()); nCards++; } _status_nopp.Format("%d", p_symbol_engine_prwin->nopponents_for_prwin()); } else { for (int i=0; i<k_number_of_cards_per_player; i++) { if (p_table_state->User()->HasKnownCards()) { Card card = p_table_state->User()->_hole_cards[i]; _status_plcards.Append(card.ToString()); CardMask_SET(Cards, card.GetValue()); nCards++; } } // Not playing, therefore no opponents to be considered for prwin. _status_nopp = ""; } // Common cards _status_comcards = ""; for (int i=0; i<k_number_of_community_cards; i++) { Card card = p_table_state->_common_cards[i]; if (card.IsKnownCard()) { _status_comcards.Append(card.ToString()); CardMask_SET(Cards, card.GetValue()); nCards++; } } // poker hand HandVal hv = Hand_EVAL_N(Cards, nCards); char hvstring[100] = {0}; HandVal_toString(hv, hvstring); _status_pokerhand = hvstring; _status_pokerhand = _status_pokerhand.Mid(0, _status_pokerhand.Find(" ")); // Always use handrank169 here _status_handrank.Format("%.0f/169", p_symbol_engine_handrank->handrank169()); // Always update prwin/nit if (p_symbol_engine_userchair->userchair_confirmed() && p_table_state->User()->HasKnownCards()) { _status_prwin.Format("%d/%d/%d", (int) (p_iterator_thread->prwin()*1000), (int) (p_iterator_thread->prtie()*1000), (int) (p_iterator_thread->prlos()*1000)); double iterations; p_engine_container->EvaluateSymbol("f$prwin_number_of_iterations", &iterations); _status_nit.Format("%d/%s", p_iterator_thread->IteratorThreadProgress(), Number2CString(iterations)); } else { _status_prwin = "0/0/0"; // No iteratrions without userchair or cards _status_nit.Format("0"); } }