-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83c6fbc
commit ca9636e
Showing
9 changed files
with
195 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//******************************************************************************* | ||
// | ||
// This file is part of the OpenHoldem project | ||
// Download page: http://code.google.com/p/openholdembot/ | ||
// Forums: http://www.maxinmontreal.com/forums/index.php | ||
// Licensed under GPL v3: http://www.gnu.org/licenses/gpl.html | ||
// | ||
//******************************************************************************* | ||
// | ||
// Purpose: Detecting if we plaz rush / zoom / ... | ||
// depending on the time since our last action on handreset. | ||
// | ||
//******************************************************************************* | ||
|
||
#ifndef INC_CSYMBOLENGINEISRUSH_H | ||
#define INC_CSYMBOLENGINEISRUSH_H | ||
|
||
#include "CVirtualSymbolEngine.h" | ||
|
||
class CSymbolEngineIsRush: public CVirtualSymbolEngine { | ||
public: | ||
CSymbolEngineIsRush(); | ||
~CSymbolEngineIsRush(); | ||
public: | ||
// Mandatory reset-functions | ||
void InitOnStartup(); | ||
void ResetOnConnection(); | ||
void ResetOnHandreset(); | ||
void ResetOnNewRound(); | ||
void ResetOnMyTurn(); | ||
void ResetOnHeartbeat(); | ||
public: | ||
// Public accessors | ||
bool EvaluateSymbol(const char *name, double *result, bool log = false); | ||
CString SymbolsProvided(); | ||
public: | ||
bool isrush(); | ||
private: | ||
double sum_of_handreset_durations; | ||
int handresets; | ||
}; | ||
|
||
extern CSymbolEngineIsRush *p_symbol_engine_isrush; | ||
|
||
#endif INC_CSYMBOLENGINEUSERCHAIR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
//******************************************************************************* | ||
// | ||
// This file is part of the OpenHoldem project | ||
// Download page: http://code.google.com/p/openholdembot/ | ||
// Forums: http://www.maxinmontreal.com/forums/index.php | ||
// Licensed under GPL v3: http://www.gnu.org/licenses/gpl.html | ||
// | ||
//******************************************************************************* | ||
// | ||
// Purpose: Detecting if we plaz rush / zoom / ... | ||
// depending on the time since our last action on handreset. | ||
// | ||
//******************************************************************************* | ||
|
||
#include "stdafx.h" | ||
#include "CSymbolEngineIsRush.h" | ||
|
||
#include "CPreferences.h" | ||
#include "CScraper.h" | ||
#include "CSymbolEngineIsTournament.h" | ||
#include "CSymbolEngineTime.h" | ||
#include "CTableState.h" | ||
#include "MagicNumbers.h" | ||
|
||
CSymbolEngineIsRush *p_symbol_engine_isrush = NULL; | ||
|
||
// Maximum average time between last action and handreset | ||
// if the game should be considered rush / zoom. | ||
// Ploease note: detecting hand-resets can take several heartbeats (2..4) | ||
// so this value might need some fine-tuning. | ||
const int kMaxAverageDurationOfHandreset = 4; | ||
|
||
CSymbolEngineIsRush::CSymbolEngineIsRush() { | ||
// The values of some symbol-engines depend on other engines. | ||
// As the engines get later called in the order of initialization | ||
// we assure correct ordering by checking if they are initialized. | ||
assert(p_symbol_engine_time != NULL); | ||
assert(p_symbol_engine_istournament != NULL); | ||
} | ||
|
||
CSymbolEngineIsRush::~CSymbolEngineIsRush() { | ||
} | ||
|
||
void CSymbolEngineIsRush::InitOnStartup() { | ||
ResetOnConnection(); | ||
} | ||
|
||
void CSymbolEngineIsRush::ResetOnConnection() { | ||
sum_of_handreset_durations = 0.0; | ||
// Init to 1 to avoid division by zero | ||
handresets = 1; | ||
} | ||
|
||
void CSymbolEngineIsRush::ResetOnHandreset() { | ||
if (p_symbol_engine_time->elapsedauto() > 60) { | ||
// Unreliable value, we might have been sitting out | ||
return; | ||
} | ||
sum_of_handreset_durations += p_symbol_engine_time->elapsedauto(); | ||
++handresets; | ||
} | ||
|
||
void CSymbolEngineIsRush::ResetOnNewRound() { | ||
} | ||
|
||
void CSymbolEngineIsRush::ResetOnMyTurn() { | ||
} | ||
|
||
void CSymbolEngineIsRush::ResetOnHeartbeat() { | ||
} | ||
|
||
bool CSymbolEngineIsRush::isrush() { | ||
if (p_symbol_engine_istournament->istournament()) { | ||
// Not a cash-game, therefore not rush | ||
write_log(preferences.debug_symbolengine(), | ||
"[CSymbolEngineIsRush] Tournament, therefore not rush / zoom\n"); | ||
return false; | ||
} | ||
assert(handresets > 0); | ||
write_log(preferences.debug_symbolengine(), | ||
"[CSymbolEngineIsRush] Average duration of hand-reset: %.2f\n", | ||
sum_of_handreset_durations / handresets); | ||
if (sum_of_handreset_durations / handresets > kMaxAverageDurationOfHandreset) { | ||
// Too long duration | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool CSymbolEngineIsRush::EvaluateSymbol(const char *name, double *result, bool log /* = false */) { | ||
FAST_EXIT_ON_OPENPPL_SYMBOLS(name); | ||
if (memcmp(name, "isrush", 6)==0) { | ||
*result = isrush(); | ||
return true; | ||
} | ||
// Symbol of a different symbol-engine | ||
return false; | ||
} | ||
|
||
CString CSymbolEngineIsRush::SymbolsProvided() { | ||
return "isrush "; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.