Exemplo n.º 1
0
        public StatisticItem(Statistic statisticToDisplay, Control parent)
        {
            this.statisticToDisplay = statisticToDisplay;
            this.parent = parent;
            this.highlightOnMouseOver = true;
            this.clickable = true;
            this.itemIsSelected = false;
            this.itemIsALine = false;
            InitializeComponent();

            if (statisticToDisplay.MainData is StatisticsLineData)
            {
                this.itemIsALine = true;
                this.lblName.Hide();
                this.lblLine.Show();
            }

            this.lblName.Text = String.Format("{0}: {1}",
                statisticToDisplay.MainData.Name, statisticToDisplay.MainData.GetValue());
        }
Exemplo n.º 2
0
        /* How many times has the player raised? */
        public Statistic GetRaiseStats(HoldemGamePhase phase, String category)
        {
            if (sawStreet[phase].Value == 0) return CreateUnknownActionStatistic("Raises", category);
            else
            {
                float raiseRatio = (float)raises[phase].Value / (float)sawStreet[phase].Value;
                Statistic ret = new Statistic(new StatisticsPercentageData("Raises", raiseRatio), category);

                AppendActionsSubstatistics(phase, ret, raisesRatings);

                return ret;
            }
        }
Exemplo n.º 3
0
        /* Returns the limp statistics */
        public Statistic GetLimpStats()
        {
            float limpRatio = 0;

            if (totalHandsPlayed.Value == 0) limpRatio = 0;
            else limpRatio = (float)limps.Value / (float)totalHandsPlayed.Value;

            Statistic ret = new Statistic(new StatisticsPercentageData("Limp", limpRatio), "Preflop");

            // Advanced statistics
            float sum = (float)limpsDetails.GetSumOfAllValues();
            foreach (HoldemHand.Rating rating in Enum.GetValues(typeof(HoldemHand.Rating)))
            {
                if (sum == 0) ret.AddSubStatistic(new StatisticsUnknownData(rating.ToString()));
                else
                {
                    float ratio = (float)limpsDetails[rating].Value / sum;
                    ret.AddSubStatistic(new StatisticsPercentageData(rating.ToString(), ratio));
                }
            }

            return ret;
        }
Exemplo n.º 4
0
        private Statistic GetDrawStatistics(HoldemGamePhase phase, String category)
        {
            List<StatisticsData> subData = new List<StatisticsData>(10);
            float sum = (float)draws.GetSumOfAllValuesIn(phase);
            float max = 0;
            HoldemPlayerAction mostCommonAction = (HoldemPlayerAction)(-1);

            for (HoldemPlayerAction action = HoldemPlayerAction.Call; action <= HoldemPlayerAction.CheckFold; action++)
            {
                if (sum == 0) subData.Add(new StatisticsUnknownData(action.ToString()));
                else
                {
                    float value = draws[phase, action].Value / sum;

                    // Keep track of the max value as to put a quick description on the statistic indicating
                    // which is the most common action taken by the player
                    // Note: in case of equality, the first element is used
                    if (value > max){
                        max = value;
                        mostCommonAction = action;
                    }
                    subData.Add(new StatisticsPercentageData(action.ToString(), value));
                }
            }

            String description = "?";
            if (mostCommonAction != (HoldemPlayerAction)(-1)) description = "Mostly " + mostCommonAction.ToString().ToLower();

            Statistic ret = new Statistic(new StatisticsDescriptiveData("On a straight/flush draw", description), category, subData);
            return ret;
        }
Exemplo n.º 5
0
        /* @param ratings the multiple value counter object containing the ratings how a check action, can be null if no ratings are available */
        private Statistic GetCheckActionStats(HoldemGamePhase phase, String name, String category, MultipleValueCounter values, MultipleValueCounter ratings)
        {
            int checkActions = (int)checkRaises[phase].Value + (int)checkCalls[phase].Value + (int)checkFolds[phase].Value;

            if (checkActions == 0)
            {
                if (ratings != null) return CreateUnknownActionStatistic(name, category);
                else return Statistic.CreateUnknown(name, category);
            }
            else
            {
                float ratio = (float)values[phase].Value / (float)checkActions;
                Statistic ret = new Statistic(new StatisticsPercentageData(name, ratio), category);

                if (ratings != null) AppendActionsSubstatistics(phase, ret, ratings);

                return ret;
            }
        }
Exemplo n.º 6
0
        private void AppendActionsSubstatistics(HoldemGamePhase phase, Statistic statistic, MultipleValueCounter ratings)
        {
            float sum = (float)ratings.GetSumOfAllValuesIn(phase);

            foreach (HoldemHand.Rating rating in Enum.GetValues(typeof(HoldemHand.Rating)))
            {
                if (sum == 0) statistic.AddSubStatistic(new StatisticsUnknownData(rating.ToString()));
                else
                {
                    float ratio = (float)ratings[phase, rating].Value / sum;
                    statistic.AddSubStatistic(new StatisticsPercentageData(rating.ToString(), ratio));
                }
            }
        }
Exemplo n.º 7
0
        private Statistic CreateOutsStatistic(String name, int numOuts, HoldemGamePhase phase)
        {
            Trace.Assert(phase == HoldemGamePhase.Flop || phase == HoldemGamePhase.Turn, "Cannot create outs statistics for a phase different than flop or turn.");
            float value = 0.0f;
            if (phase == HoldemGamePhase.Flop)
            {
                value = GetOutsPercentage(numOuts, OutsByThe.Turn);
            }
            else if (phase == HoldemGamePhase.Turn)
            {
                value = GetOutsPercentage(numOuts, OutsByThe.River);
            }

            Statistic result = new Statistic(new StatisticsOddsData(name, value, PRECISION));

            // The flop has extra information as we want to see the chances of hitting
            // something by the turn, or by the turn and river combined
            if (phase == HoldemGamePhase.Flop)
            {
                float valueByTurnOrRiver = GetOutsPercentage(numOuts, OutsByThe.TurnOrRiver);
                result.AddSubStatistic(new StatisticsOddsData("By the turn", value, PRECISION));
                result.AddSubStatistic(new StatisticsOddsData("By the turn or river", valueByTurnOrRiver, PRECISION));
            }

            return result;
        }
Exemplo n.º 8
0
 /* Sets a new statistic in our table */
 public void Set(Statistic stat)
 {
     stat.Order = table.Count;
     table[stat.Name + "_" + stat.Category] = stat;
 }
Exemplo n.º 9
0
 /* Function to sort the statistics data entries */
 private int CompareEntries(Statistic entry1, Statistic entry2)
 {
     if (entry1.Order == entry2.Order) return 0;
     else if (entry1.Order < entry2.Order) return -1;
     else return 1;
 }