コード例 #1
0
        /// <summary>
        /// Shows and hides the manual decision buttons. Making sure those buttons available are allowed. Also sets the default raise amount to the minimum allowable raise.
        /// </summary>
        /// <param name="buttonsVisible"></param>
        public void showHideManualButtons(bool buttonsVisible)
        {
            this.checkFoldButton.Visible = buttonsVisible;
            this.checkFoldButton.Enabled = true;

            this.callButton.Visible = buttonsVisible;
            this.callButton.Enabled = true;

            this.raiseAmount.Visible = buttonsVisible;
            this.raiseAmount.Enabled = true;

            this.raiseButton.Visible = buttonsVisible;
            this.raiseButton.Enabled = true;

            //If we are going to show the buttons we can decide at this point what the valid decisions are.
            if (buttonsVisible)
            {
                manualDecisionMade = false;
                long currentActivePlayerId = genericCache.getPlayerId(genericCache.getCurrentActiveTablePosition());

                if (genericCache.getMinimumPlayAmount() - genericCache.getPlayerCurrentRoundBetAmount(currentActivePlayerId) == 0)
                {
                    //If the game is post flop and no-one has yet bet
                    this.checkFoldButton.Text = "Check";
                    this.callButton.Enabled   = false;
                    this.raiseAmount.Text     = genericCache.BigBlind.ToString();
                }
                else
                {
                    decimal minCallAmount             = genericCache.getMinimumPlayAmount();
                    decimal currentRoundBetAmount     = genericCache.getPlayerCurrentRoundBetAmount(currentActivePlayerId);
                    decimal lastAdditionalRaiseAmount = genericCache.getCurrentRoundLastRaiseAmount();
                    decimal minimumRaiseToAmount      = (minCallAmount - lastAdditionalRaiseAmount) + (lastAdditionalRaiseAmount * 2);

                    //Check is no longer the option.
                    this.checkFoldButton.Text = "Fold";

                    //If raising is no longer an option disable that.
                    if (minCallAmount - currentRoundBetAmount > genericCache.getPlayerStack(currentActivePlayerId))
                    {
                        this.raiseButton.Enabled = false;
                        this.raiseAmount.Enabled = false;
                    }
                    else
                    {
                        //Set the text box to the minimum allowable raise amount.
                        this.raiseAmount.Text = minimumRaiseToAmount.ToString();
                    }
                }
            }
        }
コード例 #2
0
            public TableModel(databaseCache cache, WinRatioProvider wrProv, bool useAllPlayersCards)
            {
                this.tableId    = cache.TableId;
                this.numPlayers = cache.NumSeats;
                this.wrProv     = wrProv;

                //playersOld = new Dictionary<long, PlayerModel>(numPlayers);
                playersNew = new Dictionary <long, PlayerModelFixed>(numPlayers);

                var satDownPositions = cache.getSatDownPositions();

                for (byte i = 0; i < numPlayers; i++)
                {
                    if (satDownPositions.Contains(i))
                    {
                        //playersOld.Add(cache.getPlayerId(i), new PlayerModel(tableId, cache.getCurrentHandId(), cache.getPlayerId(i), wrProv));
                        playersNew.Add(cache.getPlayerId(i), new PlayerModelFixed(tableId, cache.BigBlind, cache.getCurrentHandId(), cache.getPlayerId(i), wrProv));
                    }
                }
            }
コード例 #3
0
        public static void LogAIError(Exception ex, databaseCache cache)
        {
            //Save the cache for later checking and try again
            WebLogging.AddLog("GPA", WebLogging.LogCategory.AIError, "AI error logged - " + ex.ToString());

            string errorFileName = "pokerAIError " + DateTime.Now.Hour.ToString() + "." + DateTime.Now.Minute.ToString() + "." + DateTime.Now.Second.ToString() + "." + DateTime.Now.Millisecond.ToString() + " " + DateTime.Now.ToString("dd-MM-yyyy");

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(errorFileName + ".log", false))
            {
                sw.WriteLine("Hand Id: " + cache.getCurrentHandId().ToString() + " Player Id: " + cache.getPlayerId(cache.getCurrentActiveTablePosition()).ToString());

                if (ex.GetBaseException() != null)
                {
                    sw.WriteLine("Base Exception Type: " + ex.GetBaseException().ToString());
                }

                if (ex.InnerException != null)
                {
                    sw.WriteLine("Inner Exception Type: " + ex.InnerException.ToString());
                }

                if (ex.StackTrace != null)
                {
                    sw.WriteLine("");
                    sw.WriteLine("Stack Trace: " + ex.StackTrace.ToString());
                }

                File.WriteAllBytes(errorFileName + ".FBPcache", cache.Serialise());

                sw.Close();
            }
        }