Exemple #1
0
bool CAutoplayer::DoSwag(void) 
{
	if (p_autoplayer_functions->f$betsize() > 0)
	{
		return p_casino_interface->EnterBetsize(p_autoplayer_functions->f$betsize());
	}
	return false;
}
bool CAutoplayer::DoSwag(void)
{
    if (p_autoplayer_functions->f$betsize() > 0)
    {
        return p_casino_interface->EnterBetsize(p_autoplayer_functions->f$betsize());
    }
    write_log(prefs.debug_autoplayer(), "[AutoPlayer] Don't swag, because f$betsize evaluates to 0.\n");
    return false;
}
Exemple #3
0
bool CAutoplayer::DoSwag(void) 
{
	if (p_autoplayer_functions->f$betsize() > 0)
	{
		int success = p_casino_interface->EnterBetsize(p_autoplayer_functions->f$betsize());
		if (success)
		{
			p_symbol_engine_history->RegisterAction(k_autoplayer_function_betsize);
			return true;
		}
	}
	write_log(preferences.debug_autoplayer(), "[AutoPlayer] Don't swag, because f$betsize evaluates to 0.\n");
	return false;
}
Exemple #4
0
void write_logautoplay(const char * action) 
{
    char		nowtime[26];
    CString		pcards, comcards, temp, rank, pokerhand, bestaction, fcra_seen;
    char		*card;
    CardMask	Cards;
    int			nCards;
    CString		fcra_formula_status;

	int			sym_userchair = (int) p_symbol_engine_userchair->userchair();
	int			betround = (int) p_betround_calculator->betround();


	if (!prefs.trace_enabled())
		return;

	if (log_fp != NULL) 
	{
		CSLock lock(log_critsec);

		// log$ writing
		if (prefs.log_symbol_enabled())
		{
			int max_log = p_symbols->logsymbols_collection()->GetCount();

			if (max_log > 0)
			{
				if (max_log > prefs.log_symbol_max_log())
				{
					max_log = prefs.log_symbol_max_log();
				}

				write_log(k_always_log_basic_information, "*** log$ (Total: %d | Showing: %d)\n", p_symbols->logsymbols_collection()->GetCount(), max_log);

				for (int i=0; i<max_log; i++)
				{
					write_log(k_always_log_basic_information, "***     %s\n", p_symbols->logsymbols_collection()->GetAt(i));
				}
			}
		}
		
		CardMask_RESET(Cards);
		nCards=0;

		// player cards
		if (p_symbol_engine_userchair->userchair_confirmed()) 
		{
			for (int i=0; i<=1; i++) 
			{
				card = StdDeck_cardString(p_scraper->card_player(sym_userchair, i));
				temp.Format("%s", card);
				pcards.Append(temp);
				CardMask_SET(Cards, p_scraper->card_player(sym_userchair, i));
				nCards++;
			}
		}
		else 
		{
			pcards = "....";
		}

		// common cards
		comcards = "";
		if (betround >= k_betround_flop) 
		{
			for (int i=0; i<=2; i++) 
			{
				if (p_scraper->card_common(i) != CARD_BACK && 
					p_scraper->card_common(i) != CARD_NOCARD) 
				{
					card = StdDeck_cardString(p_scraper->card_common(i));
					temp.Format("%s", card);
					comcards.Append(temp);
					CardMask_SET(Cards, p_scraper->card_common(i));
					nCards++;
				}
			}
		}

		if (betround >= k_betround_turn) 
		{
			card = StdDeck_cardString(p_scraper->card_common(3));
			temp.Format("%s", card);
			comcards.Append(temp);
			CardMask_SET(Cards, p_scraper->card_common(3));
			nCards++;
		}

		if (betround >= k_betround_river) 
		{
			card = StdDeck_cardString(p_scraper->card_common(4));
			temp.Format("%s", card);
			comcards.Append(temp);
			CardMask_SET(Cards, p_scraper->card_common(4));
			nCards++;
		}

        comcards.Append("..........");
        comcards = comcards.Left(10);

        // Always use handrank169 here
		rank.Format("%.0f", p_symbol_engine_handrank->handrank169());

        // poker hand
		pokerhand = p_symbol_engine_pokerval->HandType();

        // best action
        if (strcmp(action, "SWAG")==0) 
		{
            bestaction.Format("$%.2f", p_autoplayer_functions->f$betsize());
        }
        else 
		{
            if (p_autoplayer_functions->f$alli())
                bestaction = "Allin";

            else if (p_autoplayer_functions->f$betsize())
                bestaction = "SWAG";

            else if (p_autoplayer_functions->f$rais())
                bestaction = "Bet/Raise";

            else if (p_autoplayer_functions->f$call())
                bestaction = "Call/Check";

            else if (p_autoplayer_functions->f$prefold())
                bestaction = "Pre-fold";

            else
                bestaction = "Fold/Check";

        }

        // fcra_seen
		int sym_myturnbits = p_symbol_engine_autoplayer->myturnbits();
        fcra_seen.Format("%s%s%s%s%s",
                         sym_myturnbits&0x01 ? "F" : ".",
                         sym_myturnbits&0x02 ? "C" : ".",
						 // Check button out of order to stay consistent
						 // with button order in manual mode.
						 sym_myturnbits&0x10 ? "K" : ".",
                         sym_myturnbits&0x04 ? "R" : ".",
                         sym_myturnbits&0x08 ? "A" : ".");

        // fcra formula status
		fcra_formula_status.Format("%s%s%s%s",
			!p_autoplayer_functions->f$alli() && !p_autoplayer_functions->f$rais() && !p_autoplayer_functions->f$call() && !p_autoplayer_functions->f$betsize() ? "F" : ".",
			p_autoplayer_functions->f$call() ? "C" : ".",
			p_autoplayer_functions->f$rais() ? "R" : ".",
			p_autoplayer_functions->f$alli() ? "A" : ".");

        fprintf(log_fp, "%s - %1d ", 
			get_time(nowtime), 
			p_tablemap->nchairs());
        fprintf(log_fp, "%4s %10s %4s %5s ", 
			pcards.GetString(), 
			comcards.GetString(), 
			rank.GetString(), 
			pokerhand.GetString());
        fprintf(log_fp, "%4d %4d %4d ", 
			(iter_vars.prwin() * 1000),
			(iter_vars.prlos() * 1000), 
			(iter_vars.prtie() * 1000));
        fprintf(log_fp, "%2d %8d %-10s - ", 
			p_symbol_engine_prwin->nopponents_for_prwin(),
			iter_vars.nit(),
			bestaction.GetString());
        fprintf(log_fp, "%-5s %9.2f %9.2f %9.2f ", 
			action, 
			p_symbol_engine_chip_amounts->call(), 
			p_tablelimits->bet(), 
			p_symbol_engine_chip_amounts->pot());
		int userchair = p_symbol_engine_userchair->userchair();
		fprintf(log_fp, "%9.2f - %s %s %.2f\n", 
			p_symbol_engine_chip_amounts->balance(userchair), 
			fcra_seen.GetString(), 
			fcra_formula_status.GetString(), 
			p_autoplayer_functions->f$betsize() );

		if (prefs.trace_enabled() && p_symbols->symboltrace_collection()->GetSize() > 0)
		{
			write_log_nostamp(1, "***** Autoplayer Trace ****\n");
			for (int i=0; i<p_symbols->symboltrace_collection()->GetSize(); i++)
			{
				write_log_nostamp(1, "%s\n", p_symbols->symboltrace_collection()->GetAt(i));
			}
			write_log_nostamp(1, "***********************\n");
		}

		fflush(log_fp);
    }
}
Exemple #5
0
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(), "[AutoPlayer] Starting DoSwag...\n");

	// 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(), "[AutoPlayer] ...ending DoSwag 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(), "[AutoPlayer] Sleeping %dms.\n", preferences.swag_delay_1());
	Sleep(preferences.swag_delay_1()); 

	// Check for stolen , and thus misswag
	if (TableLostFocus())
		lost_focus = true;
	
	DeleteSwagText();

	// Check for stolen focus, and thus misswag
	if (TableLostFocus())
		lost_focus = true;

	write_log(preferences.debug_autoplayer(), "[AutoPlayer] Sleeping %dms.\n", preferences.swag_delay_2());
	
	// SWAG AMOUNT ENTRY
	double swag_adjusted = AdjustedBetsize(p_autoplayer_functions->f$betsize());

	if (swag_adjusted != (int) swag_adjusted)
		swag_amt.Format("%.2f", swag_adjusted);
	else
		swag_amt.Format("%.0f", swag_adjusted);

	write_log(preferences.debug_autoplayer(), "[AutoPlayer] Swag amount (not adjusted): %.2f\n", p_autoplayer_functions->f$betsize());
	write_log(preferences.debug_autoplayer(), "[AutoPlayer] Swag amount; calling keyboard.dll to swag (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);
	(theApp._dll_keyboard_sendstring) (p_autoconnector->attached_hwnd(), i3_edit_region, swag_amt, preferences.swag_use_comma(), NULL, point_null);

	Sleep(preferences.swag_delay_2());
	// Check for stolen focus, and thus misswag
	if (TableLostFocus())
		lost_focus = true;

	write_log(preferences.debug_autoplayer(), "[AutoPlayer] Sleeping %dms.\n", preferences.swag_delay_3());
	Sleep(preferences.swag_delay_3());

	// BET CONFIRMATION ACTION
	if (!lost_focus)
	{
		if (p_tablemap->swagconfirmationmethod() == BETCONF_ENTER)
		{
			write_log(preferences.debug_autoplayer(), "[AutoPlayer] 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(), "[AutoPlayer] 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(), "[AutoPlayer] ...ending DoSwag early (invalid swagconfirmationmethod).\n");
			return false;
		}
		
		write_logautoplay(ActionConstantNames(k_prevaction_betsize));

	}
	int betround = p_betround_calculator->betround();
	write_log(preferences.debug_autoplayer(), "[AutoPlayer] ...ending DoSwag, 'didswag' now: %d\n", 
		p_symbol_engine_history->didswag(betround));
	return (!lost_focus);
}
Exemple #6
0
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(prefs.debug_autoplayer(), "[AutoPlayer] Starting DoSwag...\n");

	// swag regions are hard coded as #3 for now, due to legacy WH standard
	if (!p_scraper_access->i3_edit_defined)
	{
		write_log(prefs.debug_autoplayer(), "[AutoPlayer] ...ending DoSwag early (no edit field).\n");
		return false;
	}

	SelectSwagText();

	// First sleep(), THEN check for stolen focus
	write_log(prefs.debug_autoplayer(), "[AutoPlayer] Sleeping %dms.\n", prefs.swag_delay_1());
	Sleep(prefs.swag_delay_1()); 

	// Check for stolen , and thus misswag
	if (GetForegroundWindow() != p_autoconnector->attached_hwnd())
		lost_focus = true;
	
	DeleteSwagText();

	// Check for stolen focus, and thus misswag
	if (GetForegroundWindow() != p_autoconnector->attached_hwnd())
		lost_focus = true;

	write_log(prefs.debug_autoplayer(), "[AutoPlayer] Sleeping %dms.\n", prefs.swag_delay_2());
	
	// SWAG AMOUNT ENTRY
	double swag_adjusted = SwagAmountAdjusted(p_autoplayer_functions->f$betsize());

	if (swag_adjusted != (int) swag_adjusted)
		swag_amt.Format("%.2f", swag_adjusted);
	else
		swag_amt.Format("%.0f", swag_adjusted);

	write_log(prefs.debug_autoplayer(), "[AutoPlayer] Swag amount (not adjusted): %.2f\n", p_autoplayer_functions->f$betsize());
	write_log(prefs.debug_autoplayer(), "[AutoPlayer] Swag amount; calling keyboard.dll to swag (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);
	(theApp._dll_keyboard_sendstring) (p_autoconnector->attached_hwnd(), i3_edit_region, swag_amt, prefs.swag_use_comma(), NULL, point_null);

	Sleep(prefs.swag_delay_2());
	// Check for stolen focus, and thus misswag
	if (GetForegroundWindow() != p_autoconnector->attached_hwnd())
		lost_focus = true;

	write_log(prefs.debug_autoplayer(), "[AutoPlayer] Sleeping %dms.\n", prefs.swag_delay_3());
	Sleep(prefs.swag_delay_3());

	// BET CONFIRMATION ACTION
	if (!lost_focus)
	{
		if (p_tablemap->swagconfirmationmethod() == BETCONF_ENTER)
		{
			write_log(prefs.debug_autoplayer(), "[AutoPlayer] 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] || p_scraper_access->i3_button_available))
		{
			int confirmation_button = k_button_undefined;

			// use i3button region if it exists, otherwise use the bet/raise button region
			if (p_scraper_access->i3_button_available)
			{
				confirmation_button = k_button_i3;
				write_log(prefs.debug_autoplayer(), "[AutoPlayer] Bet Confirmation: Using i3button\n");
			}
			else
			{
				confirmation_button = k_button_raise;
				write_log(prefs.debug_autoplayer(), "[AutoPlayer] Bet Confirmation: Using raise button\n");
			}

			if (p_tablemap->buttonclickmethod() == BUTTON_DOUBLECLICK)
			{
				ClickButtonSequence(confirmation_button, confirmation_button, k_double_click_delay);
			}
			else
			{
				ClickButton(confirmation_button);
			}
		}

		else if (p_tablemap->swagconfirmationmethod() == BETCONF_NOTHING)
		{
		}

		else
		{
			write_log(prefs.debug_autoplayer(), "[AutoPlayer] ...ending DoSwag early (invalid swagconfirmationmethod).\n");
			return false;
		}
		
		p_symbols->RecordPrevAction(k_action_betsize);
		write_logautoplay(ActionConstantNames(k_action_betsize));

		p_heartbeat_thread->set_replay_recorded_this_turn(false);
	}
	int betround = p_betround_calculator->betround();
	write_log(prefs.debug_autoplayer(), "[AutoPlayer] ...ending DoSwag, 'didswag' now: %d\n", 
		p_symbol_engine_history->didswag(betround));
	return (!lost_focus);
}
Exemple #7
0
void write_logautoplay(int level, const char * action) 
{
    char		nowtime[26];
    CString		pcards, comcards, temp, rank, pokerhand, bestaction, fcra_seen;
    char		*card;
    CardMask	Cards;
    int			i, nCards;
    HandVal		hv;
    CString		fcra_formula_status;

	int			sym_userchair = (int) p_symbols->sym()->userchair;
	int			sym_br = (int) p_symbols->sym()->br;


	if (level>prefs.log_level())
		return;

	if (log_fp != NULL) 
	{
		CSLock lock(log_critsec);

		// log$ writing
		if (prefs.log_symbol_enabled())
		{
			int max_log = p_symbols->logsymbols_collection()->GetCount();

			if (max_log > 0)
			{
				if (max_log > prefs.log_symbol_max_log())
				{
					max_log = prefs.log_symbol_max_log();
				}

				write_log(1, "*** log$ (Total: %d | Showing: %d)\n", p_symbols->logsymbols_collection()->GetCount(), max_log);

				for (int i=0; i<max_log; i++)
				{
					write_log(1, "***     %s\n", p_symbols->logsymbols_collection()->GetAt(i));
				}
			}
		}
		
		CardMask_RESET(Cards);
		nCards=0;

		// player cards
		if (p_symbols->user_chair_confirmed()) 
		{
			for (i=0; i<=1; i++) 
			{
				card = StdDeck_cardString(p_scraper->card_player(sym_userchair, i));
				temp.Format("%s", card);
				pcards.Append(temp);
				CardMask_SET(Cards, p_scraper->card_player(sym_userchair, i));
				nCards++;
			}
		}
		else 
		{
			pcards = "....";
		}

		// common cards
		comcards = "";
		if (sym_br >= 2) 
		{
			for (i=0; i<=2; i++) 
			{
				if (p_scraper->card_common(i) != CARD_BACK && 
					p_scraper->card_common(i) != CARD_NOCARD) 
				{
					card = StdDeck_cardString(p_scraper->card_common(i));
					temp.Format("%s", card);
					comcards.Append(temp);
					CardMask_SET(Cards, p_scraper->card_common(i));
					nCards++;
				}
			}
		}

		if (sym_br >= 3) 
		{
			card = StdDeck_cardString(p_scraper->card_common(3));
			temp.Format("%s", card);
			comcards.Append(temp);
			CardMask_SET(Cards, p_scraper->card_common(3));
			nCards++;
		}

		if (sym_br >= 4) 
		{
			card = StdDeck_cardString(p_scraper->card_common(4));
			temp.Format("%s", card);
			comcards.Append(temp);
			CardMask_SET(Cards, p_scraper->card_common(4));
			nCards++;
		}

        comcards.Append("..........");
        comcards = comcards.Left(10);

        // handrank
        if (prefs.sym_handrank_value() == "169")
			rank.Format("%.0f", p_symbols->sym()->handrank169);

        else if (prefs.sym_handrank_value() == "1000")
            rank.Format("%.0f", p_symbols->sym()->handrank1000);

        else if (prefs.sym_handrank_value() == "1326")
            rank.Format("%.0f", p_symbols->sym()->handrank1326);

        else if (prefs.sym_handrank_value() == "2652")
            rank.Format("%.0f", p_symbols->sym()->handrank2652);

        else if (prefs.sym_handrank_value() == "p")
            rank.Format("%.2f", p_symbols->sym()->handrankp);


        // poker hand
        hv = Hand_EVAL_N(Cards, nCards);
        if (HandVal_HANDTYPE(hv)==HandType_STFLUSH && StdDeck_RANK(HandVal_TOP_CARD(hv))==Rank_ACE)
            pokerhand="royfl";

        else if (HandVal_HANDTYPE(hv)==HandType_STFLUSH)
            pokerhand="strfl";

        else if (HandVal_HANDTYPE(hv)==HandType_QUADS)
            pokerhand="4kind";

        else if (HandVal_HANDTYPE(hv)==HandType_FULLHOUSE)
            pokerhand="fullh";

        else if (HandVal_HANDTYPE(hv)==HandType_FLUSH)
            pokerhand="flush";

        else if (HandVal_HANDTYPE(hv)==HandType_STRAIGHT)
            pokerhand="strai";

        else if (HandVal_HANDTYPE(hv)==HandType_TRIPS)
            pokerhand="3kind";

        else if (HandVal_HANDTYPE(hv)==HandType_TWOPAIR)
            pokerhand="2pair";

        else if (HandVal_HANDTYPE(hv)==HandType_ONEPAIR)
            pokerhand="1pair";

        else if (HandVal_HANDTYPE(hv)==HandType_NOPAIR)
            pokerhand="hcard";


        // best action
        if (strcmp(action, "SWAG")==0) 
		{
            bestaction.Format("$%.2f", p_symbols->f$betsize());
        }
        else 
		{
            if (p_symbols->f$alli())
                bestaction = "Allin";

            else if (p_symbols->f$betsize())
                bestaction = "SWAG";

            else if (p_symbols->f$rais())
                bestaction = "Bet/Raise";

            else if (p_symbols->f$call())
                bestaction = "Call/Check";

            else if (p_symbols->f$prefold())
                bestaction = "Pre-fold";

            else
                bestaction = "Fold/Check";

        }

        // fcra_seen
		int sym_myturnbits = (int) p_symbols->sym()->myturnbits;
        fcra_seen.Format("%s%s%s%s%s",
                         sym_myturnbits&0x01 ? "F" : ".",
                         sym_myturnbits&0x02 ? "C" : ".",
						 // Check button out of order to stay consistent
						 // with button order in manual mode.
						 sym_myturnbits&0x10 ? "K" : ".",
                         sym_myturnbits&0x04 ? "R" : ".",
                         sym_myturnbits&0x08 ? "A" : ".");

        // fcra formula status
        fcra_formula_status.Format("%s%s%s%s",
                                   !p_symbols->f$alli() && !p_symbols->f$rais() && !p_symbols->f$call() && !p_symbols->f$betsize() ? "F" : ".",
                                   p_symbols->f$call() ? "C" : ".",
                                   p_symbols->f$rais() ? "R" : ".",
                                   p_symbols->f$alli() ? "A" : ".");

        fprintf(log_fp, "%s - %1d ", 
			get_time(nowtime), 
			p_tablemap->nchairs());
        fprintf(log_fp, "%4s %10s %4s %5s ", 
			pcards.GetString(), 
			comcards.GetString(), 
			rank.GetString(), 
			pokerhand.GetString());
        fprintf(log_fp, "%4d %4d %4d ", 
			(int) (p_symbols->sym()->prwin*1000),
			(int) (p_symbols->sym()->prlos*1000), 
			(int) (p_symbols->sym()->prtie*1000));
        fprintf(log_fp, "%2d %8d %-10s - ", 
			(int) p_symbols->sym()->nopponents,
			(int) p_symbols->sym()->nit,
			bestaction.GetString());
        fprintf(log_fp, "%-5s %9.2f %9.2f %9.2f ", 
			action, 
			p_symbols->sym()->call, 
			p_tablelimits->bet(), 
			p_symbols->sym()->pot);
		fprintf(log_fp, "%9.2f - %s %s %.2f\n", 
			p_symbols->sym()->balance[10], 
			fcra_seen.GetString(), 
			fcra_formula_status.GetString(), 
			p_symbols->f$betsize() );

		if (prefs.trace_enabled() && p_symbols->symboltrace_collection()->GetSize() > 0)
		{
			write_log_nostamp(1, "***** Autoplayer Trace ****\n");
			for (int i=0; i<p_symbols->symboltrace_collection()->GetSize(); i++)
			{
				write_log_nostamp(1, "%s\n", p_symbols->symboltrace_collection()->GetAt(i));
			}
			write_log_nostamp(1, "***********************\n");
		}

		fflush(log_fp);
    }
}