Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Calculate_Click(object sender, EventArgs e)
        {
            HiPerfTimer timer = new HiPerfTimer();
            int count = 0, index = 0;
            int[] playerIndex = { -1, -1, -1, -1 };
            int[] pocketIndex = { -1, -1, -1, -1 };

            foreach (string pocket in PlayerText)
            {
                if (pocket != "")
                {
                    playerIndex[count] = count;
                    pocketIndex[count++] = index;
                }
                index++;
            }

            string[] pocketCards = new string[count];

            for (int i = 0; i < count; i++)
            {
                pocketCards[i] = PlayerText[pocketIndex[i]];
            }

            long[] wins = new long[count];
            long[] losses = new long[count];
            long[] ties = new long[count];
            long totalhands = 0;

            try
            {
                timer.Start();
                Hand.HandOdds(pocketCards, Board.Text, DeadCards.Text, wins, ties, losses, ref totalhands);
                double duration = timer.Duration;

                System.Diagnostics.Debug.Assert(totalhands != 0);

                if (totalhands != 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        SetPlayerValue(pocketIndex[i], (((double)wins[i]) + ((double) ties[i])/2.0) / ((double)totalhands));
                    }
                }

                ErrorInfo.Text = string.Format("{0:###,###,###,###} hands evaluated in {1:#0.###} seconds.", totalhands, duration);
                ErrorInfo.ForeColor = Color.Black;

            }
            catch (ArgumentException ae)
            {
                ErrorInfo.Text = "Unable to process: " + ae.Message + ".";
                ErrorInfo.ForeColor = Color.Red;
            }
            catch
            {
                ErrorInfo.Text = "Unable to process: Please check pocket, board, and dead card definitions for errors.";
                ErrorInfo.ForeColor = Color.Red;
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Calculate_Click(object sender, EventArgs e)
        {
            HiPerfTimer timer = new HiPerfTimer();
            int         count = 0, index = 0;

            int[] playerIndex = { -1, -1, -1, -1 };
            int[] pocketIndex = { -1, -1, -1, -1 };

            foreach (string pocket in PlayerText)
            {
                if (pocket != "")
                {
                    playerIndex[count]   = count;
                    pocketIndex[count++] = index;
                }
                index++;
            }

            string[] pocketCards = new string[count];

            for (int i = 0; i < count; i++)
            {
                pocketCards[i] = PlayerText[pocketIndex[i]];
            }

            long[] wins       = new long[count];
            long[] losses     = new long[count];
            long[] ties       = new long[count];
            long   totalhands = 0;

            try
            {
                timer.Start();
                Hand.HandOdds(pocketCards, Board.Text, DeadCards.Text, wins, ties, losses, ref totalhands);
                double duration = timer.Duration;

                System.Diagnostics.Debug.Assert(totalhands != 0);

                if (totalhands != 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        SetPlayerValue(pocketIndex[i], (((double)wins[i]) + ((double)ties[i]) / 2.0) / ((double)totalhands));
                    }
                }

                ErrorInfo.Text      = string.Format("{0:###,###,###,###} hands evaluated in {1:#0.###} seconds.", totalhands, duration);
                ErrorInfo.ForeColor = Color.Black;
            }
            catch (ArgumentException ae)
            {
                ErrorInfo.Text      = "Unable to process: " + ae.Message + ".";
                ErrorInfo.ForeColor = Color.Red;
            }
            catch
            {
                ErrorInfo.Text      = "Unable to process: Please check pocket, board, and dead card definitions for errors.";
                ErrorInfo.ForeColor = Color.Red;
            }
        }