コード例 #1
0
        /**
         * Return string representing current equity of hand
         */
        internal static String equityString(MEquity me)
        {
            String      s;
            OmahaEquity hionly = me.eqs[0];

            if (me.HiLo)
            {
                OmahaEquity hihalf = me.eqs[1];
                OmahaEquity lohalf = me.eqs[2];
                if (hionly.tied + hihalf.tied + lohalf.tied > 10)
                {
                    // 50.0% (0:100, 0:70)
                    s = String.Format("{0:0.00} ({1}:{2}, {3}:{4})%%", me.TotalEq, hionly.won + hihalf.won,
                                      hionly.tied + hihalf.tied, lohalf.won, lohalf.tied);
                }
                else
                {
                    s = String.Format("%{0:0.00} ({1}, {2})%%", me.TotalEq, hionly.won + hihalf.won, lohalf.won);
                }
            }
            else
            {
                s = String.Format("{0:0.00}%%", hionly.won);
                if (hionly.tied > 1)
                {
                    s += String.Format(" ({0:0.00}%% T)", hionly.tied);
                }
            }

            return(s);
        }
コード例 #2
0
        /** get the equity instance for the given equity type */
        public OmahaEquity getEquity(OmahaEquity.EquityType type)
        {
            int i;

            switch (type)
            {
            case OmahaEquity.EquityType.DSLO_ONLY:
            case OmahaEquity.EquityType.AFLO_ONLY:
            case OmahaEquity.EquityType.AFLO8_ONLY:
            case OmahaEquity.EquityType.HI_ONLY:
            case OmahaEquity.EquityType.BADUGI_ONLY:
                i = 0;
                break;

            case OmahaEquity.EquityType.HILO_HI_HALF:
                i = 1;
                break;

            case OmahaEquity.EquityType.HILO_AFLO8_HALF:
                i = 2;
                break;

            default:
                throw new ArgumentException("no such equity type " + type);
            }
            OmahaEquity e = eqs[i];

            if (e.type != type)
            {
                throw new ArgumentException("eq is type " + e.type + " not " + type);
            }
            return(e);
        }
コード例 #3
0
 internal static MEquity createMEquity(OmahaEquity.EquityType type, int rem, bool exact)
 {
     OmahaEquity[] eqs = new OmahaEquity[] {
         new OmahaEquity(type, exact)
     };
     return(new MEquity(eqs, false, rem, exact));
 }
コード例 #4
0
        /**
         * summarise equities (convert counts to percentages)
         */
        internal static void summariseMEquities(MEquity[] meqs, int count, int lowCount)
        {
            // System.out.println("summarise count=" + count + " hilocount=" +
            // hiloCount);
            foreach (MEquity meq in meqs)
            {
                // System.out.println(" meq " + meq);

                OmahaEquity hionly = meq.eqs[0];
                hionly.summariseEquity(count);
                // System.out.println(" hionly won: " + hionly.won + " tied: " +
                // hionly.tied + " total: " + hionly.total);

                if (lowCount == 0)
                {
                    meq.TotalEq = hionly.total;
                }
                else
                {
                    OmahaEquity hihalf = meq.eqs[1];
                    // high count as it applies to every hand not just hi/lo hands
                    hihalf.summariseEquity(count);
                    // System.out.println(" hihalf won: " + hihalf.won + " tied: " +
                    // hihalf.tied + " total: " + hihalf.total);
                    // System.out.println(" hionly+hihalf won: " + (hionly.won +
                    // hihalf.won) + " tied: " + (hionly.tied+hihalf.tied) + "
                    // total: " + (hionly.total+hihalf.total));

                    OmahaEquity lohalf = meq.eqs[2];
                    lohalf.summariseEquity(count);
                    // System.out.println(" lohalf won: " + lohalf.won + " tied: " +
                    // lohalf.tied + " total: " + lohalf.total);

                    meq.lowPossible = (lowCount * 100f) / count;
                    // System.out.println(" low possible: " + meq.lowPossible);

                    meq.TotalEq = hionly.total + (hihalf.total + lohalf.total) / 2;
                }
                // System.out.println(" total eq: " + meq.totaleq);

                meq.scoop = (meq.scoopcount * 100f) / count;
                // System.out.println(" scoop count: " + meq.scoopcount + " scoop: "
                // + meq.scoop);
            }
        }
コード例 #5
0
        /// <summary>
        /// Set the current value of the hands, not the equity
        /// </summary>
        /// <param name="meqs"></param>
        /// <param name="eqtype"></param>
        /// <param name="vals"></param>
        internal static void updateCurrent(MEquity[] meqs, OmahaEquity.EquityType eqtype, int[] vals)
        {
            int max = 0, times = 0;

            for (int i = 0; i < vals.Length; i++)
            {
                int v = vals[i];
                if (v > max)
                {
                    max   = v;
                    times = 1;
                }
                else if (v == max)
                {
                    times++;
                }
            }
            // only set curwin, curtie if there actually is non zero current value
            if (max > 0)
            {
                for (int i = 0; i < vals.Length; i++)
                {
                    OmahaEquity e = meqs[i].getEquity(eqtype);
                    e.current = vals[i];
                    if (e.current == max)
                    {
                        if (times == 1)
                        {
                            e.curwin = true;
                        }
                        else
                        {
                            e.curtie = true;
                        }
                    }
                }
            }
        }
コード例 #6
0
        /**
         * Update equities win, tie and win rank with given hand values for the
         * given cards. Return index of single winner (scoop), if any, or -1
         */
        private static int updateMEquities2(MEquity[] meqs, OmahaEquity.EquityType eqtype, int[] vals, String[] cards)
        {
            // find highest hand and number of times it occurs
            int max = 0, maxcount = 0;

            for (int i = 0; i < vals.Length; i++)
            {
                int v = vals[i];
                if (v > max)
                {
                    max      = v;
                    maxcount = 1;
                }
                else if (v == max)
                {
                    maxcount++;
                }
            }

            int winner = -1;

            for (int i = 0; i < vals.Length; i++)
            {
                if (vals[i] == max)
                {
                    // update the win/tied/rank count
                    OmahaEquity e = meqs[i].getEquity(eqtype);
                    if (maxcount == 1)
                    {
                        winner = i;
                        e.woncount++;
                    }
                    else
                    {
                        e.tiedcount++;
                        e.tiedwithcount += maxcount;
                    }
                    e.wonrankcount[OmahaPoker.rank(max)]++;

                    // count the cards as outs if this turns losing hand into
                    // win/tie or tying hand into win
                    if (cards != null && e.current > 0 && (!(e.curwin || e.curtie) || (e.curtie && maxcount == 1)))
                    {
                        for (int c = 0; c < cards.Length; c++)
                        {
                            String card      = cards[c];
                            int    cardIndex = OmahaPoker.cardToIndex(card);
                            e.outcount[cardIndex]++;
                        }
                    }

                    // XXX experimental - String[][] mcards

                    /*
                     * if (mcards != null && e.current > 0 && (!e.curwin ||
                     * (e.curtie && maxcount == 1))) { for (int c = 0; c <
                     * mcards[i].length; c++) { String card = mcards[i][c]; int
                     * cardIndex = Poker.cardToIndex(card); e.outcount[cardIndex]++;
                     * } }
                     */
                }
            }

            return(winner);
        }