Пример #1
0
        private bool EnumCallBackBlind(IntPtr hWnd, IntPtr lParam)
        {
            if (data.BBindex >= 0)
            {
                return(true);
            }

            StringBuilder builder = new StringBuilder(200);

            if (User32.GetWindowText(hWnd, builder, 200) != 0)
            {
                string caption = builder.ToString();
                if (caption.Contains("Blinds"))
                {
                    String blindtext = caption.Split(new char[] { '(', ')' })[1];
                    blindtext = blindtext.Replace("'", "");
                    blindtext = blindtext.Replace(".", "");
                    blindtext = blindtext.Replace(",", "");

                    BlindInfo blind = new BlindInfo(blindtext);
                    //BlindS§
                    for (int i = 0; i < blindStruct.Count; i++)
                    {
                        if (blindStruct[i].Equals(blind))
                        {
                            data.BBindex = i;
                            break;
                        }
                    }
                }
            }
            return(true);
        }
Пример #2
0
        public override bool Equals(object obj)
        {
            if (!(obj is BlindInfo))
            {
                return(false);
            }
            BlindInfo joo = (BlindInfo)obj;

            return(joo.smallblind == this.Smallblind && joo.bigblind == this.bigblind && joo.ante == this.ante);
        }
Пример #3
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            panel1.Visible = e.Node != null;
            if (e.Node == null)
            {
                return;
            }

            if (e.Node.Level == 0)
            {
                dataGridViewBlinds.Rows.Clear();


                BlindSaver saver = (BlindSaver)e.Node.Tag;


                for (int i = 0; i < saver.blinds.Count; i++)
                {
                    BlindInfo       blind    = saver.blinds[i];
                    int             rowindex = dataGridViewBlinds.Rows.Add();
                    DataGridViewRow row      = dataGridViewBlinds.Rows[rowindex];
                    row.Cells[0].Value = blind.Smallblind;
                    row.Cells[1].Value = blind.Bigblind;
                    if (blind.Ante > 0)
                    {
                        row.Cells[2].Value = blind.Ante;
                    }
                }

                panelBlinds.Visible = true;
                panelBlinds.Height  = panel1.Height - 20;
                panelWin.Visible    = false;

                return;
            }
            if (e.Node.Level == 1)
            {
                Award aw = (Award)e.Node.Tag;

                for (int i = 0; i < dataGridViewWin.Rows.Count; i++)
                {
                    dataGridViewWin.Rows[i].Cells[1].Value = "";
                }

                for (int i = 0; i < aw.wins.Count; i++)
                {
                    dataGridViewWin.Rows[i].Cells[1].Value = aw.wins[i];
                }
                textBoxPlayerCount.Text = Convert.ToString(aw.playercount);

                panelBlinds.Visible = false;
                panelWin.Top        = panelBlinds.Top;
                panelWin.Visible    = true;
            }
        }
Пример #4
0
        public int CompareTo(object obj)
        {
            if (!(obj is BlindInfo))
            {
                throw new Exception("Can't compare");
            }

            BlindInfo compare = (BlindInfo)obj;

            return(this.smallblind.CompareTo(compare.smallblind));
        }
Пример #5
0
        protected override void FillBlindIndex()
        {
            if (hwnd.ToInt32() == -1)
            {
                BlindSelectionForm joo = new BlindSelectionForm();
                data.BBindex = joo.getindex(blindStruct);

                return;
            }
            StringBuilder builder = new StringBuilder(255);

            User32.GetWindowText(hwnd, builder, 250);

            Match blindreg = Regex.Match(builder.ToString(), @"Blinds \$?(?<small>\d+)/\$?(?<big>\d+)\s*(Ante \$?(?<ante>\d+))?");

            if (blindreg.Success)
            {
                BlindInfo info;
                int       bigblind   = Convert.ToInt32(blindreg.Groups["big"].Value);
                int       smallblind = Convert.ToInt32(blindreg.Groups["small"].Value);
                int       ante       = 0;
                if (blindreg.Groups["ante"].Value != "")
                {
                    ante = Convert.ToInt32(blindreg.Groups["ante"].Value);
                }

                info = new BlindInfo(smallblind, bigblind, ante);

                for (int i = 0; i < blindStruct.Count; i++)
                {
                    if (blindStruct[i].Equals(info))
                    {
                        data.BBindex = i;
                        return;
                    }
                }
            }
            data.BBindex = -1;
        }
Пример #6
0
        public void ICMRanges(BlindInfo blinds, bool nosb, Award award, bool isPush)
        {
            calcRanges ranges = new calcRanges();
            int PLAYERCOUNT = 10;
            int[] playerrange = new int[PLAYERCOUNT];
            int[] stacks = new int[PLAYERCOUNT];
            int allin = -1;

            for (int i = 0; i < PLAYERCOUNT; i++)
                playerrange[i] = 1;

            int found = 0;
            for (int i = 0; i < PLAYERCOUNT; i++)
            {
                if (playersData[i, STACK] != 0)
                    stacks[found++] = (int)playersData[i, STACK];
            }

            // jos ollaan Push -moodissa, niin etsitään oma indeksi pääohjelman vasemmanpuolisimmista radio buttoneista
            if (isPush)
            {
                allin = -1;
                for (int i = 0; i < 10; i++)
                {
                    if (players[i].position.Checked == true)
                    {
                        allin = i;
                        break;
                    }
                }
            }
            // call -moodissa korottaja löytyy all-in radio -buttoneiden avulla
            else
            {
                for (int i = 0; i < 10; i++)
                {
                    if (players[i].allin.Checked == true)
                    {
                        allin = i;
                        break;
                    }
                }
            }

            ranges.calc(found, stacks, allin, blinds.Bigblind, blinds.Ante, nosb, 0.1, award.wins.ToArray(), playerrange);

            Console.Write("playerrange: ");
            for (int i = 0; i < 10; i++)
                Console.Write(playerrange[i] + ", ");
            Console.Write("\n");

            for (int i = 0; i < found; i++)
                setRange(i, playerrange[i],true);
        }
Пример #7
0
        protected override void FillBlindIndex()
        {
            if (hwnd.ToInt32() == -1)
            {
                BlindSelectionForm joo = new BlindSelectionForm();
                data.BBindex =  joo.getindex(blindStruct);

                return;
            }
            StringBuilder builder = new StringBuilder(255);
            User32.GetWindowText(hwnd, builder, 250);

            Match blindreg = Regex.Match(builder.ToString(), @"Blinds \$?(?<small>\d+)/\$?(?<big>\d+)\s*(Ante \$?(?<ante>\d+))?");
            if (blindreg.Success)
            {
                BlindInfo info;
                int bigblind = Convert.ToInt32(blindreg.Groups["big"].Value);
                int smallblind = Convert.ToInt32(blindreg.Groups["small"].Value);
                int ante = 0;
                if (blindreg.Groups["ante"].Value != "")
                    ante = Convert.ToInt32(blindreg.Groups["ante"].Value);

                info = new BlindInfo(smallblind,bigblind,ante);

                for (int i = 0; i < blindStruct.Count; i++)
                    if (blindStruct[i].Equals(info))
                    {
                        data.BBindex = i;
                        return;
                    }

            }
            data.BBindex = -1;
        }
Пример #8
0
        public void ICMRanges(BlindInfo blinds, bool nosb, Award award, bool isPush)
        {
            calcRanges ranges      = new calcRanges();
            int        PLAYERCOUNT = 10;

            int[] playerrange = new int[PLAYERCOUNT];
            int[] stacks      = new int[PLAYERCOUNT];
            int   allin       = -1;

            for (int i = 0; i < PLAYERCOUNT; i++)
            {
                playerrange[i] = 1;
            }

            int found = 0;

            for (int i = 0; i < PLAYERCOUNT; i++)
            {
                if (playersData[i, STACK] != 0)
                {
                    stacks[found++] = (int)playersData[i, STACK];
                }
            }

            // jos ollaan Push -moodissa, niin etsitään oma indeksi pääohjelman vasemmanpuolisimmista radio buttoneista
            if (isPush)
            {
                allin = -1;
                for (int i = 0; i < 10; i++)
                {
                    if (players[i].position.Checked == true)
                    {
                        allin = i;
                        break;
                    }
                }
            }
            // call -moodissa korottaja löytyy all-in radio -buttoneiden avulla
            else
            {
                for (int i = 0; i < 10; i++)
                {
                    if (players[i].allin.Checked == true)
                    {
                        allin = i;
                        break;
                    }
                }
            }

            ranges.calc(found, stacks, allin, blinds.Bigblind, blinds.Ante, nosb, 0.1, award.wins.ToArray(), playerrange);

            Console.Write("playerrange: ");
            for (int i = 0; i < 10; i++)
            {
                Console.Write(playerrange[i] + ", ");
            }
            Console.Write("\n");

            for (int i = 0; i < found; i++)
            {
                setRange(i, playerrange[i], true);
            }
        }
Пример #9
0
        private bool EnumCallBackBlind(IntPtr hWnd, IntPtr lParam)
        {
            if (data.BBindex >= 0)
                return true;

            StringBuilder builder = new StringBuilder(200);

            if (User32.GetWindowText(hWnd, builder, 200) != 0)
            {

                string caption = builder.ToString();
                if (caption.Contains("Blinds"))
                {
                    String blindtext = caption.Split(new char[] { '(', ')' })[1];
                    blindtext = blindtext.Replace("'", "");
                    blindtext = blindtext.Replace(".", "");
                    blindtext = blindtext.Replace(",", "");

                    BlindInfo blind = new BlindInfo(blindtext);
                    //BlindS§
                    for(int i=0; i<blindStruct.Count; i++)
                        if (blindStruct[i].Equals(blind))
                        {
                            data.BBindex = i;
                            break;
                        }
                }
            }
            return true;
        }
Пример #10
0
        // Handles game data parsing moves dealer to 0 position and checks stacks
        public void parseGame(TableData oData)
        {
            oData.error    = iData.error;
            oData.errorStr = iData.errorStr;
            if (iData.error != 0)
            {
                return;
            }
            Debug.WriteLine("\n************************************************\n");


            // Check for serious errors

            //  postflop
            if (iData.boardCards[0] >= 0 || iData.boardCards[1] >= 0)
            {
                oData.error    = 1;
                oData.errorStr = "This program is only useful in preflop. Can't continue.";
                return;
            }

            // Couldn't find own position
            if (iData.myPos < 0)
            {
                oData.error    = 3;
                oData.errorStr = "Couldn't find own position. Can't continue.";

                return;
            }

            if (iData.BBindex < 0)
            {
                oData.error    = 2;
                oData.errorStr = "Couldn't find blind size. Can't continue";
                return;
            }

            if (iData.dealerPos < 0)
            {
                oData.error    = 3;
                oData.errorStr = "Couldn't find dealer position. Can't continue.";
                return;
            }


            Debug.WriteLine("Starting point:");
            for (int i = 0; i < 10; i++)
            {
                Console.Write("{0}\t{1}\t{2}", i, iData.stacks[i], iData.bets[i]);
                if (i == iData.myPos)
                {
                    Console.Write(" me");
                }
                if (i == iData.dealerPos)
                {
                    Console.Write(" dealer ");
                }
                Debug.WriteLine("");
            }
            Debug.WriteLine("");

            int BBsize = blindIndextoSize(iData.BBindex);

            // Count player amount
            int playersCount = 0;

            for (int i = 0; i < 10; i++)
            {
                if (iData.bets[i] > 0 || iData.stacks[i] > 0)
                {
                    playersCount++;
                }
            }

            // Put players to two dimensional table, dealer at position 0

            int POS   = 0;  // position on table 0-9
            int STACK = 1;
            int BET   = 2;

            int[,] tmpPlayers = new int[playersCount, 3];
            int index = 0;

            for (int i = iData.dealerPos; i < 10; i++)
            {
                if (iData.bets[i] > 0 || iData.stacks[i] > 0)
                {
                    tmpPlayers[index, POS] = i;
                    if (iData.stacks[i] > -1)
                    {
                        tmpPlayers[index, STACK] = iData.stacks[i];
                    }
                    if (iData.bets[i] > -1)
                    {
                        tmpPlayers[index, BET] = iData.bets[i];
                    }
                    index++;
                }
            }
            if (iData.dealerPos > 0)
            {
                for (int i = 0; i < iData.dealerPos; i++)
                {
                    if (iData.bets[i] > 0 || iData.stacks[i] > 0)
                    {
                        tmpPlayers[index, POS] = i;
                        if (iData.stacks[i] > -1)
                        {
                            tmpPlayers[index, STACK] = iData.stacks[i];
                        }
                        if (iData.bets[i] > -1)
                        {
                            tmpPlayers[index, BET] = iData.bets[i];
                        }
                        index++;
                    }
                }
            }


            Debug.WriteLine("tmpPlayers: button first");
            for (int i = 0; i < playersCount; i++)
            {
                Debug.WriteLine("{0}\t{1}\t{2}", tmpPlayers[i, POS], tmpPlayers[i, STACK], tmpPlayers[i, BET]);
            }


            int[] oldPos     = new int[10]; // Here we store old indexes
            int   myNewIndex = 0;           // .. so that we can get our own index in oData table

            // two players -> small blind is button
            if (playersCount == 2)
            {
                // if we are button we are in push mode
                if (iData.dealerPos == iData.myPos)
                {
                    oData.mode      = true;                                                                // push
                    oData.stacks[0] = tmpPlayers[1, STACK] + tmpPlayers[1, BET] + anteSize(iData.BBindex); //opp
                    oData.stacks[1] = tmpPlayers[0, STACK] + tmpPlayers[0, BET] + anteSize(iData.BBindex); //me
                }
                // otherwise opponent may have gone all-in
                else
                {
                    // If opponent has gone all-in
                    if (tmpPlayers[0, STACK] == 0)
                    {
                        oData.allinIndex = 1;
                        oData.mode       = false; // call
                        oData.stacks[0]  = tmpPlayers[1, STACK] + tmpPlayers[1, BET] + anteSize(iData.BBindex);
                        oData.stacks[1]  = tmpPlayers[0, STACK] + tmpPlayers[0, BET] + anteSize(iData.BBindex);
                    }
                    // No all-in -> set error code
                    else
                    {
                        oData.allinIndex = 1;
                        oData.mode       = false; // call
                        oData.stacks[0]  = tmpPlayers[1, STACK] + tmpPlayers[1, BET] + anteSize(iData.BBindex);
                        oData.stacks[1]  = tmpPlayers[0, STACK] + tmpPlayers[0, BET] + anteSize(iData.BBindex);
                        oData.error      = 11;
                        oData.errorStr   = "There is less than all in sized bet. Can't continue.";
                    }
                }
            }

            // More than 2 players
            else
            {
                // Index 1 and 2 contains small blind and big blind
                int  SBpos      = 1;
                int  BBpos      = 2;
                bool foundBBpos = false;

                // Check for big blind
                if (tmpPlayers[BBpos, BET] > 0 && tmpPlayers[BBpos, BET] <= BBsize)
                {
                    Debug.WriteLine("Iso blindi löydettiin");
                    foundBBpos = true;
                }

                //If normal big blind hasn't paid anything, player next to dealer
                //is only blind payer (Partys nosb)
                if (foundBBpos == false && !iData.noSB)
                {
                    BBpos      = SBpos;
                    oData.noSB = true;
                }

                Debug.WriteLine("BBpos: {0} oData.noSB: {1}", BBpos, oData.noSB);

                // Put stacks and blinds to result object by goind counterclockwise
                index = 0;
                for (int i = BBpos; i >= 0; i--)
                {
                    oldPos[index]       = tmpPlayers[i, POS];
                    oData.stacks[index] = tmpPlayers[i, STACK] + tmpPlayers[i, BET] + anteSize(iData.BBindex);
                    oData.bets[index]   = tmpPlayers[i, BET];
                    index++;
                }
                if (BBpos < playersCount - 1)
                {
                    for (int i = playersCount - 1; i > BBpos; i--)
                    {
                        oldPos[index]       = tmpPlayers[i, POS];
                        oData.stacks[index] = tmpPlayers[i, STACK] + tmpPlayers[i, BET] + anteSize(iData.BBindex);
                        oData.bets[index]   = tmpPlayers[i, BET];
                        index++;
                    }
                }

                // Search our own position from tables
                for (int i = 0; i < 10; i++)
                {
                    if (oldPos[i] == iData.myPos)
                    {
                        myNewIndex = i;
                        break;
                    }
                }
            }

            Debug.WriteLine("\nMy new index: {0}", myNewIndex);
            Debug.WriteLine("\noData.stacks:");
            for (int i = 0; i < playersCount; i++)
            {
                Debug.WriteLine("{0}\t{1}\t{2}", i, oData.stacks[i], oData.bets[i]);
            }


            // Set remaining table data
            if (iData.BBindex >= 0)
            {
                oData.BBindex = iData.BBindex;
            }
            else
            {
                oData.BBindex = 0;
            }
            oData.BBsize = BBsize;
            for (int i = 0; i < 5; i++)
            {
                oData.boardCards[i] = iData.boardCards[i];
            }
            oData.handCards[0] = iData.handCards[0];
            oData.handCards[1] = iData.handCards[1];
            oData.handIndex    = indexFromHand(iData.handCards);
            oData.myPos        = myNewIndex;
            oData.players      = playersCount;
            oData.tableType    = iData.tableType;


            if (playersCount > 2)
            {
                // // If we are first to act, we surely are in PUSH-mode
                if (playersCount - 1 == myNewIndex)
                {
                    oData.mode = true;
                }
                else
                {
                    //Go table from UTG towards our own position. If we came to our own position without all-in
                    //we are in push mode else call

                    int i = 0;
                    int limpersOrRaisers = 0;
                    int allins           = 0;
                    for (i = playersCount - 1; i > myNewIndex; i--)
                    {
                        //Opponent wen't all-in
                        if (oData.bets[i] >= 0 && oData.bets[i] + anteSize(iData.BBindex) == oData.stacks[i])
                        {
                            allins++;
                            oData.allinIndex = i;
                        }

                        // opponent went all-in but didn't go allin
                        else if (oData.bets[i] > 0 && oData.bets[i] + anteSize(iData.BBindex) < oData.stacks[i])
                        {
                            //If bet is smaller than big blind and bet maker still has stack, small blind folded
                            if (oData.bets[i] < BBsize && i == 1)
                            {
                                continue;
                            }

                            // Limping
                            limpersOrRaisers++;
                            if (oData.allinIndex < 0)
                            {
                                oData.allinIndex = i;  // Set all-in index to better. THIS IS WRONG!!!!!!
                            }
                        }
                    }
                    // limpers -> can't calculate
                    if (limpersOrRaisers > 0)
                    {
                        oData.error = 12;
                        BlindInfo blind = BlindStruct[iData.BBindex];

                        oData.errorStr = "There is limpers or less than all in sized bet. Can't continue.";
                        oData.mode     = true;
                    }
                    // no limpers, but one all-in, can be calculated in call-mode
                    else if (limpersOrRaisers == 0 && allins == 1)
                    {
                        oData.mode = false;
                    }
                    // multiple all-ins can't calculate
                    else if (allins > 1)
                    {
                        oData.error    = 13;
                        oData.errorStr = "There is more than one all in. Can't continue.";
                        oData.mode     = false;
                    }
                    // No limpers, or all-ins  -> push mode
                    else if (allins == 0 && limpersOrRaisers == 0)
                    {
                        oData.mode = true;
                    }
                }
            }

            // Own cards not found
            if (iData.handCards[0] < 0 || iData.handCards[1] < 0)
            {
                oData.handIndex = 0; // AA oletuksena
                oData.error     = 14;
                oData.errorStr  = "Couldn't recognize cards. Can't continue.";
            }

            // Unable to determine blind size
            else if (iData.BBindex < 0)
            {
                oData.BBindex  = 0; // 20/40 oletuksena
                oData.error    = 15;
                oData.errorStr = "Couldn't find blind size. Can't continue.";
            }

            // There has to be more than 2 players
            else if (oData.players < 2)
            {
                oData.error    = 4;
                oData.errorStr = "Couldn't find player count. Can't continue.";
            }

            // Sum of chips doesn't match
            int chipSum = 0;

            for (int i = 0; i < 10; i++)
            {
                if (oData.stacks[i] > 0)
                {
                    chipSum += oData.stacks[i];
                }
            }

            float chipsPerPlayer = chipSum / oData.tableType;

            if (chipsPerPlayer != 1500 && chipsPerPlayer != 2000 && chipsPerPlayer != 300)
            {
                Debug.WriteLine("oData.tableType: {0} chipSum: {1}", oData.tableType, chipSum);

                // Error is serious, if none of the stacks can be read
                if (chipSum == 0)
                {
                    oData.error    = 5;
                    oData.errorStr = "Couldn't find any stack size. Can't continue.";
                }
                // ... and less serious if we got something
                else
                {
                    oData.error    = 16;
                    oData.errorStr = "Couldn't find all stacks sizes. Can't continue.";
                }
            }


            // Print all calculated infos
            Debug.WriteLine("\noData.error: {0}", oData.error);
            Debug.WriteLine("oData.errorStr: {0}", oData.errorStr);
            Debug.WriteLine("oData.mode: {0}", oData.mode);
            Debug.WriteLine("oData.myPos: {0}", oData.myPos);
            Debug.WriteLine("handCards: {0} {1}", oData.handCards[0], oData.handCards[1]);
            Debug.WriteLine("handIndex: {0}", oData.handIndex);
            Debug.WriteLine("noSB: {0}", oData.noSB);
            Debug.WriteLine("BBsize: {0}", oData.BBsize);
            Debug.WriteLine("BBindex: {0}", oData.BBindex);
            Debug.WriteLine("allinIndex: {0}", oData.allinIndex);
            Debug.WriteLine("Stacks:");
            for (int i = 0; i < playersCount; i++)
            {
                Debug.WriteLine("{0}\t{1}", i, oData.stacks[i], oData.bets[i]);
            }
        }