Пример #1
0
/* Move is in form of 103, where 1 is the player's turn and 3 is the matches taken off */
MOVELIST *GenerateMoves (POSITION position)
{
	MOVELIST *moves = NULL;
	int matchCount = numberOfMatches(position);
	int whoseTurn = playersTurn(position);
	int moveCount = 1; /* Minimum move is 1 */
	if(matchCount == 0) {
		moves = CreateMovelistNode(whoseTurn*MULTIPLE, moves);
	}
	else
	if(whoseTurn == FIRST_TURN) {
		while(matchCount > 0 && moveCount <= MAXMOVE) {
			moves = CreateMovelistNode(FIRST_TURN*MULTIPLE + moveCount, moves);
			--matchCount;
			++moveCount;
		}
	}
	else {
		while(matchCount > 0 && moveCount <= MAXMOVE) {
			moves = CreateMovelistNode(SECOND_TURN*MULTIPLE + moveCount, moves);
			--matchCount;
			++moveCount;
		}
	}

	return moves;
}
Пример #2
0
unsigned int Tags::numberOfMatches( const QString & tagpart, bool partial )
{
    unsigned int n = 0;
    QStringList::iterator it;
    for (it = _tagFiles.begin(); it != _tagFiles.end(); it++)
    {
        n += numberOfMatches( (*it).ascii(), tagpart, partial );
    }

    return n;
}
Пример #3
0
void PrintPosition (POSITION position, STRING playersName, BOOLEAN usersTurn)
{
	int i;
	int currentMatches = numberOfMatches(position);
	printf("\n");
	printf("\n");
	printf(" ");
	for(i = 0; i < currentMatches; i++) {
		printf("O ");
	}
	printf("\n");
	for(i = 0; i < currentMatches; i++) {
		printf("/ ");
	}
	printf("\n");
	printf("\n");
	printf("The number of matches currently on the board: %d \n", currentMatches);
	printf("The number of matches first player has is: %d \n", firstPlayerMatches(position));
	printf("The number of matches second player has is: %d \n", secondPlayerMatches(position));
	printf("\n");
}
Пример #4
0
unsigned int Tags::numberOfExactMatches( const QString & tagpart )
{
    return numberOfMatches( tagpart, false );
}
Пример #5
0
unsigned int Tags::numberOfPartialMatches( const QString & tagpart )
{
    return numberOfMatches( tagpart, true );
}