コード例 #1
0
ファイル: Strategy.cs プロジェクト: Zapp44/blackjack-repo
        public void Mutate(double impact)
        {
            // impact is the % of cells that should be mutated

            // randomly set cells in each of the arrays
            int NumPairMutations = (int)(100F * impact);     // 10 possible holdings x 10 upcards
            int NumSoftMutations = (int)(80F * impact);      // 8 possible holdings
            int NumHardMutations = (int)(160F * impact);     // 16 possible holdings

            // pairs
            for (int i = 0; i < NumPairMutations; i++)
            {
                var upcardRank     = GetRandomRankIndex();
                var randomPairRank = GetRandomRankIndex();
                SetActionForPair(upcardRank, randomPairRank, GetRandomAction(true));
            }

            // soft hands
            for (int i = 0; i < NumSoftMutations; i++)
            {
                var upcardRank      = GetRandomRankIndex();
                var randomRemainder = randomizer.IntBetween(LowestSoftHandRemainder, HighestSoftHandRemainder);
                SetActionForSoftHand(upcardRank, randomRemainder, GetRandomAction(false));
            }

            // hard hands
            for (int i = 0; i < NumHardMutations; i++)
            {
                var upcardRank = GetRandomRankIndex();
                var hardTotal  = randomizer.IntBetween(LowestHardHandValue, HighestHardHandValue);
                SetActionForHardHand(upcardRank, hardTotal, GetRandomAction(false));
            }
        }