Пример #1
0
        public static PlayerStats deserialize(BinaryReader reader)
        {
            var playerName   = reader.ReadString();
            var client       = strToPokerClient(reader.ReadString());
            var totalPlayers = reader.ReadInt32();
            var vpipPositive = reader.ReadInt32();
            var vpipTotal    = reader.ReadInt32();

            var preFlopTotal = reader.ReadInt32();
            var preFlopAds   = new ActionStats[preFlopTotal];

            for (int i = 0; i < preFlopTotal; i++)
            {
                preFlopAds[i] = ActionStats.deserialize(reader);
            }

            var postFlopTotal = reader.ReadInt32();
            var postFlopAds   = new ActionStats[postFlopTotal];

            for (int i = 0; i < postFlopTotal; i++)
            {
                postFlopAds[i] = ActionStats.deserialize(reader);
            }

            return(new PlayerStats(playerName, client, (TableType)totalPlayers, vpipPositive, vpipTotal, preFlopAds, postFlopAds));
        }
Пример #2
0
        public static ActionStats deserialize(BinaryReader reader)
        {
            ActionStats ad = new ActionStats();

            ad.BetRaiseSamples  = reader.ReadInt32();
            ad.CheckCallSamples = reader.ReadInt32();
            ad.FoldSamples      = reader.ReadInt32();

            return(ad);
        }
Пример #3
0
        public void calculateWTP(out int positiveCount, out int totalCount)
        {
            var totalForcedStats = new ActionStats();

            for (int i = 0; i < _allPostFlopParams.Count; i++)
            {
                if (_allPostFlopParams[i].NumBets > 0)
                {
                    totalForcedStats.append(PostFlopStats[i]);
                }
            }

            positiveCount = totalForcedStats.CheckCallSamples + totalForcedStats.BetRaiseSamples;
            totalCount    = positiveCount + totalForcedStats.FoldSamples;
        }
Пример #4
0
        public void calculatePFR(out int betRaiseCount, out int totalCount)
        {
            ActionStats totalAD = new ActionStats();

            for (int i = 0; i < _allPreFlopParams.Count; i++)
            {
                if (_allPreFlopParams[i].NumRaises == 0)
                {
                    totalAD.append(PreFlopStats[i]);
                }
            }

            betRaiseCount = totalAD.BetRaiseSamples;
            totalCount    = totalAD.totalSamples();
        }
Пример #5
0
        public void calculateAggression(out int raiseCount, out int totalCount)
        {
            var totalForcedStats   = new ActionStats();
            var totalUnforcedStats = new ActionStats();

            for (int i = 0; i < _allPostFlopParams.Count; i++)
            {
                if (_allPostFlopParams[i].NumBets > 0)
                {
                    totalForcedStats.append(PostFlopStats[i]);
                }

                if (_allPostFlopParams[i].NumBets == 0)
                {
                    totalUnforcedStats.append(PostFlopStats[i]);
                }
            }

            raiseCount = totalForcedStats.BetRaiseSamples + totalUnforcedStats.BetRaiseSamples; // bets + raises
            totalCount = raiseCount + totalForcedStats.CheckCallSamples;                        // bets + raises + calls
        }
Пример #6
0
        public PlayerStats(string playerName, PokerClient client, TableType tableType)
        {
            PlayerName = playerName;
            Client     = client;
            _tableType = tableType;
            VPIP       = new StatValue();

            _allPreFlopParams  = PreFlopParams.getAllParams(_tableType);
            _allPostFlopParams = PostFlopParams.getAllParams(_tableType);

            PreFlopStats  = new ActionStats[_allPreFlopParams.Count];
            PostFlopStats = new ActionStats[_allPostFlopParams.Count];

            for (int i = 0; i < PreFlopStats.Length; i++)
            {
                PreFlopStats[i] = new ActionStats();
            }

            for (int i = 0; i < PostFlopStats.Length; i++)
            {
                PostFlopStats[i] = new ActionStats();
            }
        }
Пример #7
0
        private EstimatedAD estimateADPostFlop(PlayerStats playerStats, DifferencePair[] sortedOpponents, PostFlopParams postFlopParams)
        {
            Debug.Assert(playerStats != null);

            var priorBetRaise  = new HistDistribution(_options.priorNumBins);
            var priorCheckCall = new HistDistribution(_options.priorNumBins);
            var priorFold      = new HistDistribution(_options.priorNumBins);

            var cumulativeActionsStats = new ActionStats();
            int k = 0;

            for (int i = 0; (i < sortedOpponents.Length) &&
                 (k < _options.maxSimilarPlayers) &&
                 (k == 0 || sortedOpponents[i].Difference < _options.maxDifference); i++)
            {
                int playerInd = sortedOpponents[i].Index;

                if (_baseModels[playerInd].Aggression.Sigma < _options.maxBaseStatsSigma)
                {
                    ActionStats similarOponentStats = _fullStatsList[playerInd].getPostFlopStats(postFlopParams);

                    if (similarOponentStats.totalSamples() > _options.minSamples)
                    {
                        priorBetRaise.AddSample(similarOponentStats.betRaiseProbability());
                        priorCheckCall.AddSample(similarOponentStats.checkCallProbability());
                        priorFold.AddSample(similarOponentStats.foldProbability());

                        k++;
                    }
                    else
                    {
                        cumulativeActionsStats.append(similarOponentStats);
                    }

                    if (cumulativeActionsStats.totalSamples() > _options.minSamples)
                    {
                        priorBetRaise.AddSample(cumulativeActionsStats.betRaiseProbability());
                        priorCheckCall.AddSample(cumulativeActionsStats.checkCallProbability());
                        priorFold.AddSample(cumulativeActionsStats.foldProbability());

                        cumulativeActionsStats.clear();
                        k++;
                    }
                }
            }

            priorBetRaise.Normalize();
            priorCheckCall.Normalize();
            priorFold.Normalize();

            // Update prior sa statistikom igraca
            ActionStats startStats = playerStats.getPostFlopStats(postFlopParams);

            var estBetRaise  = estimateGaussian(priorBetRaise, startStats.BetRaiseSamples, startStats.totalSamples());
            var estCheckCall = estimateGaussian(priorCheckCall, startStats.CheckCallSamples, startStats.totalSamples());
            var estFold      = estimateGaussian(priorFold, startStats.FoldSamples, startStats.totalSamples());

            if (postFlopParams.ForcedAction())
            {
                var totalMean = estBetRaise.Mean + estCheckCall.Mean + estFold.Mean;
                var scale     = 1.0f / totalMean;

                estBetRaise  = estBetRaise.Scale(scale);
                estCheckCall = estCheckCall.Scale(scale);
                estFold      = estFold.Scale(scale);
            }
            else
            {
                var totalMean = estBetRaise.Mean + estCheckCall.Mean;
                var scale     = 1.0f / totalMean;

                estBetRaise  = estBetRaise.Scale(scale);
                estCheckCall = estCheckCall.Scale(scale);
                estFold      = new GaussianDistribution(0.0f, 0.0f);
            }

            return(new EstimatedAD(estBetRaise, estCheckCall, estFold, k, startStats.totalSamples()));
        }
Пример #8
0
 public void append(ActionStats asv)
 {
     BetRaiseSamples  += asv.BetRaiseSamples;
     CheckCallSamples += asv.CheckCallSamples;
     FoldSamples      += asv.FoldSamples;
 }