Beispiel #1
0
        public void SupportAndBinaryBetweentwoBitboardStates()
        {
            var state1        = new BitboardState(1 << 8, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, 1 << 4, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow);
            var state2        = new BitboardState(1, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, 1 << 4, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow);
            var expectedState = new BitboardState(HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, 1 << 4, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow);

            var actualState = state1 & state2;

            Assert.Equal(expectedState, actualState);
        }
Beispiel #2
0
        public void SupportXorBinaryBetweenTwoBitboardStates()
        {
            var state1        = new BitboardState(0x100, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow);
            var state2        = new BitboardState(0x1, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, 1 << 4, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow);
            var expectedState = new BitboardState(0x101, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, 1 << 4, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow);

            var actualState = state1 ^ state2;

            Assert.Equal(expectedState, actualState);
        }
Beispiel #3
0
        public void UpdateBitboardStateForValidMoves()
        {
            var complexState = new FullBitboardState(
                BitboardPredefinedStates.InitialWhitePositions, BitboardPredefinedStates.InitialBlackPositions);

            var expectedState = new BitboardState(HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, 0x100, 0xFF, HexValues.TwoPieceRow, HexValues.FullRow);
            var board         = new Bitboard(complexState);

            board.Move(PlayerType.Black, "9g9f");

            Assert.Equal(BitboardPredefinedStates.InitialWhitePositions, board.BitboardState.WhitePieces);
            Assert.Equal(expectedState, board.BitboardState.BlackPieces);
        }
Beispiel #4
0
 public BitboardShogiGame(IBoard board, IBoardRender render)
 {
     _board      = board;
     _render     = render;
     _boardState = new BitboardState();
 }
Beispiel #5
0
 public void Refresh(BitboardState boardState)
 {
     throw new System.NotImplementedException();
 }
Beispiel #6
0
        public void GetBitBasedOnIndexedProperty()
        {
            var state = new BitboardState(1 << 8, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow);

            Assert.True(state[0]);
        }
Beispiel #7
0
        public void ThrowIndexOutOfRangeExceptionForIndexesGreaterThan80()
        {
            var state = new BitboardState(HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow, HexValues.EmptyRow);

            Assert.Throws <IndexOutOfRangeException>(() => state[81]);
        }
Beispiel #8
0
 public FullBitboardState(BitboardState whitePieces, BitboardState blackPieces)
 {
     WhitePieces = whitePieces;
     BlackPieces = blackPieces;
 }
Beispiel #9
0
        public void ThrowIndexOutOfRangeExceptionForIndexesBelow0()
        {
            var state = new BitboardState(BinaryValues.EmptyRow, BinaryValues.EmptyRow, BinaryValues.EmptyRow, BinaryValues.EmptyRow, BinaryValues.EmptyRow, BinaryValues.EmptyRow, BinaryValues.EmptyRow, BinaryValues.EmptyRow, BinaryValues.EmptyRow);

            Assert.Throws <IndexOutOfRangeException>(() => state[-1]);
        }