// 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(); }
// Resets the memory of the knowledge state at the start of each round public void Reset() { CurrentOpponentCount = PlayerCount - 1; SetMyHand(0, 0); Array.Clear(PlayerIsKnockedOut, 0, PlayerCount); Array.Copy(GameController.CARD_COUNT, CountUnaccountedForCards, GameController.CARD_COUNT.Length); DeckDistribution.CopyFrom(BaseDeckDistribution); ThreeOpponentsHandsDistribution.CopyFrom(BaseThreeOpponentsHandsDistribution); ResetOpponentsBeliefsAboutMyHand(); // Sort the hidden hands' sitting order again int hiddenHandIndex = 0; for (int p = 0; p < PlayerCount; p++) { if (p != MySittingOrder) { HiddenHands[hiddenHandIndex++] = p; HandDistribution[p].CopyFrom(BaseDeckDistribution); } } }