Esempio n. 1
0
        public void AfterIsCheckTest()
        {
            //a - arange
            var board = new Board();
            var pawn = new FigurePawn(Side.WHITE);
            var king = new FigureKing(Side.WHITE);
            board["h3"] = king;
            board["g2"] = pawn;
            board["f3"] = new FigureQueen(Side.BLACK);

            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsTrue(map.IsCheck);
            Assert.IsTrue(map["f3"].Contains(pawn));
            Assert.IsTrue(map["g3"].Contains(pawn));
            Assert.IsFalse(map["g4"].Contains(pawn));
            Assert.IsFalse(map["g3"].Contains(king));
            Assert.IsFalse(map["g4"].Contains(king));
            Assert.IsTrue(map["h2"].Contains(king));
            Assert.IsTrue(map["h4"].Contains(king));
        }
Esempio n. 2
0
        public void SimpleKingTest()
        {
            //a - arange
            var board = new Board();
            var king = new FigureKing(Side.WHITE);
            board["e4"] = king;

            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsTrue(map["e5"].Contains(king));
            Assert.IsTrue(map["f5"].Contains(king));
            Assert.IsTrue(map["f4"].Contains(king));
            Assert.IsTrue(map["f3"].Contains(king));
            Assert.IsTrue(map["e3"].Contains(king));
            Assert.IsTrue(map["d3"].Contains(king));
            Assert.IsTrue(map["d4"].Contains(king));
            Assert.IsTrue(map["d5"].Contains(king));
            Assert.IsTrue(!map["h6"].Contains(king));
        }
Esempio n. 3
0
        public void ShortCastlingWhiteTest2()
        {
            //a - arange
            var board = new Board();
            var king = new FigureKing(Side.WHITE);
            var rook = new FigureRook(Side.WHITE);
            var pawn = new FigurePawn(Side.WHITE);

            board["e1"] = king;
            board["h1"] = rook;
            board["f1"] = pawn;
            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsFalse(map["g1"].Contains(king));
        }
Esempio n. 4
0
        public void ShortCastlingBlackTest()
        {
            //a - arange
            var board = new Board();
            var king = new FigureKing(Side.BLACK);
            var rook = new FigureRook(Side.BLACK);

            board["e8"] = king;
            board["h8"] = rook;
            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsTrue(map["g8"].Contains(king));
        }
Esempio n. 5
0
        public void LongCastlingWhiteTest()
        {
            //a - arange
            var board = new Board();
            var king = new FigureKing(Side.WHITE);
            var rook = new FigureRook(Side.WHITE);

            board["e1"] = king;
            board["a1"] = rook;
            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsTrue(map["c1"].Contains(king));
        }
Esempio n. 6
0
        public void LongCastlingBlackTest4()
        {
            //a - arange
            var board = new Board();
            var king = new FigureKing(Side.BLACK);
            var rook = new FigureRook(Side.BLACK);
            var knight = new FigureKnight(Side.WHITE);

            board["e8"] = king;
            board["a8"] = rook;
            board["d6"] = knight;
            //a - act
            var moves = new List<Move>{
                new Move { From = "c8", To = "d6" }};
            var map = new AttackMap(moves, board);

            //a - assert
            Assert.IsFalse(map["c8"].Contains(king));
        }
Esempio n. 7
0
        public void LongCastlingBlackTest2()
        {
            //a - arange
            var board = new Board();
            var king = new FigureKing(Side.BLACK);
            var rook = new FigureRook(Side.BLACK);
            var pawn = new FigurePawn(Side.BLACK);

            board["e8"] = king;
            board["a8"] = rook;
            board["b8"] = pawn;
            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsFalse(map["c8"].Contains(king));
        }
Esempio n. 8
0
        public void IsStalemateWhiteTest()
        {
            //a - arange
            var board = new Board();
            var pawn = new FigurePawn(Side.WHITE);
            var pawn2 = new FigurePawn(Side.BLACK);
            var king = new FigureKing(Side.WHITE);
            board["h8"] = king;
            board["f7"] = new FigureQueen(Side.BLACK);
            board["b4"] = pawn;
            board["b5"] = pawn2;

            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsTrue(map.IsStalemateWhite);
        }
Esempio n. 9
0
        public void IsMateWhiteTest()
        {
            //a - arange
            var board = new Board();
            board["a1"] = new FigureKing(Side.WHITE);
            board["a2"] = new FigurePawn(Side.WHITE);
            board["b1"] = new FigureRook(Side.WHITE);
            board["b2"] = new FigureBishop(Side.WHITE);
            board["c2"] = new FigureKnight(Side.BLACK);

            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsTrue(map.IsMateWhite);
        }
Esempio n. 10
0
        public void IsMateBlackTest()
        {
            //a - arange
            var board = new Board();
            var king = new FigureKing(Side.BLACK);
            board["e8"] = king;
            board["g8"] = new FigureQueen(Side.WHITE);
            board["c8"] = new FigureRook(Side.WHITE);
            board["b7"] = new FigureRook(Side.WHITE);
            board["e7"] = new FigureBishop(Side.WHITE);

            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsTrue(map.IsMateBlack);
        }
Esempio n. 11
0
        public void IsCheckTest()
        {
            //a - arange
            var board = new Board();
            var rook = new FigureRook(Side.BLACK);
            var king = new FigureKing(Side.WHITE);
            board["e3"] = king;
            board["h3"] = rook;

            //a - act
            var map = new AttackMap(new List<Move>(), board);
            Assert.IsTrue(map.IsCheck);
        }
Esempio n. 12
0
        public void WhiteKingTest()
        {
            //a - arange
            var board = new Board();
            var king = new FigureKing(Side.WHITE);
            var pawn = new FigurePawn(Side.WHITE);
            var rook = new FigureRook(Side.BLACK);
            var pawn1 = new FigurePawn(Side.BLACK);
            var bishop = new FigureBishop(Side.BLACK);
            var queen = new FigureQueen(Side.BLACK);
            board["e4"] = king;
            board["f5"] = pawn;
            board["f4"] = pawn1;
            board["f3"] = bishop;
            board["e3"] = rook;
            board["d3"] = queen;

            //a - act
            var map = new AttackMap(new List<Move>(), board);
            //a - assert
            Assert.IsFalse(map["e5"].Contains(king));
            Assert.IsFalse(map["f5"].Contains(king));
            Assert.IsTrue(map["f4"].Contains(king));
            Assert.IsFalse(map["f3"].Contains(king));
            Assert.IsFalse(map["e3"].Contains(king));
            Assert.IsFalse(map["d3"].Contains(king));
            Assert.IsFalse(map["d4"].Contains(king));
            Assert.IsFalse(map["d5"].Contains(king));
            Assert.IsFalse(map["g4"].Contains(king));
        }
Esempio n. 13
0
        public void InitialPosition()
        {
            Cells[0, 0] = new FigureRook(Side.WHITE);
            Cells[1, 0] = new FigureKnight(Side.WHITE);
            Cells[2, 0] = new FigureBishop(Side.WHITE);
            Cells[3, 0] = new FigureQueen(Side.WHITE);
            Cells[4, 0] = new FigureKing(Side.WHITE);
            Cells[5, 0] = new FigureBishop(Side.WHITE);
            Cells[6, 0] = new FigureKnight(Side.WHITE);
            Cells[7, 0] = new FigureRook(Side.WHITE);

            for (int i = 0; i < BoardSize; i++)
            {
                Cells[i, 1] = new FigurePawn(Side.WHITE);
            }

            //FillEmptyCells(0, BoardSize, 2, BoardSize - 2);

            for (int i = 0; i < BoardSize; i++)
            {
                Cells[i, 6] = new FigurePawn(Side.BLACK);
            }

            Cells[0, 7] = new FigureRook(Side.BLACK);
            Cells[1, 7] = new FigureKnight(Side.BLACK);
            Cells[2, 7] = new FigureBishop(Side.BLACK);
            Cells[3, 7] = new FigureQueen(Side.BLACK);
            Cells[4, 7] = new FigureKing(Side.BLACK);
            Cells[5, 7] = new FigureBishop(Side.BLACK);
            Cells[6, 7] = new FigureKnight(Side.BLACK);
            Cells[7, 7] = new FigureRook(Side.BLACK);
        }