예제 #1
0
        public void SeePlayerHand(int playerShowingHand, Card hole1, Card hole2, Hand bestHand)
        {
            if (_botTimeOutMilliSeconds > 0)
            {
                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunSeePlayerHand(playerShowingHand, hole1, hole2, bestHand); });

                    // wait X amount of time for task to complete
                    if (!_task.Wait(_botTimeOutMilliSeconds))
                    {
                        // Note that the task is still running in the background
                        _bIsBotBusy = true;
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunSeePlayerHand(playerShowingHand, hole1, hole2, bestHand);
            }

            TimingLogger.Log(string.Format("{0}, {1}, {2}, {3}, {4:0.0000}, {5}, {6}, {7}", _handNum, Stage.StageShowdown, PlayerNum, MethodBase.GetCurrentMethod().Name, (double)_lastMethodElapsedTime.Ticks / TimeSpan.TicksPerMillisecond, playerShowingHand, hole1, hole2));
        }
예제 #2
0
        public void InitPlayer(int pPlayerNum, GameConfig gameConfig, Dictionary <string, string> playerConfigSettings)
        {
            PlayerNum = pPlayerNum;
            StackSize = gameConfig.StartingStack;

            if (playerConfigSettings.ContainsKey("startingStack"))
            {
                StackSize = Convert.ToInt32(playerConfigSettings["startingStack"]);
            }

            _botTimeOutMilliSeconds = gameConfig.BotTimeOutMilliSeconds;

            if (_botTimeOutMilliSeconds > 0)
            {
                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunInitPlayer(pPlayerNum, gameConfig, playerConfigSettings); });

                    // wait X amount of time for task to complete
                    if (!_task.Wait(_botTimeOutMilliSeconds))
                    {
                        // Note that the task is still running in the background
                        _bIsBotBusy = true;
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunInitPlayer(pPlayerNum, gameConfig, playerConfigSettings);
            }

            TimingLogger.Log(string.Format("{0}, {1}, {2}, {3}, {4:0.0000}", _handNum, Stage.StagePreflop, pPlayerNum, MethodBase.GetCurrentMethod().Name, (double)_lastMethodElapsedTime.Ticks / TimeSpan.TicksPerMillisecond));

            if (IsObserver)
            {
                IsAlive   = false;
                IsActive  = false;
                StackSize = 0;
            }
        }
예제 #3
0
        public void GetAction(Stage stage, int betSize, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize, out ActionType playersAction, out int playersBetAmount)
        {
            // Default to fold if exception or timeout
            playersAction    = ActionType.Fold;
            playersBetAmount = 0;

            if (_botTimeOutMilliSeconds > 0)
            {
                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunGetAction(stage, betSize, callAmount, minRaise, maxRaise, raisesRemaining, potSize); });

                    // wait X amount of time for task to complete
                    // if method has not returned in time then use default action
                    if (_task.Wait(_botTimeOutMilliSeconds))
                    {
                        playersAction    = _playersAction;
                        playersBetAmount = _playersBetAmount;
                    }
                    else
                    {
                        // Note that the task is still running in the background
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunGetAction(stage, betSize, callAmount, minRaise, maxRaise, raisesRemaining, potSize);
                playersAction    = _playersAction;
                playersBetAmount = _playersBetAmount;
            }

            ValidateAction(stage, callAmount, minRaise, maxRaise, raisesRemaining, potSize, ref playersAction, ref playersBetAmount);

            TimingLogger.Log(string.Format("{0}, {1}, {2}, {3}, {4:0.0000}, {5}, {6}", _handNum, stage, PlayerNum, MethodBase.GetCurrentMethod().Name, (double)_lastMethodElapsedTime.Ticks / TimeSpan.TicksPerMillisecond, playersAction, playersBetAmount));
        }
예제 #4
0
        public void SeeBoardCard(EBoardCardType cardType, Card boardCard)
        {
            if (_botTimeOutMilliSeconds > 0)
            {
                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunSeeBoardCard(cardType, boardCard); });

                    // wait X amount of time for task to complete
                    if (!_task.Wait(_botTimeOutMilliSeconds))
                    {
                        // Note that the task is still running in the background
                        _bIsBotBusy = true;
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunSeeBoardCard(cardType, boardCard);
            }

            Stage stage = Stage.StageFlop;

            if (cardType == EBoardCardType.BoardRiver)
            {
                stage = Stage.StageRiver;
            }
            else if (cardType == EBoardCardType.BoardTurn)
            {
                stage = Stage.StageTurn;
            }

            TimingLogger.Log(string.Format("{0}, {1}, {2}, {3}, {4:0.0000}, {5}, {6}", _handNum, stage, PlayerNum, MethodBase.GetCurrentMethod().Name, (double)_lastMethodElapsedTime.Ticks / TimeSpan.TicksPerMillisecond, cardType, boardCard));
        }
예제 #5
0
        public void InitHand(int handNum, int numPlayers, List <PlayerInfo> players, int dealerId, int smallBlindSize, int bigBlindSize)
        {
            _handNum++;
            IsActive = IsAlive;
            StackSizeAtStartOfHand = StackSize;

            if (_botTimeOutMilliSeconds > 0)
            {
                // if bot is busy at the start of the hand then don't send any messages for the hand (so it doesn't get messages for half a hand)
                _bIsBotBusy = (_task != null && !_task.IsCompleted);

                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunInitHand(handNum, numPlayers, players, dealerId, smallBlindSize, bigBlindSize); });

                    // wait X amount of time for task to complete
                    if (!_task.Wait(_botTimeOutMilliSeconds))
                    {
                        // Note that the task is still running in the background
                        _bIsBotBusy = true;
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunInitHand(handNum, numPlayers, players, dealerId, smallBlindSize, bigBlindSize);
            }

            TimingLogger.Log(string.Format("{0}, {1}, {2}, {3}, {4:0.0000}", _handNum, Stage.StagePreflop, PlayerNum, MethodBase.GetCurrentMethod().Name, (double)_lastMethodElapsedTime.Ticks / TimeSpan.TicksPerMillisecond));
        }
예제 #6
0
        public void EndOfGame(int numPlayers, List <PlayerInfo> players)
        {
            if (_botTimeOutMilliSeconds > 0)
            {
                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunEndOfGame(numPlayers, players); });

                    // wait X amount of time for task to complete
                    if (!_task.Wait(_botTimeOutMilliSeconds))
                    {
                        // Note that the task is still running in the background
                        _bIsBotBusy = true;
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunEndOfGame(numPlayers, players);
            }

            TimingLogger.Log(string.Format("{0}, {1}, {2}, {3}, {4:0.0000}", _handNum, Stage.StageShowdown, PlayerNum, MethodBase.GetCurrentMethod().Name, (double)_lastMethodElapsedTime.Ticks / TimeSpan.TicksPerMillisecond));

            // !!! should I be doing this here?
            if (_newDomain != null)
            {
                AppDomain.Unload(_newDomain);
            }
        }