Beispiel #1
0
        public void ActionAfterBlackjackTest()
        {
            var bot = new PrimitiveManchetanStrategyBot(exampleStartMoney, exampleStartRate);

            bot.TakeCard(new UsualCard(CardNames.Ten, CardSuits.Diamond));
            bot.TakeCard(new AceCard(CardSuits.Diamond));
            bot.MakeNextPlayerTurn(new AceCard(CardSuits.Diamond));

            Assert.IsTrue(bot.PlayerTurnNow == PlayerTurn.Stand);
        }
Beispiel #2
0
        public void BotLosingTest()
        {
            var bot = new PrimitiveManchetanStrategyBot(exampleStartMoney, exampleStartRate);

            bot.Lose();
            Assert.IsTrue(bot.Money == exampleStartMoney - exampleStartRate);
            Assert.IsTrue(bot.CountGames == 1);
            Assert.IsTrue(bot.CountWinGames == 0);
            Assert.IsTrue(bot.IsWantNextGame);
        }
Beispiel #3
0
        public void GameWithPrimitiveBotConstructorTest()
        {
            var thirdBot  = new PrimitiveManchetanStrategyBot(1000, minimumRate);
            var thirdGame = new Game(thirdBot);

            thirdGame.CreateGame(countDecksInOne);

            Assert.IsNotNull(thirdBot);
            Assert.IsNotNull(thirdGame.Deck);
            Assert.IsNotNull(thirdGame.Dealer);
            Assert.IsNotNull(thirdGame.Bot);
            Assert.AreEqual(thirdBot, thirdGame.Bot);
        }
Beispiel #4
0
        public void NextGamePreparationTest()
        {
            var bot = new PrimitiveManchetanStrategyBot(exampleStartMoney, exampleStartRate);

            bot.Win();
            Assert.IsTrue(bot.Rate == exampleStartRate * 2);

            bot.Win();
            Assert.IsTrue(bot.Rate == exampleStartRate);

            bot.Lose();
            Assert.IsTrue(bot.Rate == exampleStartRate);
        }
Beispiel #5
0
        public void PrimitiveBotPlayTest()
        {
            var thirdBot  = new PrimitiveManchetanStrategyBot(1000, minimumRate);
            var thirdGame = new Game(thirdBot);

            thirdGame.CreateGame(countDecksInOne);

            int startCountOfCards = thirdGame.Deck.Deck.Count();

            thirdGame.CreateGame(countDecksInOne);

            Assert.DoesNotThrow(() => thirdGame.StartGame());
            Assert.IsTrue(thirdGame.Deck.Deck.Count() < startCountOfCards);
        }
Beispiel #6
0
        public void GetNextTurnTest()
        {
            var bot = new PrimitiveManchetanStrategyBot(exampleStartMoney, exampleStartRate);

            bot.TakeCard(new UsualCard(CardNames.Six, CardSuits.Diamond));
            Assert.IsTrue(bot.GetNextTurn(exapleDealerCard) == PlayerTurn.Hit);

            bot.TakeCard(new UsualCard(CardNames.Six, CardSuits.Diamond));
            Assert.IsTrue(bot.GetNextTurn(exapleDealerCard) == PlayerTurn.Double);

            bot.TakeCard(new UsualCard(CardNames.Six, CardSuits.Diamond));
            Assert.IsTrue(bot.GetNextTurn(exapleDealerCard) == PlayerTurn.Stand);

            bot.TakeCard(new UsualCard(CardNames.Three, CardSuits.Diamond));
            Assert.IsTrue(bot.GetNextTurn(exapleDealerCard) == PlayerTurn.Blackjack);
        }
Beispiel #7
0
        static void Main(string[] agrs)
        {
            Console.WriteLine("This program show what balance you'll have after play Blackjack" +
                              "with one of the strategies: \n");

            int countGames               = 50000;
            int startMoney               = 10000;
            int startRate                = 500;
            int sumAfterGame             = 0;
            int countLoseAllBalanceGames = 0;

            // PrimitiveManchetanStrategyBot statistic

            for (int i = 0; i < countGames; i++)
            {
                PrimitiveManchetanStrategyBot bot = new PrimitiveManchetanStrategyBot(startMoney, startRate);
                Game game = new Game(bot);
                game.CreateGame(8);
                game.StartGame();
                sumAfterGame += (int)bot.Money;
                if (bot.Money <= 0)
                {
                    countLoseAllBalanceGames++;
                }
            }
            Console.WriteLine("1) PrimitiveManchetanStrategyBot statistic: ");
            Console.WriteLine($"Average winnings over 40 games ---> {sumAfterGame / 50000}/{startMoney} <--- Your start balance");
            Console.WriteLine("The number of games when a player loses his entire balance ---> " + countLoseAllBalanceGames);

            // MartingaleBot statistic
            sumAfterGame             = 0;
            countLoseAllBalanceGames = 0;

            for (int i = 0; i < countGames; i++)
            {
                MartingaleBot bot  = new MartingaleBot(startMoney, startRate);
                Game          game = new Game(bot);
                game.CreateGame(8);
                game.StartGame();
                sumAfterGame += (int)bot.Money;
                if (bot.Money <= 0)
                {
                    countLoseAllBalanceGames++;
                }
            }
            Console.WriteLine("2) MartingaleBot statistic: ");
            Console.WriteLine($"Average winnings over 40 games ---> {sumAfterGame / 50000}/{startMoney} <--- Your start balance");
            Console.WriteLine("The number of games when a player loses his entire balance ---> " + countLoseAllBalanceGames);

            // OneThreeTwoSixBot statistic
            sumAfterGame             = 0;
            countLoseAllBalanceGames = 0;

            for (int i = 0; i < countGames; i++)
            {
                OneThreeTwoSixBot bot = new OneThreeTwoSixBot(startMoney, startRate);
                Game game             = new Game(bot);
                game.CreateGame(8);
                game.StartGame();
                sumAfterGame += (int)bot.Money;
                if (bot.Money <= 0)
                {
                    countLoseAllBalanceGames++;
                }
            }
            Console.WriteLine("3) OneThreeTwoSixBot statistic: ");
            Console.WriteLine($"Average winnings over 40 games ---> {sumAfterGame / 50000}/{startMoney} <--- Your start balance");
            Console.WriteLine("The number of games when a player loses his entire balance ---> " + countLoseAllBalanceGames);

            Console.WriteLine("<----------------------------------------------->");
            return;
        }
Beispiel #8
0
        public void PrimitiveManchetanStrategyBotConstructorTest()
        {
            var bot = new PrimitiveManchetanStrategyBot(exampleStartMoney, exampleStartRate);

            ConstructorTest(bot);
        }