public void BishopBorderBlocked() { BitBoard border = 0xff818181818181ff; BitBoard borderInner = 0x7e424242427e00; var corners = BitBoards.MakeBitboard(Squares.a1, Squares.a8, Squares.h1, Squares.h8); const int expectedCorner = 1; // just a single attack square no matter what const int expectedSide = 2; /* * borderInner (X = set bit) : * * 0 0 0 0 0 0 0 0 * 0 X X X X X X 0 * 0 X 0 0 0 0 X 0 * 0 X 0 0 0 0 X 0 * 0 X 0 0 0 0 X 0 * 0 X 0 0 0 0 X 0 * 0 X X X X X X 0 * 0 0 0 0 0 0 0 0 * */ foreach (var square in border) { var attacks = square.BishopAttacks(borderInner); attacks.IsEmpty.Should().BeFalse(); var expected = corners & square ? expectedCorner : expectedSide; var actual = attacks.Count; Assert.Equal(expected, actual); } }
public void MakeBitBoardTest() { // a few squares var b1 = BitBoards.MakeBitboard(Squares.a1, Squares.b1, Squares.a2, Squares.b2); var b2 = Squares.a1.BitBoardSquare() | Squares.b1.BitBoardSquare() | Squares.a2.BitBoardSquare() | Squares.b2.BitBoardSquare(); Assert.Equal(b1, b2); // a single square (not needed, but still has to work in case of list of squares etc) var b3 = BitBoards.MakeBitboard(Squares.h3); var b4 = Squares.h3.BitBoardSquare(); Assert.Equal(b3, b4); }