Пример #1
0
        public void Test_002()
        {
            //Model
            //View
            //Controller

            var moves = new List <string>()
            {
                //white, Black - COLLECTION OF STRINGS TO REPRESENT MOVES
                "G1F3", "G8F6",
                "C2C4", "G7G6",
                "B1C3", "F8G7",
                "D1D4", "E8G8",        //CASTLE
                "C1C4", "D7D5",
                "D1B3", "D5C4",        //CAPTURE
                "B3C4",                //CAPTURE
            };

            var game = new Chess();            // refer to class library- view

            var board   = new Board();         // refer to class library -model
            var printer = new BoardPrinter();  //printing to the console

            //board.Move += (moves) => Debug.WriteLine("");//we want an event and I have to declare that myself.

            //game.Result += (result) => Debug.WriteLine("");
            //game.Capture += (piece, position) => Debug.WriteLine("");

            foreach (var move in moves)
            {
                game.Apply(move, board);                //representing the chess board; apply method to the board as a parameter; the method can be somewhere else.

                printer.Show(board);
            }
        }
Пример #2
0
        public void Test_002()
        {
            // Model
            // View
            // Controller

            var moves = new List <string>()
            {
                // White, Black
                "G1F3", "G8F6",
                "C2C4", "G7G6",
                "B1C3", "F8G7",
                "D1D4", "E8G8", // castle
                "C1C4", "D7D5",
                "D1B3", "D5C4", // capture
                "B3C4",         // capture, ...
            };

            var game    = new Chess();
            var board   = new Board();
            var printer = new BoardPrinter();

            //board.Move += (move) => Debug.WriteLine("");

            //game.Result += (result) => Debug.WriteLine("");
            //game.Capture += (piece, position) => Debug.WriteLine("");

            foreach (var move in moves)
            {
                game.Apply(move, board);

                printer.Show(board);
            }
        }
Пример #3
0
        public void Test_003()
        {
            var moves = new List <string>()
            {
                // White, Black
                "G1F3", "G8F6",
                "C2C4", "G7G6",
                "B1C3", "F8G7",
                "D1D4", "E8G8", // castle
                "C1C4", "D7D5",
                "D1B3", "D5C4", // capture
                "B3C4",         // capture, ...
            };
            var printer = new BoardPrinter();

            ChessMove result = null;

            var gameMoves = new List <ChessMove>();

            foreach (var move in moves)
            {
                if (ChessMove.Try(move, ref result))
                {
                    Debug.WriteLine($"");
                    Debug.WriteLine($"Move Number: {result.MoveNumber}");
                    Debug.WriteLine($"Origin: {result.Move.Substring(0, 2)}");
                    Debug.WriteLine($"Destination: {result.Move.Substring(2, 2)}");
                    Debug.WriteLine($"");

                    printer.Show(result.Before);
                    printer.Show(result.After);

                    gameMoves.Add(result);
                }
                else
                {
                    break;
                }
            }
        }