internal PlayingContext(Game game) { Game = game; if (game.GameType != GameType.AllPass) { mDeclarerIndex = game.Declarer.Index; } TrumpSuit = BitwiseCardHelper.SuitToBits(game.BiddingContext.TrumpSuit); InitialSuit = BitwiseCardHelper.SuitToBits(game.PlayingContext.InitialSuit); SetStateEvaluator(); }
private void CalculateCardSets() { mHandsToRandomize = mState.GetHandsToRandomize(); int handCount = mHandsToRandomize.Count; mCardCounts = new int[handCount]; mCardSets = new CardSet[handCount]; // We know own cards. int knownCards = mState.ActiveHand.Cards; // We know just played cards. for (int i = 0; i < 3; i++) { if (mState.Hands[i] != mState.ActiveHand) { knownCards |= mState.Hands[i].Move.Card; } } // We know discarded cards. knownCards |= mState.Discards; for (int i = 0; i < handCount; i++) { int handIndex = mHandsToRandomize[i]; Hand hand = mState.Game.GetHand(handIndex); mCardCounts[i] = hand.Cards.Count; int cardSet = ~knownCards; // Remove suits that the hand is known to miss. foreach (var suit in hand.VoidSuits) { cardSet &= ~BitwiseCardHelper.SuitToBits(suit); } mCardSets[i] = new CardSet(cardSet); } }