Skip to content

Commit

Permalink
T: OH: Fixes for PT thread sleeping times.
Browse files Browse the repository at this point in the history
Added PT stat "pt_flop_float" (PT's stat for: bet IP flop vs missed cbet)
  • Loading branch information
fqfq committed May 1, 2015
1 parent 2b39104 commit 9d2d8c7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 16 deletions.
27 changes: 13 additions & 14 deletions OpenHoldem/CPokerTrackerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,9 @@ UINT CPokerTrackerThread::PokertrackerThreadFunction(LPVOID pParam)
pParent->Connect();
}

double players = p_symbol_engine_active_dealt_playing->nopponentsplaying()
+ (p_symbol_engine_userchair->userchair_confirmed() ? 1 : 0);
write_log(preferences.debug_pokertracker(), "[PokerTracker] Players count is [%d]\n", players);
double players = p_symbol_engine_active_dealt_playing->nopponentsseated()
+ (p_symbol_engine_userchair->userchair_confirmed() ? 1 : 0);
write_log(preferences.debug_pokertracker(), "[PokerTracker] Players count is [%d]\n", (int)players);

if (players < 2)
{
Expand Down Expand Up @@ -793,16 +793,17 @@ UINT CPokerTrackerThread::PokertrackerThreadFunction(LPVOID pParam)
return 0;
}

/*Sleeps but wakes up on stop thread event
/*Sleeps but wakes up on stop thread event every 250ms.
We use this function since we never want the thread to ignore the stop_thread event while it's sleeping*/
int CPokerTrackerThread::LightSleep(int sleepTime, CPokerTrackerThread *pParent)
{
write_log(preferences.debug_pokertracker(), "[PokerTracker] LightSleep: called with sleepTime[%d]\n", sleepTime);
if ( sleepTime > 0)

if (sleepTime > 0)
{
int iterations = 20;
int sleepSlice = (int) ((double)sleepTime / (double)iterations);
for (int i = 0; i < iterations; i++)
unsigned int sleepSlice = 250 ; // ms
unsigned int slicesNumber = sleepTime / sleepSlice ;
for (int i = 1; i <= slicesNumber; i++)
{
Sleep(sleepSlice);
if (::WaitForSingleObject(pParent->_m_stop_thread, 0) == WAIT_OBJECT_0)
Expand All @@ -811,14 +812,12 @@ int CPokerTrackerThread::LightSleep(int sleepTime, CPokerTrackerThread *pParent)
return 1;
}
}
Sleep(sleepTime%sleepSlice);
}
else
if (::WaitForSingleObject(pParent->_m_stop_thread, 0) == WAIT_OBJECT_0)
{
if (::WaitForSingleObject(pParent->_m_stop_thread, 0) == WAIT_OBJECT_0)
{
write_log(preferences.debug_pokertracker(), "[PokerTracker] LightSleep: _m_stop_thread signal received\n");
return 1;
}
write_log(preferences.debug_pokertracker(), "[PokerTracker] LightSleep: _m_stop_thread signal received\n");
return 1;
}
return 0;
}
38 changes: 36 additions & 2 deletions PokerTracker_Query_Definitions/PokerTracker_Queries_Version_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#define PT4_QUERY_SUPPORT__FLOP_FOLD_TO_3B (FALSE) // "flop_fold_to_3bet" // 3b is a reraise, we should have a "flop_fold_to_raise" stat first.
#define PT4_QUERY_SUPPORT__FLOP_CHECK_RAISE (TRUE) // "flop_checkraise"
#define PT4_QUERY_SUPPORT__FLOP_DONKBET (TRUE) // "flop_donkbet"
#define PT4_QUERY_SUPPORT__FLOP_FLOAT (TRUE) // "flop_float" (PT's stat for: bet IP flop vs missed cbet)

// TURN Other stats
#define PT4_QUERY_SUPPORT__TURN_FOLD_TO_3B (FALSE) // "turn_fold_to_3bet" // 3b is a reraise, we should have a "turn_fold_to_raise" stat first.
Expand Down Expand Up @@ -143,15 +144,16 @@ const int k_number_of_pokertracker_stats = //GENERAL STATS
(PT4_QUERY_SUPPORT__FLOP_FOLD_TO_3B ? 1 : 0) +
(PT4_QUERY_SUPPORT__FLOP_CHECK_RAISE ? 1 : 0) +
(PT4_QUERY_SUPPORT__FLOP_DONKBET ? 1 : 0) +

(PT4_QUERY_SUPPORT__FLOP_FLOAT ? 1 : 0) +

// Turn Other stats
(PT4_QUERY_SUPPORT__TURN_FOLD_TO_3B ? 1 : 0) +
(PT4_QUERY_SUPPORT__TURN_CHECK_RAISE ? 1 : 0) +
(PT4_QUERY_SUPPORT__TURN_CHECK_CALL ? 1 : 0) +

// River Other stats
(PT4_QUERY_SUPPORT__RIVER_FOLD_TO_3B ? 1 : 0) +
(PT4_QUERY_SUPPORT__RIVER_BET ? 1 : 0);
(PT4_QUERY_SUPPORT__RIVER_BET ? 1 : 0) ;


// PokerTracker support
Expand Down Expand Up @@ -1189,6 +1191,38 @@ t_QueryDefinition query_definitions[k_number_of_pokertracker_stats] =
},
#endif

#if PT4_QUERY_SUPPORT__FLOP_FLOAT
/* PT4 query to get flop float */
{
// name
"flop_float",
// description_for_editor
"Poker Tracker flop float",
// query
"SELECT (case when ActionOpportunities = 0 then -1 \
else cast(ActionCount as real) / ActionOpportunities \
end) as result \
FROM (SELECT sum(case when ((cnt_p_call>0) AND S.flg_p_face_raise AND S.flg_f_bet \
AND char_length(HSum.str_aggressors_p) = 2 \
AND ((HSum.cnt_players > 2 AND S.val_p_raise_aggressor_pos > S.position) \
OR (HSum.cnt_players = 2 AND S.flg_f_has_position))) then 1 else 0 end) \
as ActionCount, \
sum(case when ((cnt_p_call>0) AND S.flg_p_face_raise AND S.flg_f_open_opp \
AND char_length(HSum.str_aggressors_p)=2 \
AND((HSum.cnt_players>2 AND S.val_p_raise_aggressor_pos > S.position) \
OR(HSum.cnt_players=2 AND S.flg_f_has_position))) then 1 else 0 end) \
as ActionOpportunities \
FROM player as P, %TYPE%_hand_summary as HSum, %TYPE%_hand_player_statistics as S \
WHERE S.id_player = P.id_player AND \
S.id_gametype = %GAMETYPE% AND \
HSum.id_hand = S.id_hand AND \
P.id_site = %SITEID% AND \
P.player_name LIKE '%SCREENNAME%') foo",
// stat_group
pt_group_advanced
},
#endif

#if PT4_QUERY_SUPPORT__TURN_FOLD_TO_3B
/* PT4 query to get TURN fold to 3 bet */
{
Expand Down

0 comments on commit 9d2d8c7

Please sign in to comment.