Пример #1
0
    // Card filter: GUARD, when played against anyone but me.
    public void GuardFilter(int TargetSittingOrder, int GuessedValue)
    {
        Debug.Assert(TargetSittingOrder != MySittingOrder);
        Debug.Assert(GuessedValue >= CardController.VALUE_PRIEST && GuessedValue <= CardController.VALUE_PRINCESS);
        int CardIndex       = GuessedValue - 1;
        int HiddenHandIndex = GetHiddenHandIndex(TargetSittingOrder);

        // Update and renormalize the appropriate matrix
        if (CurrentOpponentCount == 3)
        {
            // In case of THREE remaining opponents, update the ThreeOpponentsHandsDistribution
            ThreeOpponentsHandsDistribution.ClearSlice(HiddenHandIndex, CardIndex);
            ThreeOpponentsHandsDistribution.Renormalize();
        }
        else if (CurrentOpponentCount == 2)
        {
            // In case of TWO remaining opponents, update the TwoOpponentsHandsDistribution
            TwoOpponentsHandsDistribution.ClearSlice(HiddenHandIndex, CardIndex);
            TwoOpponentsHandsDistribution.Renormalize();
        }
        else if (CurrentOpponentCount == 1)
        {
            // In case of ONE remaining opponents, update the SingleOpponentHandDistribution
            SingleOpponentHandDistribution[CardIndex] = 0;
            SingleOpponentHandDistribution.Renormalize();
        }
    }
Пример #2
0
 // During the basic opponent turn update, we need to update the joint probability distribution
 // using just the information about which card he has just played
 protected void FilterHiddenHand(MoveData TurnData)
 {
     Debug.Assert(TurnData.Player.SittingOrder != MySittingOrder);
     Debug.Assert(!PlayerIsKnockedOut[TurnData.Player.SittingOrder]);
     Debug.Assert(TurnData.Card.Value >= CardController.VALUE_GUARD && TurnData.Card.Value <= CardController.VALUE_PRINCESS);
     // Update the hand distribution matrices
     if (CurrentOpponentCount == 3)
     {
         // Prepare a temporary array
         tempArray3D.Clear();
         // Loop through all possible world states and update the tempoprary array accordingly
         for (int h0 = 0; h0 < CARD_VECTOR_LENGTH; h0++)
         {
             for (int h1 = 0; h1 < CARD_VECTOR_LENGTH; h1++)
             {
                 for (int h2 = 0; h2 < CARD_VECTOR_LENGTH; h2++)
                 {
                     UpdatePartialHandDistribution(TurnData, h0, h1, h2, ref tempArray3D);
                 }
             }
         }
         // Renormalize the temporary array and write it back to the three-player distribution
         tempArray3D.Renormalize();
         ThreeOpponentsHandsDistribution.CopyFrom(tempArray3D);
     }
     else if (CurrentOpponentCount == 2)
     {
         // Prepare a temporary array
         tempArray2D.Clear();
         // Loop through all possible world states and update the tempoprary array accordingly
         for (int h0 = 0; h0 < CARD_VECTOR_LENGTH; h0++)
         {
             for (int h1 = 0; h1 < CARD_VECTOR_LENGTH; h1++)
             {
                 UpdatePartialHandDistribution(TurnData, h0, h1, ref tempArray2D);
             }
         }
         // Renormalize the temporary array and write it back to the two-player distribution
         tempArray2D.Renormalize();
         TwoOpponentsHandsDistribution.CopyFrom(tempArray2D);
     }
     else if (CurrentOpponentCount == 1)
     {
         // Prepare a temporary array
         tempArray1D.Clear();
         // Loop through all possible world states and update the tempoprary array accordingly
         for (int h0 = 0; h0 < CARD_VECTOR_LENGTH; h0++)
         {
             UpdatePartialHandDistribution(TurnData.Card.Value - 1, h0, ref tempArray1D);
         }
         // Renormalize the temporary array and write it back to the one-payer distribution
         tempArray1D.Renormalize();
         SingleOpponentHandDistribution.CopyFrom(tempArray1D);
     }
     // Finally, recalculate utility arrays
     RecalculateHandAndDeckdistributions();
 }