Exemplo n.º 1
0
        private float TakeOtherPlayerTurn(float foldProb, int bid, int bidScalar, CardGameAI ai)
        {
            // other player responds
            CardGameState nextState = Clone();

            nextState.currentBid       = bid;
            nextState.currentBidScalar = bidScalar;
            nextState.amountInPot     += bid;
            nextState.AdvanceTurn();

            TurnResult subResult = nextState.CaclulateOptimalTurn(ai);

            return(subResult.value * (1 - foldProb) + amountInPot * foldProb);
        }
Exemplo n.º 2
0
        public CardGameState Clone()
        {
            CardGameState result = new CardGameState();

            result.aiPlayer.CloneFrom(aiPlayer);
            result.otherPlayer.CloneFrom(otherPlayer);
            result.round            = round;
            result.isFirstTurn      = isFirstTurn;
            result.isAIFirst        = isAIFirst;
            result.amountInPot      = amountInPot;
            result.currentBid       = currentBid;
            result.currentBidScalar = currentBidScalar;

            return(result);
        }
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
        private TurnResult TakeAITurn(int bid, int bidScalar, CardGameAI ai)
        {
            TurnResult result = shootout.TurnResult.Fold();


            aiPlayer.ForEachInHand((index) =>
            {
                CardGameState nextState = Clone();

                Card cardPlayed = nextState.aiPlayer.PlayCard(index);

                if (round == 2 && nextState.aiPlayer.CanPlayTriple())
                {
                    nextState.aiPlayer.ForEachInHand((fourthIndex) =>
                    {
                        CardGameState fourthPlayState = nextState.Clone();

                        Card fourthCard = fourthPlayState.aiPlayer.PlayFourthCard(fourthIndex);

                        float score = fourthPlayState.FinishAITurn(bid, bidScalar, ai);

                        if (score > result.value)
                        {
                            result.value      = score;
                            result.chosenCard = cardPlayed;
                            result.bid        = nextState.currentBid;
                            result.fourthCard = fourthCard;
                        }
                    });
                }
                else
                {
                    float score = nextState.FinishAITurn(bid, bidScalar, ai);

                    if (score > result.value)
                    {
                        result.value      = score;
                        result.chosenCard = cardPlayed;
                        result.bid        = nextState.currentBid;
                    }
                }
            });

            return(result);
        }