示例#1
0
        public void InitHand(int numPlayers, PlayerInfo[] players)
        {
            // this is called at the start of every hand and tells you the current status of all players (e.g. if is alive and stack size and who is dealer)
            // create a writer and open the file
            _handNum++;

            string sStackSizes = _handNum + "\t";

            foreach (PlayerInfo p in players)
            {
                sStackSizes += p.StackSize + "\t";
            }

            // write a line of text to the file
            _tw.WriteLine(sStackSizes);
        }
示例#2
0
        public void EndOfGame(int numPlayers, PlayerInfo[] players)
        {
            _handNum++;

            string sStackSizes = _handNum + "\t";

            foreach (PlayerInfo p in players)
            {
                sStackSizes += p.StackSize + "\t";
            }

            // write a line of text to the file
            _tw.WriteLine(sStackSizes);

            // close the stream
            _tw.Close();
        }
示例#3
0
        public void InitHand(int numPlayers, PlayerInfo[] players)
        {
            // this is called at the start of every hand and tells you the current status of all players (e.g. if is alive and stack size and who is dealer)
            // create a writer and open the file
            _handNum++;

            if(_handNum == 1)
            {
                playerStats = new PlayerStats[numPlayers];

                string sHeader = "HandNum\t";

                foreach (PlayerInfo p in players)
                {
                    playerStats[p.PlayerNum] = new PlayerStats(p.PlayerNum, p.IsObserver);
                    if(!p.IsObserver)
                    {
                        sHeader += p.PlayerNum + "-" + p.Name + "\t";
                    }
                }

                // write a line of text to the file
                _tw.WriteLine(sHeader);
            }

            string sStackSizes = _handNum + "\t";

            foreach (PlayerInfo p in players)
            {
                if(!p.IsObserver)
                {
                    sStackSizes += p.StackSize + "\t";
                }

                if (p.IsAlive)
                {
                    playerStats[p.PlayerNum].NumHandsPlayed++;
                    playerStats[p.PlayerNum].bWonThisHand = false;
                }
            }

            // write a line of text to the file
            _tw.WriteLine(sStackSizes);
        }
示例#4
0
        public void EndOfGame(int numPlayers, PlayerInfo[] players)
        {
            _handNum++;

            string sStackSizes = _handNum + "\t";

            foreach (PlayerInfo p in players)
            {
                if(!p.IsObserver)
                {
                    sStackSizes += p.StackSize + "\t";
                }
            }

            // write a line of text to the file
            _tw.WriteLine(sStackSizes);

            _tw.WriteLine("");

            _tw.WriteLine("PlayerNum\tNumHandsPlayed\tNumPreFlopsFolded\tNumFlopsFolded\tNumTurnsFolded\tNumRiversFolded\tNumShowdowns\tNumHandsWon");

            foreach (PlayerStats p in playerStats)
            {
                if(!p.bIsObserver)
                {
                    p.NumShowdowns = p.NumHandsPlayed - (p.NumPreFlopsFolded + p.NumFlopsFolded + p.NumTurnsFolded + p.NumRiversFolded);

                    _tw.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}",
                            p.PlayerNum,
                            p.NumHandsPlayed,
                            p.NumPreFlopsFolded,
                            p.NumFlopsFolded,
                            p.NumTurnsFolded,
                            p.NumRiversFolded,
                            p.NumShowdowns,
                            p.NumHandsWon
                        );
                }
            }

            // close the stream
            _tw.Close();
        }
 private void RunEndOfGame(int numPlayers, PlayerInfo[] players)
 {
     try
     {
         _player.EndOfGame(numPlayers, players);
     }
     catch (Exception e)
     {
         Logger.Log(string.Format("EXCEPTION: {0} Player {1} : {2}", MethodBase.GetCurrentMethod().Name, PlayerNum, e.Message));
     }
 }
        public void EndOfGame(int numPlayers, 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);
            }
        }
        public void InitHand(int numPlayers, PlayerInfo[] players)
        {
            IsActive = IsAlive;

            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(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
                RunInitHand(numPlayers, players);
            }
        }
 public void EndOfGame(int numPlayers, PlayerInfo[] players)
 {
     player.EndOfGame(numPlayers, players);
 }
示例#9
0
 public void InitHand(int numPlayers, PlayerInfo[] players)
 {
     // this is called at the start of every hand and tells you the current status of all players (e.g. if is alive and stack size and who is dealer)
     System.Threading.Thread.Sleep(_sleepMilliSeconds);
 }
示例#10
0
 public void InitHand(int numPlayers, PlayerInfo[] players)
 {
 }
示例#11
0
        public void InitHand(int numPlayers, PlayerInfo[] players)
        {
            IsActive = IsAlive;

            try
            {
                _player.InitHand(numPlayers, players);
            }
            catch (Exception e)
            {
                Logger.Log(string.Format("EXCEPTION: {0} Player {1} : {2}", MethodBase.GetCurrentMethod().Name, PlayerNum, e.Message));
            }

        }
示例#12
0
 public void InitHand(int numPlayers, PlayerInfo[] players)
 {
     // this is called at the start of every hand and tells you the current status of all players (e.g. if is alive and stack size and who is dealer)
     // create a writer and open the file
     _handNum++;
 }
示例#13
0
 public void EndOfGame(int numPlayers, PlayerInfo[] players)
 {
     int i = 1 / zero;
 }
示例#14
0
        private void EndOfGame()
        {
            PlayerInfo[] playerInfo = new PlayerInfo[numPlayers];

            System.Console.WriteLine("---------*** GAME OVER ***----------");
            System.Console.WriteLine("Num\tName\tIsAlive\tStackSize\tIsDealer");

            for (int i = 0; i < players.Count(); i++)
            {
                System.Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", i, players[i].Name, players[i].IsAlive, players[i].StackSize, i == dealerPlayerNum);
                PlayerInfo pInfo = new PlayerInfo(i, players[i].Name.PadRight(20), players[i].IsAlive, players[i].StackSize, i == dealerPlayerNum, players[i].IsObserver);
                playerInfo[i] = pInfo;
            }

            System.Console.WriteLine("---------------");

            // broadcast player info to all players
            foreach (ServerHoldemPlayer player in players)
            {
                player.EndOfGame(players.Count(), playerInfo);
            }
        }
示例#15
0
        private void InitHand(int handNum)
        {
            PlayerInfo[] playerInfo = new PlayerInfo[numPlayers];

            System.Console.WriteLine("---------*** HAND {0} ***----------", handNum);
            System.Console.WriteLine("Num\tName\tIsAlive\tStackSize\tIsDealer");

            for (int i = 0; i < players.Count(); i++)
            {
                System.Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", i, players[i].Name, players[i].IsAlive, players[i].StackSize, i == dealerPlayerNum);
                PlayerInfo pInfo = new PlayerInfo(i, players[i].Name.PadRight(20), players[i].IsAlive, players[i].StackSize, i == dealerPlayerNum, players[i].IsObserver);
                playerInfo[i] = pInfo;
            }

            System.Console.WriteLine("---------------");

            // broadcast player info to all players
            foreach (ServerHoldemPlayer player in players)
            {
                player.InitHand(players.Count(), playerInfo);
            }

            // shuffle deck
            deck.Shuffle();
        }
示例#16
0
 public void InitHand(int numPlayers, PlayerInfo[] players)
 {
     // this is called at the start of every hand and tells you the current status of all players (e.g. if is alive and stack size and who is dealer)
 }
示例#17
0
        private void InitHand(int handNum)
        {

            // Double the blinds if required. Do this here because later on we may want to include this in info to players
            if (_doubleBlindFrequency > 0 && handNum % _doubleBlindFrequency == 0)
            {
                _littleBlindSize *= 2;
                _bigBlindSize *= 2;
            }
            
            PlayerInfo[] playerInfo = new PlayerInfo[_numPlayers];

            Logger.Log("");
            Logger.Log("---------*** HAND {0} ***----------", handNum);
            Logger.Log("Num\tName\tIsAlive\tStackSize\tIsDealer");

            for (var i = 0; i < _players.Length; i++)
            {
                Logger.Log("{0}\t{1}\t{2}\t{3}\t{4}", i, _players[i].Name, _players[i].IsAlive, _players[i].StackSize, i == _dealerPlayerNum);
                var pInfo = new PlayerInfo(i, _players[i].Name.PadRight(20), _players[i].IsAlive, _players[i].StackSize, i == _dealerPlayerNum, _players[i].IsObserver);
                playerInfo[i] = pInfo;
            }

            Logger.Log("---------------");

            // broadcast player info to all players
            foreach (var player in _players)
            {
                player.InitHand(_players.Length, playerInfo);
            }

            // shuffle deck
            _deck.Shuffle();
        }
示例#18
0
 public void EndOfGame(int numPlayers, PlayerInfo[] players)
 {
 }
示例#19
0
        private void EndOfGame()
        {
            var playerInfo = new PlayerInfo[_numPlayers];

            Logger.Log("");
            Logger.Log("---------*** GAME OVER ***----------");
            Logger.Log("Num\tName\tIsAlive\tStackSize\tIsDealer");

            for (var i = 0; i < _players.Length; i++)
            {
                Logger.Log("{0}\t{1}\t{2}\t{3}\t{4}", i, _players[i].Name, _players[i].IsAlive, _players[i].StackSize, i == _dealerPlayerNum);
                var pInfo = new PlayerInfo(i, _players[i].Name.PadRight(20), _players[i].IsAlive, _players[i].StackSize, i == _dealerPlayerNum, _players[i].IsObserver);
                playerInfo[i] = pInfo;
            }

            Logger.Log("---------------");

            // broadcast player info to all players
            foreach (var player in _players)
            {
                player.EndOfGame(_players.Length, playerInfo);
            }
        }
示例#20
0
 public void EndOfGame(int numPlayers, PlayerInfo[] players)
 {
     System.Threading.Thread.Sleep(_sleepMilliSeconds);
 }
 public void InitHand(int numPlayers, PlayerInfo[] players)
 {
     IsActive = IsAlive;
     player.InitHand(numPlayers, players);
 }