Esempio n. 1
0
void PrintPosition(POSITION position, STRING playerName, BOOLEAN usersTurn)
{
	int *arrayHashedBoard, i;

	arrayHashedBoard = array_hash(position);

	for(i = 1, printf("\nP2 Bin #  "); i < mancalaR; printf("\t %d", i), i += 1) ;
	printf("\n\t");
	for(i = 1; i < mancalaR; i += 1) {
		printf("\t[%d]", arrayHashedBoard[i]);
	}

	printf("\n\t[%d]", arrayHashedBoard[mancalaL]);
	for(i = 1; i <= mancalaR; printf("\t"), i += 1) ;
	printf("[%d]\n\t", arrayHashedBoard[mancalaR]);

	for(i = boardSize - 1; i > mancalaR; i -= 1) {
		printf("\t[%d]", arrayHashedBoard[i]);
	}
	for(i = mancalaR + 1, printf("\nP1 Bin #  "); i < boardSize;
	    printf("\t %d", i), i += 1) ;

	printf("\n%s\n\n", GetPrediction(position, playerName, usersTurn));

	SafeFree(arrayHashedBoard);
}
Esempio n. 2
0
void PrintPosition (POSITION position, STRING playersName, BOOLEAN usersTurn)
{
	generic_hash_unhash(position, gBoard);
	printf("   Board         Key\n");
	printf("     %c            3\n",gBoard[3]);
	printf("  %c  |  %c      2  |  4\n", gBoard[2], gBoard[4]);
	printf("   \\ | /        \\ | /\n");
	printf(" %c-- %c --%c    1-- 0 --5\n", gBoard[1], gBoard[0], gBoard[5]);
	printf("   / | \\        / | \\\n");
	printf("  %c  |  %c      8  |  6\n", gBoard[8], gBoard[6]);
	printf("     %c            7\n", gBoard[7]);
	printf("\n%s's Turn(%c)\n", playersName, (generic_hash_turn (position)) == 1 ? 'x' : 'o');
	printf("%s\n", GetPrediction(position,playersName,usersTurn));

}
Esempio n. 3
0
void PrintPosition(POSITION position, STRING playerName, BOOLEAN usersTurn)
{
	int i, j;
	int positionBak = position;
	position /=2;
	printf("\n");
	for(i = 0; i < rows; i++)
	{
		printf("%d: ", i+1);
		for(j = 0; j < position % 8; j++)
			printf("O ");
		printf("\n");
		position = position >> 3;
	}
	printf("\n%s\n", GetPrediction(positionBak, playerName, usersTurn));
	printf("%s\n\n", GetSEvalPrediction(positionBak, playerName, usersTurn));
}
Esempio n. 4
0
void PrintPosition (POSITION position, STRING playersName, BOOLEAN usersTurn){
	char* board;
	int turn, x, y, reds, blues;
	board = unhash(position, &turn);
	countPieces(board, &reds, &blues);
	printf("\t%s's Turn (%s):\n  ",playersName,(turn==PLAYER_ONE ? "BLACK" : "WHITE"));
	printf("%s\n", GetPrediction(position, playersName, usersTurn));
	for (y = length; y >= 0; y--) { // for all the rows
		if (y == 0) {
			printf("    ");
			for (x = 0; x < width; x = x + 1) {
				printf("%c   ", 'a' + x);
			}
		} else {
			printf(" %2d ", y); //print row number
			for (x = 1; x <= width; x++) {
				if (x+1 <= width) {
					printf("%c - ",board[toIndex(x,y)]);
				} else {
					printf("%c",board[toIndex(x,y)]);
				}
			}
			printf("\n");
			if (y > 1) {
				printf("    ");
				for (x = 0; x < width; x++) {
					printf("|   ");
				}
				printf("\n");
			}
		}
	}
	printf("\n\n");
	if(board != NULL)
		SafeFree(board);
}
Esempio n. 5
0
double PathRecord::CalcConfidence() const
{
	double	w, v;
	GetPrediction( w, v );
	return CalcConfidence(w, v);
}
Esempio n. 6
0
void PrintPosition (POSITION position, STRING playersName, BOOLEAN usersTurn)
{

    int n, row, i, col;
    char* board;
    char horizchar;

    board = (char*)SafeMalloc((possize)*sizeof(char));

    generic_hash_unhash(position, board);

    if(swapmode == SWAP_DIRECTION || swapmode == SWAP_BOTH)
        horizchar = board[possize - 1];
    else
        horizchar = (DEFAULT_HORIZPLAYER == WHITEPLAYER ? WHITECHAR : BLACKCHAR);

    printf("\n\n\n\n");

    printf("  %s's turn (%c):\n\n", playersName, generic_hash_turn(position) == 1 ? WHITECHAR : BLACKCHAR);

    printf("  %c: horizontal\n", horizchar);
    printf("  %c: vertical\n\n", horizchar == WHITECHAR ? BLACKCHAR : WHITECHAR);

    printf("    ");

    for(i = 0; i < boardcols; i++) {
        printf("/ \\ ");
    }
    printf("\n");

    for(row = 0; row < boardrows; row++) {
        for(i = 0; i < row; i++)
            printf("  ");
        printf(" %c |", '0'+row);
        for(col = 0; col < boardcols; col++)
            printf(" %c |", board[row*boardcols+col]);
        printf("\n    ");
        for(i = 0; i < row; i++) {
            printf("  ");
        }
        for(i = 0; i < boardcols; i++)
            printf("\\ / ");
        if(row != boardrows-1) printf("\\");
        printf("\n");
    }
    printf("   ");
    for(col = 0; col < boardrows; col++)
        printf("  ");

    printf(" ");
    for(n = 0; n < boardcols; n++)
        printf("%c   ", 'a'+n);

    printf("\n\n");

    printf(GetPrediction(position, playersName, usersTurn));
    printf("\n\n");

    SafeFree(board);

}
const utf32* TextDecorator::_ParserText(const utf32*ptr, ITextDecorateNode* parent)
{

	enum EState
	{
		ENormal,
		ETagOpen,
		ETagClose,
		ETagEnder,
		EInStartTag,
		EInEndTag
	};

	EState state=ENormal;

	bool tagStart=false;
	bool tagEnd=false;
	core::UTFString tagName;
	core::UTFString tagValue;
	core::UTFString text;

	bool readingValue=false;
	bool skipChar=false;

	ITextDecorateNode* node=0;

	while(*ptr)
	{
		utf32 c = *ptr;
		if(!skipChar)
		{
			switch (c)
			{
			case '<':
				{
					EPredictionResult r=GetPrediction(ptr);
					if(r!=ENormalText && text!=core::UTFString::Empty)
					{
						TextDecorateNode*d=new TextDecorateNode(text.GetAsString());
						parent->AddChild(d);
						text = core::UTFString::Empty;
					}
					if(r==EOpenTag)
					{
						state=ETagOpen;
						if(!tagStart)
							tagStart=true;
						tagName = core::UTFString::Empty;
						tagValue = core::UTFString::Empty;
						readingValue=false;
					}else if(r==ECloseTag)
					{
						++ptr;
						state=EInEndTag;
						if(!tagEnd)
							tagEnd=true;
						tagName = core::UTFString::Empty;
					}else
						state=ENormal;
				}
				break;
			case '>':
				if(state==EInEndTag)
				{
					return ptr;
				}else if(state==EInStartTag)
				{
					//create Node
					node=TextDecorateNodeFactory::getInstance().CreateNode(tagName.GetAsString());
					node->ParseParameter(tagValue);
					if(parent)
						parent->AddChild(node);

					ptr=_ParserText(ptr+1,node);
				}
				state=ETagClose;
				break;
			case '\\':
				if(state==ENormal && !skipChar){
					skipChar=true;
					continue;
				}
				break;
			case '=':
				if(state==EInStartTag){
					readingValue=true;
				}
				break;
			default:
				if(state==ETagOpen)
					state=EInStartTag;

				if(state==EInStartTag ){
					if(!readingValue)
						tagName+=c;
					else tagValue+=c;
				}else if(state==EInEndTag)
				{
					tagName+=c;
				}else{
					state=ENormal;
				}

			}
		}
		if(state==ENormal)
			text+=c;
		skipChar=false;

		++ptr;
	}
	return ptr;
}