コード例 #1
0
ファイル: KI.cpp プロジェクト: KiGhost/Poker_AI
void KI::performRiver()
{
	checkOwnedCombinations();

	int highestCardComboRank = 0;

	for (int i = 0; i < 10; ++i)
	{
		if (ownedCardCombinations[i].getComboOwned())
		{
			highestCardComboRank = ownedCardCombinations[i].getComboCardRanking();
		}
	}

	if (highestCardComboRank == 2)
	{
		raising(ptr_roundManager->getPot() * 2);
	}
	else if (highestCardComboRank > 2)
	{
		raising(ptr_roundManager->getPot() * 2);
	}


	// check cardOuts to the potOdds
	if (getPercentagePotOdds() > ptr_kiCalculator->getProbabilityDrawingUsefulCard(currentRound + 1))
	{
		float differencePotOuts = getPercentagePotOdds() - ptr_kiCalculator->getProbabilityDrawingUsefulCard(currentRound + 1);

		// DEBUG
		std::cout << differencePotOuts << std::endl;

		if (differencePotOuts >= 0.2f) // >= 20%
		{
			raising(ptr_roundManager->getCurrentMaxBet() * 2);
		}
		else if (differencePotOuts < 0.2f) // < 20%
		{
			calling();
		}
	}
	else
	{
		folding();
	}
}
コード例 #2
0
ファイル: VObject.cpp プロジェクト: ruphy/kfunambol
/*
 * Returns the VCard - iCal string fro this VObject.
 * Note:
 * The returned WCHAR* is new allocated, must be freed by the caller.
 */
WCHAR* VObject::toString() {

    WString strVObject;

    bool is_30 = false;
    if (version) {
        is_30 = !wcscmp(getVersion(), TEXT("3.0"));
    }

    // *** FIXME ***
    // By now folding feature not supported on server...
    bool useFolding = false;

    // let's reserve some space to avoid reallocation in most cases
    strVObject.reserve(5000);

    for (int i=0; i<properties->size(); i++) {
        VProperty *prop = getProperty(i);
        WCHAR* propString = prop->toString(version);
        WCHAR* valueConv = NULL;

        // Folding
        if (useFolding && wcslen(propString) > VCARD_MAX_LINE_LEN) {
            valueConv = folding(propString, VCARD_MAX_LINE_LEN);
            strVObject.append(valueConv);
        }
        else {
            strVObject.append(propString);
        }
        strVObject.append(RFC822_LINE_BREAK);

        if (propString) {
            delete [] propString;  propString = NULL;
        }
        if (valueConv) {
            delete [] valueConv;   valueConv = NULL;
        }
    }

    // memory must be free by caller with delete []
    WCHAR *str = wstrdup(strVObject);
    return str;
}
コード例 #3
0
QsciEditor::QsciEditor( QWidget *parent ) : QsciScintilla( parent ) {

	setFocus();

	/* Set tab width, and fonts */
	setTabWidth( 4 );
	setFont( QFont( "Envy Code R", 9 ) );
	setTabIndents( true );
	setIndentationsUseTabs( true );

	/* Set folding style */
	setFolding( QsciScintilla::BoxedTreeFoldStyle );

	/* Remove Horizontal Scrollbar, put a Vertical one */
	setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
	setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );

	/* Whitespace, indentation markings, and eol */
	setIndentationGuides( false );
	setWhitespaceVisibility( WsInvisible );
	setEolMode( EolUnix );

	/* Create Margins */
	setMarginWidth( 0, QString( " %1 " ).arg( lines() ) );
	setMarginWidth( 1, " " );
	setMarginWidth( 2, 10 );
	setMarginsFont( QFont( "Envy Code R", 9 ) );
	setWrapMode( QsciScintilla::WrapWord );

	/* Current Line Visibility */
	ensureCursorVisible();
	setCaretLineVisible( true );
	setCaretLineBackgroundColor( QColor( "#555555" ) );
	setCaretForegroundColor( QColor( "#FAFFAF" ) );
	setCaretWidth( 2 );

	/* Selection Color */
	// setSelectionBackgroundColor( "#333964" );
	// setSelectionForegroundColor( "*" );

	/* Margin and folding margins background colors */
	setMarginsBackgroundColor( QColor( "#A0A0A0" ) );
	setFoldMarginColors( QColor( "#666666" ), Qt::black );

	/* Set the width of the line */
	setLineWidth( 144 );
	ensureLineVisible( true );

	/* Set the paper and pen color - Editor BG and FG color */
	setPaper( Qt::black );
	setColor( Qt::white );

	/* Brace coloring */
	setBraceMatching( QsciScintilla::SloppyBraceMatch );
	setUnmatchedBraceForegroundColor( Qt::red );
	setUnmatchedBraceBackgroundColor( Qt::black );
	setMatchedBraceForegroundColor( Qt::darkGreen );
	setMatchedBraceBackgroundColor( Qt::black );

	/* Multi-selection and typing */
	SendScintilla( SCI_SETADDITIONALSELECTIONTYPING, true );
	SendScintilla( SCI_SETMULTIPLESELECTION, true );
	SendScintilla( SCI_SETMULTIPASTE, true );

	/* Scroll beyond the last line */
	SendScintilla( SCI_SETENDATLASTLINE, false );

	/* Set the editor state as not modified */
	setModified( false );

	/* Auto Save Timer: 60 sec */
	autoSaveTimer = new QBasicTimer();

	/* Enable and Show Custom context Menu */
	setContextMenuPolicy( Qt::CustomContextMenu );

	/* Connections */
	setupActions();

	/* Default Lexer */
	setLexer( new QLexerDefault() );

    QsciScintilla::FoldStyle state = static_cast<QsciScintilla::FoldStyle>( ( !folding() ) * 5 );
    if ( !state )
        foldAll( false );
    setFolding( state );
};