예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #4
0
 public BitboardShogiGame(IBoard board, IBoardRender render)
 {
     _board      = board;
     _render     = render;
     _boardState = new BitboardState();
 }
예제 #5
0
 public void Refresh(BitboardState boardState)
 {
     throw new System.NotImplementedException();
 }
예제 #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]);
        }
예제 #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]);
        }
예제 #8
0
 public FullBitboardState(BitboardState whitePieces, BitboardState blackPieces)
 {
     WhitePieces = whitePieces;
     BlackPieces = blackPieces;
 }
예제 #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]);
        }