Beispiel #1
0
        private static void Main(string[] args)
        {
            Trace.Listeners.Add(new ConsoleTraceListener());

            var table = new Table();

            Player[] players =
            {
                new Player("Book Guy 1", new ByTheBookStrategy()),
                new Player("Book Guy 2", new ByTheBookStrategy()),
                //new Player("Bad guy 1", new ImbicileStrategy()),
                //new Player("Mad man", new RandomStrategy()),
            };
            var dealer = new Player("Dealer", new DealerStrategy());
            var shoe   = new Shoe(7);

            for (var i = 0; i < 10000; i++)
            {
                if (shoe.NeedsNewShoe())
                {
                    shoe = new Shoe(7);
                }
                table.PlayHand(shoe, players, dealer);
            }
            ReportStats(players, dealer);
            Console.Read();
        }
Beispiel #2
0
        public void PlayHand()
        {
            if (_shoe.NeedsNewShoe())
            {
                _shoe = Shoe.Create(7);
            }
            var toPlay = _players.Where(x => null != x).ToArray();

            foreach (var player in toPlay)
            {
                player.TakeCard(Deal());
            }
            _dealer.TakeCard(Deal());

            foreach (var player in toPlay)
            {
                player.TakeCard(Deal());
            }
            _dealer.TakeCard(Deal());

            if (!_dealer.Hand.IsBlackjack)
            {
                foreach (var player in toPlay)
                {
                    if (player.Hand.IsBlackjack)
                    {
                        continue;
                    }
                    PlayHand(player);
                }
                PlayHand(_dealer);
            }
            Payout(toPlay, _dealer);
        }
Beispiel #3
0
        private static void Main(string[] args)
        {
            Trace.Listeners.Add(new ConsoleTraceListener());

            var table = new Table();
            Player[] players = {
                new Player("Book Guy 1", new ByTheBookStrategy()),
                new Player("Book Guy 2", new ByTheBookStrategy()),
                //new Player("Bad guy 1", new ImbicileStrategy()),
                //new Player("Mad man", new RandomStrategy()),
            };
            var dealer = new Player("Dealer", new DealerStrategy());
            var shoe = new Shoe(7);
            for (var i = 0; i < 10000; i++)
            {
                if(shoe.NeedsNewShoe())
                    shoe = new Shoe(7);
                table.PlayHand(shoe, players, dealer);
            }
            ReportStats(players, dealer);
            Console.Read();
        }