void CSymbolEngineChipAmounts::CalculatePots() {
	_pot = 0;
	_potplayer = 0;
	_potcommon = 0;
	for (int i=0; i<p_tablemap->nchairs(); i++) {
    assert(_currentbet[i] >= 0.0);
		_potplayer += _currentbet[i];	
	}
  assert(_potplayer >= 0.0);
	// pot, potcommon, based on value of potmethod
	if (p_tablemap->potmethod() == 2)	{
		_pot = p_table_state->_pot[0];
		_potcommon = _pot - _potplayer;
	}
	else if(p_tablemap->potmethod() == 3) {
		_pot = p_table_state->_pot[0];
		for (int i=1; i<k_max_number_of_pots; i++) {
			_pot = max(_pot, p_table_state->_pot[i]);
		}
		_potcommon = _pot - _potplayer;
	} else { // potmethod() == 1
		_potcommon = 0;
		for (int i=0; i<k_max_number_of_pots; i++) {
			_potcommon += p_table_state->_pot[i];
		}
		_pot = _potcommon + _potplayer;
	}
  // Avoiding problems with floatingpoint-representations here
  // http://www.maxinmontreal.com/forums/viewtopic.php?f=110&t=17984#p125241
  if (IsSmaller(_potcommon, 0)) {
	  // This can happen for potmethod = 2 and incorrectly scraped (occluded) main-pot
	  write_log(k_always_log_errors, "[CSymbolEngineChipAmounts] ERROR: negative potcommon. Probably miss-scraped main-pot. Adapting to 0.0\n");
	  _potcommon = 0;
  }
}
double CParseTreeNode::EvaluateBinaryExpression(bool log) {
  assert(_first_sibbling  != NULL);
  assert(_second_sibbling != NULL);
  assert(_third_sibbling  == NULL);
  assert(_terminal_name == "");
	double value_of_first_sibbling  = EvaluateSibbling(_first_sibbling, log);
	double value_of_second_sibbling = 0.0;
	// Short circuiting
	// Don't evaluate unnecessary parts of expressions
	if (_node_type == kTokenOperatorLogicalAnd)	{
		if (value_of_first_sibbling == false) {
			return false;
		}
		value_of_second_sibbling = EvaluateSibbling(_second_sibbling, log);
		return (value_of_second_sibbling ? true : false);
	}	else if (_node_type == kTokenOperatorLogicalOr)	{
    // Attention!
    // We can not look here for "value_of_first_sibbling == true"
    // because this way we would only accept true (==1)
    // but we want to accept any non-zero value.
    // http://www.maxinmontreal.com/forums/viewtopic.php?f=111&t=17899
		if (value_of_first_sibbling) {
			return true;
		}
		value_of_second_sibbling = EvaluateSibbling(_second_sibbling, log);
		return (value_of_second_sibbling ? true : false);
	}
	// Short circuiting done
	// Now normal evaluation of operators that need both operands
	value_of_second_sibbling = EvaluateSibbling(_second_sibbling, log);
	switch (_node_type) {
	  case kTokenOperatorPlus: 
		  return value_of_first_sibbling + value_of_second_sibbling;
	  case kTokenOperatorMinus: 
		  return value_of_first_sibbling - value_of_second_sibbling;
	  case kTokenOperatorMultiplication: 
		  return value_of_first_sibbling * value_of_second_sibbling;
	  case kTokenOperatorDivision: 
		  if (value_of_second_sibbling == 0) {
			  OH_MessageBox_Error_Warning("Division by zero.");
			  return kUndefined;
		  } else {
			  return value_of_first_sibbling / value_of_second_sibbling;
		  }
	  case kTokenOperatorModulo: 
      if (value_of_second_sibbling == 0) {
			  OH_MessageBox_Error_Warning("Division by zero.");
			  return kUndefined;
		  } else {
			  return (unsigned long)value_of_first_sibbling 
				  % (unsigned long)value_of_second_sibbling;
		  }
	  case kTokenOperatorExponentiation: 
		  return pow(value_of_first_sibbling, value_of_second_sibbling);
	  case kTokenOperatorEquality: 
		  return IsEqual(value_of_first_sibbling, value_of_second_sibbling);
	  case kTokenOperatorApproximatellyEqual: 
		  return IsApproximatellyEqual(value_of_first_sibbling, value_of_second_sibbling);
	  case kTokenOperatorSmaller: 
		  return IsSmaller(value_of_first_sibbling, value_of_second_sibbling);
	  case kTokenOperatorSmallerOrEqual: 
		  return IsSmallerOrEqual(value_of_first_sibbling, value_of_second_sibbling);
	  case kTokenOperatorGreater: 
		  return IsGreater(value_of_first_sibbling, value_of_second_sibbling);
	  case kTokenOperatorGreaterOrEqual: 
		  return IsGreaterOrEqual(value_of_first_sibbling, value_of_second_sibbling);
	  case kTokenOperatorNotEqual: 
	  case kTokenOperatorLogicalXOr: 
		  return value_of_first_sibbling != value_of_second_sibbling;
	  case kTokenOperatorBinaryAnd: 
		  return (unsigned long)value_of_first_sibbling 
			  & (unsigned long)value_of_second_sibbling;
	  case kTokenOperatorBinaryOr: 
		  return (unsigned long)value_of_first_sibbling 
			  | (unsigned long)value_of_second_sibbling;
	  case kTokenOperatorBinaryXOr: 
		  return (unsigned long)value_of_first_sibbling 
			  ^ (unsigned long)value_of_second_sibbling;
	  case kTokenOperatorBitShiftLeft: 
		  return (unsigned long)value_of_first_sibbling 
			  << (unsigned long)value_of_second_sibbling;
	  case kTokenOperatorBitShiftRight: 
		  return (unsigned long)value_of_first_sibbling 
			  >> (unsigned long)value_of_second_sibbling;
	  case kTokenOperatorPercentage: 
		  return value_of_first_sibbling * value_of_second_sibbling * 0.01;
	  default: assert(false);
	}
	return kUndefined;
}