Exemplo n.º 1
0
    public static float ProbabilityOfWin(int myPoints, IEnumerable <Card> visibleCards, IEnumerable <Card> oponentPlayedCards, int sampleCount = 256)
    {
        Deck testDeck = new Deck(null);

        testDeck.Remove(visibleCards);

        int remainingCardCount = 5 - oponentPlayedCards.Count();

        int numberOfWins = 0;

        for (int i = 0; i < sampleCount; ++i)
        {
            testDeck.Shuffle();
            var remainingCards = testDeck.Deal(remainingCardCount);

            int handScore = CardAIBase.ScoreHand(CardAIBase.IdealHand(remainingCards, oponentPlayedCards));

            testDeck.Discard(remainingCards);

            if (handScore < myPoints)
            {
                ++numberOfWins;
            }
        }

        return((float)numberOfWins / sampleCount);
    }
Exemplo n.º 2
0
    public static float CalculateProbabilityOfFold(int cardsPlayed, int myScoreShowing, bool myMatch, int theirCardsPlayed, int theirScoreShowing, bool theirMatch, int sampleCount = 256)
    {
        Card[] myShowing    = FakeHand(myScoreShowing, cardsPlayed, myMatch);
        Card[] theirShowing = FakeHand(theirScoreShowing, theirCardsPlayed, theirMatch);

        Deck testDeck = new Deck(null);

        int numberOfWins = 0;

        for (int i = 0; i < sampleCount; ++i)
        {
            testDeck.Shuffle();
            var myRemaining    = testDeck.Deal(5 - cardsPlayed);
            var theirRemaining = testDeck.Deal(5 - theirCardsPlayed);

            int myScore    = CardAIBase.ScoreHand(CardAIBase.IdealHand(myRemaining, myShowing));
            int theirScore = CardAIBase.ScoreHand(CardAIBase.IdealHand(theirRemaining, theirShowing));

            testDeck.Discard(myRemaining);
            testDeck.Discard(theirRemaining);

            if (myScore > theirScore)
            {
                ++numberOfWins;
            }
        }

        return((float)numberOfWins / sampleCount);
    }
Exemplo n.º 3
0
 public override shootout.TurnResult ChooseCard(IEnumerable <Card> myShowing, IEnumerable <Card> theirShowing, int inPot, int currentBid, int currentBidScalar, int currentTurn)
 {
     shootout.CardGameState state = new shootout.CardGameState(
         CardAIBase.IdealHand(hand.UnplayedCards(), myShowing).Except(myShowing),
         myShowing,
         theirShowing,
         currentBidScalar == 0,
         currentBidScalar == 0,
         inPot,
         Mathf.Max(currentBid, 0),
         currentBidScalar
         );
     shootout.CardGameState.checkCount = 0;
     return(state.CaclulateOptimalTurn(ai));
 }
Exemplo n.º 4
0
    public void CalculateScore(int sampleSize)
    {
        Deck deck = new Deck(deckSkin);

        int[] pointCount = new int[54];

        for (int i = 0; i < sampleSize; ++i)
        {
            deck.Shuffle();
            var hand = deck.Deal(5);
            pointCount[CardAIBase.IdealScore(hand, new Card[] { })]++;
            deck.Discard(hand);
        }

        System.IO.File.WriteAllLines("point_probability.csv", pointCount.Select(point => point + "," + ((float)point / sampleSize).ToString()).ToArray());
    }
Exemplo n.º 5
0
    public static float AverageHandScore(int sampleCount = 256)
    {
        float result = 0.0f;

        Deck testDeck = new Deck(null);

        for (int i = 0; i < sampleCount; ++i)
        {
            testDeck.Shuffle();
            Card[] restOfHand = testDeck.Deal(5).ToArray();

            result += CardAIBase.IdealScore(restOfHand, new Card[] { });

            testDeck.Discard(restOfHand);
        }

        return(result / sampleCount);
    }
Exemplo n.º 6
0
 public IEnumerable <Card> ChooseCards(IEnumerable <Card> hand)
 {
     return(CardAIBase.IdealHand(hand, new Card[] { }));
 }
Exemplo n.º 7
0
 public int GetMaxScore()
 {
     return(CardAIBase.IdealScore(UnplayedCards(), playedCards));
 }