void CSymbolEngineIsTournament::TryToDetectTournament()
{
	if (_istournament != k_undefined)
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] Currently istournament = %s\n", Bool2CString(_istournament));
	else
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] Currently istournament = unknown\n");
	// Don't do anything if we are already sure.
	// Don't mix things up.
	if (_decision_locked)
	{
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] decision already locked\n");
		return;
	}
	// If we have more than 2 hands played we should be sure
	// and stick to our decision, whatever it is (probably cash-game).
	// Also checking for (elapsedauto < elapsed). i.e. at least one action
	// since connection, as handsplayed does not reset if we play multiple games.
	if ((_istournament != k_undefined)
		&& (p_game_state->hands_played() > 2)
		&& (p_symbol_engine_time->elapsedauto() < p_symbol_engine_time->elapsed()))
	{
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] Enough hands played; locking current value\n");
		_decision_locked = true;
		return;
	}
	// If the blinds are "too low" then we play a cash-game.
	double bigblind = p_tablelimits->bblind();
	if ((bigblind > 0) && (bigblind < k_lowest_bigblind_ever_seen_in_tournament))
	{
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] Blinds \"too low\"; this is a cash-game\n");
		_istournament    = false;
		_decision_locked = true;
		return;
	}
	// If the title-string looks like a tournament then it is a tournament.
	if (TitleStringLooksLikeTournament())
	{
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] Table title looks like a tournament\n");
		_istournament    = true;
		_decision_locked = true;
		return;
	}
	// If there are antes then it is a tournament.
	if (AntesPresent())
	{
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] Game with antes; therefore tournament\n");
		_istournament    = true;
		_decision_locked = true;
		return;
	}
	// If bets and balances are "tournament-like", then it is a tournament
	if (BetsAndBalancesAreTournamentLike())
	{
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] Bets and balances look like tournament\n");
		_istournament    = true;
		_decision_locked = true;
		return;
	}
	// Not yet sure, but we have handled so far:
	// * all lower stakes cash-games
	// * all SNGs / MTTs with good title-string
	// * all SNGs and starting tables of MTTs (by bets and balances)
	// * some later tables of MTTs (by antes)
	// * some more later tables of MTTs (if no reconnection is necessary)
	// This leaves us with only 2 cases
	// * medium and high-stakes cash-games ($5/$10 and above)
	// * some (very few) later tables of MTTs
	if (bigblind > k_large_bigblind_probably_later_table_in_tournament)
	{
		// Probably tournament, but not really sure yet,
		// so don't lock the decision.
		write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] bigblind very large; probably tournament\n");
		_istournament = true;
		return;
	}
	// Smaller bigblinds (< $500) will be considered cash-games, 
	// because they are too small for later tables of tournaments
	_istournament    = false;
	_decision_locked = true;
	write_log(prefs.debug_istournament(), "[CSymbolEngineIsTournament] high-stakes cash-game up to $200\\$400.n");
	// The only case that can go wrong now:
	// High-stakes cash-games ($250/$500 and above) can be recognized 
	// as tournaments. 
	// Main consequence: blinds won't be locked for the entire session,
	// but only for the current hand. Does this hurt much?
}
void CSymbolEngineIsTournament::TryToDetectTournament() {
	if (_istournament != kUndefined) {
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] Currently istournament = %s\n", Bool2CString(_istournament));
  } else {
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] Currently istournament = unknown\n");
  }
	// Don't do anything if we are already sure.
	// Don't mix things up.
	if (_decision_locked) {
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] decision already locked\n");
		return;
	}
	if (p_symbol_engine_mtt_info->ConnectedToMTT()) {
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] MTT tournament detected\n");
		_istournament    = true;
		_decision_locked = true;
		return;
	}
	// If we have more than 2 hands played we should be sure
	// and stick to our decision, whatever it is (probably cash-game).
	// Also checking for (elapsedauto < elapsed). i.e. at least one action
	// since connection, as handsplayed does not reset if we play multiple games.
	if ((_istournament != kUndefined)
		  && (p_handreset_detector->hands_played() > 2)
		  && (p_symbol_engine_time->elapsedauto() < p_symbol_engine_time->elapsed())) {
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] Enough hands played; locking current value\n");
		_decision_locked = true;
		return;
	}
  // If we plaz at DDPoiker the game is a tournament,
  // even though it can~t be detected bz titlestring.
  if (p_symbol_engine_casino->ConnectedToDDPoker()) {
    write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] DDPoker tournament\n");
    _istournament    = true;
		_decision_locked = true;
		return;
  }
  // If the title-string looks like a tournament then it is a tournament.
  // This should be checked before the size of the blinds,
  // because incorrectly detecting a cash-game as tournament
  // does less harm than vice versa (blind-locking).
  // And there was a problem if during the sit-down-phase 
  // of a tournament there were no blinds to be detected:
  // http://www.maxinmontreal.com/forums/viewtopic.php?f=294&t=17625&start=30#p125608
	if (TitleStringContainsIdentifier(k_tournament_identifiers,
      k_number_of_tournament_identifiers))	{
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] Table title looks like a tournament\n");
		_istournament    = true;
		_decision_locked = true;
		return;
	}
	// If the blinds are "too low" then we play a cash-game.
  // Only consider this option if a game is going on (playersplaying)
  // to avoid problems with no blinds during the sit-down-phase 
  // of a tournament.
  if (p_symbol_engine_active_dealt_playing->nplayersplaying() < 2) {
    write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] Can't consider the blinds -- too few people playing.\n");
    return;
  }
  double bigblind = p_symbol_engine_tablelimits->bblind();
	if ((bigblind > 0) && (bigblind < k_lowest_bigblind_ever_seen_in_tournament)) {
	  write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] Blinds \"too low\"; this is a cash-game\n");
	  _istournament    = false;
		// We don't lock the decision here,
    // as the blind-values at some crap-casinos need to be scraped
    // and might be unreliable for the first hand.
    // Locking will happen automatically after N hands
    // with more reliable info.
    // http://www.maxinmontreal.com/forums/viewtopic.php?f=110&t=18266&p=130775#p130772
		return;
  }
  // If it is ManualMode, then we detect it by title-string "tourney".
  // High blinds (default) don~t make it a tournament.
  // Therefore don't continue.
  if (p_symbol_engine_casino->ConnectedToManualMode()) {
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] ManualMode, but no tournament identifier\n");
    return;
  }
	// If there are antes then it is a tournament.
	if (AntesPresent())	{
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] Game with antes; therefore tournament\n");
		_istournament    = true;
		_decision_locked = true;
		return;
	}
	// If bets and balances are "tournament-like", then it is a tournament
	if (BetsAndBalancesAreTournamentLike())	{
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] Bets and balances look like tournament\n");
		_istournament    = true;
		_decision_locked = true;
		return;
	}
	// Not yet sure, but we have handled so far:
	// * all lower stakes cash-games
	// * all SNGs / MTTs with good title-string
	// * all SNGs and starting tables of MTTs (by bets and balances)
	// * some later tables of MTTs (by antes)
	// * some more later tables of MTTs (if no reconnection is necessary)
	// This leaves us with only 2 cases
	// * medium and high-stakes cash-games ($5/$10 and above)
	// * some (very few) later tables of MTTs
	if (bigblind > k_large_bigblind_probably_later_table_in_tournament) {
		// Probably tournament, but not really sure yet,
		// so don't lock the decision.
		write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] bigblind very large; probably tournament\n");
		_istournament = true;
		return;
	}
	// Smaller bigblinds (< $500) will be considered cash-games, 
	// because they are too small for later tables of tournaments
	_istournament    = false;
	_decision_locked = true;
	write_log(preferences.debug_istournament(), "[CSymbolEngineIsTournament] high-stakes cash-game up to $200\\$400\n");
	// The only case that can go wrong now:
	// High-stakes cash-games ($250/$500 and above) can be recognized 
	// as tournaments. 
	// Main consequence: blinds won't be locked for the entire session,
	// but only for the current hand. Does this hurt much?
}