Beispiel #1
0
        public void IntermediateBeatsBeginner()
        {
            int          BotWins     = 0;
            int          Bot2Wins    = 0;
            SquareValues winner      = 0;
            var          blackpieces = Pieces.BlackPlacements();
            var          whitepieces = Pieces.WhitePlacements();
            var          Board       = new GameBoard(8, blackpieces, whitepieces);
            var          Bot         = new BotPlayer3(Board, Types[rnd.Next(Types.Count)]);
            var          Bot2        = new BotPlayer1(Board, Board.OpponentType(Bot.Type));

            //var Bot = new BotPlayerTempV(Board, SquareValues.Black, 3);
            //var Bot2 = new BotPlayerTempV(Board, SquareValues.White, 2);
            for (int i = 0; i < 100; i++)
            {
                winner = BotPlayer.PlayBots(Board, Bot, Bot2);
                if (winner == Bot.Type)
                {
                    BotWins++;
                }
                else
                {
                    Bot2Wins++;
                }
            }
            Assert.IsTrue(BotWins > Bot2Wins);
        }
Beispiel #2
0
        public void AdvancedVsAdvanced()
        {
            int          BotWins     = 0;
            int          Bot2Wins    = 0;
            SquareValues winner      = 0;
            var          blackpieces = Pieces.BlackPlacements();
            var          whitepieces = Pieces.WhitePlacements();
            var          Board       = new GameBoard(8, blackpieces, whitepieces);
            var          Bot         = new BotPlayer5(Board, Types[rnd.Next(Types.Count)]);
            var          Bot2        = new BotPlayer5(Board, Board.OpponentType(Bot.Type));

            //var Bot = new BotPlayerTempV(Board, SquareValues.Black, 3);
            //var Bot2 = new BotPlayerTempV(Board, SquareValues.White, 2);
            for (int i = 0; i < 100; i++)
            {
                winner = BotPlayer.PlayBots(Board, Bot, Bot2);
                if (winner == Bot.Type)
                {
                    BotWins++;
                }
                else
                {
                    Bot2Wins++;
                }
            }
            Assert.IsFalse(Math.Abs(BotWins - Bot2Wins) > 20);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("-------- CHECKERS --------");
            Console.WriteLine();
            bool running = true;

            GameBoard Board = null;


            //Restart:
            while (running == true)
            {
                DisplayMenu();
                char menuchoice = Console.ReadLine().ToCharArray()[0];
                switch (menuchoice)
                {
                case '1':
                    var blackpieces = Pieces.BlackPlacements();
                    var whitepieces = Pieces.WhitePlacements();
                    Board = new GameBoard(8, blackpieces, whitepieces);
                    Start1PGame(Board);
                    break;

                case '2':
                    var blackpieces2 = Pieces.BlackPlacements();
                    var whitepieces2 = Pieces.WhitePlacements();
                    Board = new GameBoard(8, blackpieces2, whitepieces2);
                    Start2PGame(Board);
                    break;

                case '4':
                    var TestBlacks = Pieces.JumpedBlack();
                    var TestWhites = Pieces.JumpingWhite();
                    Board = new GameBoard(8, TestBlacks, TestWhites);
                    Start1PGame(Board);
                    break;

                case '3':
                    var retry = true;
                    while (retry)
                    {
                        try
                        {
                            string tempExeName = Path.Combine(Directory.GetCurrentDirectory(), "GUI.exe");
                            using (FileStream fsDst = new FileStream(tempExeName, FileMode.CreateNew, FileAccess.Write))
                            {
                                byte[] bytes = Resources.GetGUI();

                                fsDst.Write(bytes, 0, bytes.Length);
                            }
                            Process.Start(tempExeName);
                            retry = false;
                        }
                        catch (Exception)
                        {
                            File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "GUI.exe"));
                        }
                    }
                    running = false;
                    Application.Exit();
                    break;

                case '0':
                    running = false;
                    break;

                default:
                    Console.WriteLine("Invalid Menu Choice");
                    break;
                }
            }
        }