示例#1
0
 public void DumpToResultsLog(BetHandResult betHandResult)
 {
     if (ResultsWriter != null)
     {
         try
         {
             ResultsWriter.WriteLine(betHandResult.ConvertToString());
         }
         catch (Exception ex)
         {
             TraceWrapper.LogException(ex, "Cannot save results to a txt file!");
         }
     }
 }
示例#2
0
        public void Update(BetHandResult betHandResult, StreamWriter aggregatedDataWriter)
        {
            TotalBetStatistics.Update(betHandResult);
            TotalAggregatedStatistics.UpdateAndLogData(betHandResult, aggregatedDataWriter);
            WealthStatistics.Update(betHandResult);

            var trueCount = betHandResult.TrueCountBeforeBet;
            var trueCountBetStatsBit = TrueCountStatistics.Where(item => item.TrueCount == trueCount).FirstOrDefault();
            if (trueCountBetStatsBit != null)
            {
                trueCountBetStatsBit.Update(betHandResult);
            }
            else
            {
                var newTrueCountBetStatsBit = new TrueCountBetStatsBit
                {
                    TrueCount = trueCount,
                    BetStatistics = new BetStatistics(),
                    AggregatedStatistics = new AggregatedStatistics(AggregatedHandsCount)
                };
                newTrueCountBetStatsBit.Update(betHandResult);
                TrueCountStatistics.Add(newTrueCountBetStatsBit);
            }
        }
示例#3
0
        public void Update(BetHandResult betHandResult)
        {
            NumberOfObservations++;
            WealthValue += betHandResult.Payoff;
            if (ConsumptionRate > 0)
            {
                var toConsume = Math.Round(WealthValue * ConsumptionRate);
                ConsumptionValue += toConsume;
                WealthValue -= toConsume;
            }

            if (NumberOfObservations % AggregatedHandsCount == 0)
            {
                Reset();
            }

            if (WealthValue <= 0)
            {
                var message = String.Format("Bankruptcy has occured in {0}th played hand, wealth reset to initial value!", NumberOfObservations);
                TraceWrapper.LogInformation(message);

                Reset();
            }
        }
示例#4
0
        public void Update(BetHandResult betHandResult)
        {
            TotalInitialBet += betHandResult.BetSize;
            TotalBet += betHandResult.BetTotal;
            TotalPal += betHandResult.Payoff;
            NumberOfBets++;
            var iba = betHandResult.Payoff / betHandResult.BetSize;
            var tba = betHandResult.Payoff / betHandResult.BetTotal;
            MeanIba = (MeanIba * (NumberOfBets - 1) + iba) / (double)NumberOfBets;
            MeanTba = (MeanTba * (NumberOfBets - 1) + tba) / (double)NumberOfBets;

            SumQuadIba += Math.Pow(iba, 2);
            SumQuadTba += Math.Pow(tba, 2);
            SumQuadPal += Math.Pow(betHandResult.Payoff, 2);
        }
示例#5
0
 public void Update(BetHandResult betHandResult)
 {
     BetStatistics.Update(betHandResult);
     AggregatedStatistics.UpdateAndLogData(betHandResult);
 }
示例#6
0
 public void Update(BetHandResult betHandResult)
 {
     Statistics.Update(betHandResult, AggregatedDataWriter);
     DumpToResultsLog(betHandResult);
 }
示例#7
0
        public BetHandResult BetHand(double betSize, CardShoe shoe)
        {
            // save the True Count before bet
            int trueCountBeforeBet = 0;
            if (shoe.Count != null)
            {
                trueCountBeforeBet = shoe.Count.TrueCount;
            }

            // initial deal
            Hand handPlayer = new Hand();
            handPlayer.InitialDealPlayer(shoe);
            Hand handDealer = new Hand();
            handDealer.InitialDealDealer(shoe);
            int numberOfSplits = 0;

            // play hand
            var betHandResult = new BetHandResult();
            betHandResult.TrueCountBeforeBet = trueCountBeforeBet;
            betHandResult.BetSize = betSize;
            PlayHandOutcome playHandOutcome = PlayHand(handPlayer, handDealer, betSize, shoe, ref numberOfSplits);

            // update bet hand results
            betHandResult.NumberOfSplits = numberOfSplits;
            betHandResult.BetTotal = playHandOutcome.BetTotal;
            var payoff = PayoffHand(playHandOutcome, handDealer, shoe);
            betHandResult.Payoff = payoff;

            // update count with the hole card revealed
            shoe.Count.Update(handDealer.Cards[1], shoe.LeftPacksCount);

            return betHandResult;
        }
示例#8
0
 public void UpdateAndLogData(BetHandResult betHandResult, StreamWriter writer = null)
 {
     NumberOfObservations++;
     AggregatedPal += betHandResult.Payoff;
     AggregatedTotalBet += betHandResult.BetTotal;
     AggregatedInitialBet += betHandResult.BetSize;
     if (NumberOfObservations % AggregatedHandsCount == 0)
     {
         FlushResetAndLogData(writer);
     }
 }