Ejemplo n.º 1
0
        private ulong GetKnightMoves(int i, int j)
        {
            /*
             *   noNoWe    noNoEa
             +15  +17
             |     |
             | noWeWe  +6 __|     |__+10  noEaEa
             \   /
             \     >0<
             \ __ /   \ __
             \ soWeWe -10   |     |   -6  soEaEa
             |     |
             |  -17  -15
             | soSoWe    soSoEa
             */
            int   index      = i * 8 + j;
            ulong initialPos = 1UL << index;

            ulong board = 0;

            board |= BitBoardHelper.ShiftNorthNorthWest(initialPos);
            board |= BitBoardHelper.ShiftNorthNorthEast(initialPos);
            board |= BitBoardHelper.ShiftNorthWestWest(initialPos);
            board |= BitBoardHelper.ShiftNorthEastEast(initialPos);
            board |= BitBoardHelper.ShiftSouthWestWest(initialPos);
            board |= BitBoardHelper.ShiftSouthEastEast(initialPos);
            board |= BitBoardHelper.ShiftSouthSouthWest(initialPos);
            board |= BitBoardHelper.ShiftSouthSouthEast(initialPos);

            return(board);
        }