コード例 #1
0
 public void HandleGain(Gain gain)
 {
     if (IsReadyForGain(gain.Card))
     {
         IncrementProgress(gain.Card.GetSuit());
     }
     else
     {
         SpendDeathToken();
     }
 }
コード例 #2
0
        public Move Yolo()
        {
            var       canBurn             = game.CanBurn();
            var       knownRemainingCards = KnownRemainingCards();
            const int goodGainValue       = 30;
            var       badGainValue        = game.GetNextDeathTokenValue();
            var       goodBurnValue       = canBurn ? game.GetNextHintTokenValue() : 0;
            const int badBurnValue        = -10;

            var  bestUtility = double.MinValue;
            Move bestMove    = null;

            foreach (var card in cards)
            {
                var probabilities       = card.CalculateProbabilityOfSafePlays(knownRemainingCards, game.Progress);
                var safeGainProbability = probabilities.Item1;
                var safeBurnProbability = probabilities.Item2;

                var gainUtility = (goodGainValue * safeGainProbability) + (badGainValue * (1 - safeGainProbability));
                var burnUtility = canBurn ? (goodBurnValue * safeBurnProbability) + (badBurnValue * (1 - safeGainProbability)) : int.MinValue;

                if (gainUtility > bestUtility)
                {
                    bestMove    = new Gain(card);
                    bestUtility = gainUtility;
                }

                if (burnUtility > bestUtility)
                {
                    bestMove    = new Burn(card);
                    bestUtility = burnUtility;
                }
            }

            return(bestMove);
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: astennent/hanabi-ai
        public Move Yolo()
        {
            var canBurn = game.CanBurn();
             var knownRemainingCards = KnownRemainingCards();
             const int goodGainValue = 30;
             var badGainValue = game.GetNextDeathTokenValue();
             var goodBurnValue = canBurn ? game.GetNextHintTokenValue() : 0;
             const int badBurnValue = -10;

             var bestUtility = double.MinValue;
             Move bestMove = null;

             foreach (var card in cards)
             {
            var probabilities = card.CalculateProbabilityOfSafePlays(knownRemainingCards, game.Progress);
            var safeGainProbability = probabilities.Item1;
            var safeBurnProbability = probabilities.Item2;

            var gainUtility = (goodGainValue * safeGainProbability) + (badGainValue * (1 - safeGainProbability));
            var burnUtility = canBurn ? (goodBurnValue * safeBurnProbability) + (badBurnValue * (1 - safeGainProbability)) : int.MinValue;

            if (gainUtility > bestUtility)
            {
               bestMove = new Gain(card);
               bestUtility = gainUtility;
            }

            if (burnUtility > bestUtility)
            {
               bestMove = new Burn(card);
               bestUtility = burnUtility;
            }
             }

             return bestMove;
        }