Beispiel #1
0
    // Given a position, produce a 64-bit material signature key.
    // If the engine supports such a key, it should equal the engine's key.
    internal static ulong calc_key(Position pos, int mirror)
    {
        Color     color;
        PieceType pt;
        int       i;
        ulong     key = 0;

        color = mirror == 0 ? Color.WHITE : Color.BLACK;
        for (pt = PieceType.PAWN; pt <= PieceType.KING; ++pt)
        {
            for (i = GlobalMembersTbprobe.popcount <Max15>(pos.pieces(color, pt)); i > 0; i--)
            {
                key ^= Zobrist.psq[(int)Color.WHITE][(int)pt][i - 1];
            }
        }
        color = ~color;
        for (pt = PieceType.PAWN; pt <= PieceType.KING; ++pt)
        {
            for (i = GlobalMembersTbprobe.popcount <Max15>(pos.pieces(color, pt)); i > 0; i--)
            {
                key ^= Zobrist.psq[(int)Color.BLACK][(int)pt][i - 1];
            }
        }

        return(key);
    }
Beispiel #2
0
    // Given a position with 6 or fewer pieces, produce a text string
    // of the form KQPvKRP, where "KQP" represents the white pieces if
    // mirror == 0 and the black pieces if mirror == 1.
//C++ TO C# CONVERTER TODO TASK: Pointer arithmetic is detected on the parameter 'str', so pointers on this parameter are left unchanged:
    internal static void prt_str(Position pos, sbyte *str, int mirror)
    {
        Color     color;
        PieceType pt;
        int       i;

        color = mirror == 0 ? Color.WHITE : Color.BLACK;
        for (pt = PieceType.KING; pt >= PieceType.PAWN; --pt)
        {
            for (i = GlobalMembersTbprobe.popcount <Max15>(pos.pieces(color, pt)); i > 0; i--)
            {
                *str++ = GlobalMembersTbcore.pchr[6 - pt];
            }
        }
        *str++ = 'v';
        color = ~color;
        for (pt = PieceType.KING; pt >= PieceType.PAWN; --pt)
        {
            for (i = GlobalMembersTbprobe.popcount <Max15>(pos.pieces(color, pt)); i > 0; i--)
            {
                *str++ = GlobalMembersTbcore.pchr[6 - pt];
            }
        }
        *str++ = 0;
    }