Example #1
0
void KnowledgeBase::InitKB( Set<Card> oSet )
{
	oSet.Begin();
	while( oSet.HasNext() )
	{
		Card* pCard = oSet.GetNext();
		if ( i_KitID == ( pCard->GetID() & (SUIT::SUIT_MASK | KIT::KIT_MASK) ) )
		{
			SetState(i_ThisPlayerID, pCard->GetID(), STATE::HAVE);
			for(int i=0; i<NUM_PLAYERS; ++i)
			{
				if ( i != i_ThisPlayerID )
				{
					SetState(i, pCard->GetID(), STATE::DONT_HAVE);
				}
			}
		}
	}

	// There cannot be NOT_CHECKED states in this player's positions, turn them to DONT_HAVE
	for (int i = 0; i < NUM_CARDS; ++i)
	{
		if ( GetState(i_ThisPlayerID, GetCardIDFromIndex(i)) == STATE::NOT_CHECKED )
		{
			SetState(i_ThisPlayerID, GetCardIDFromIndex(i), STATE::DONT_HAVE);
		}
	}
}
Example #2
0
// Assumes the input set only contains cards of a single kit
Set<Card>* DifferentialFilter::Enter( Set<Card>* pInput )
{
	pInput->Begin();
	if ( pInput->HasNext() )
	{
		Card* pCard = pInput->GetNext();
		int iSuit	= pCard->GetSuit();
		int iKit	= pCard->GetKit();

		Set<Card>* pCompleteKit = Deck::GetInstace()->GetKit( iSuit | iKit );
		Set<Card>* pResultSet = new Set<Card>();
		
		for (pCompleteKit->Begin(); pCompleteKit->HasNext();)
		{
			Card* pResultCard = pCompleteKit->GetNext();
			bool bRequired = true;

			for (pInput->Begin(); pInput->HasNext();)
			{
				Card* pInputCard = pInput->GetNext();
				if ( pResultCard->GetID() == pInputCard->GetID() )
				{
					bRequired = false;
					break;
				}
			}

			if (bRequired)
			{
				pResultSet->PushBack(pResultCard);
			}
		}

		return pResultSet;
	}

	return NULL;
}