转换为dame工作,但捕获不工作为什么?

jei2mxaa  于 2021-06-29  发布在  Java
关注(0)|答案(1)|浏览(339)

我定义了一个 long 整数:

static long white1 = 0b101001011101001001101000110101000100101000010101000000L;
static long white2 = 0b101010110101010100101010010101010000101001111101001101L;
static long black1 = 0b100110010100110000100101111100101101100101011100101001L;
static long black2 = 0b100111111100111101100111011100111001100110110100110100L;

游戏状态:

static Long[] state = { white1, white2, black1, black2 };

黑白两色都有代号6的棋子。我不能使用std表生成跳棋。
如果我去了位置x,7或x,0,我将典当转换为夫人:

static void updateDame(byte n) {
    long apos = 1 << (n % 6) * 9 + 7;
    state[n / 6] = state[n / 6] + apos;
}

还有这个工作。但是

static void updateCaptured(byte n) {
    long apos = 0 << (n % 6) * 9 + 8;
    state[n / 6] = state[n / 6] + apos;
}

还是不行。。。我要换9号。从1到0的位。如果我把0改成1(像dame一样),它就行了。
如果我尝试1(二进制的1+1等于10)它将不起作用-在典当附近捕获。。。我怎样才能改变它?

1l5u6lss

1l5u6lss1#

long apos = 0 << (n % 6) * 9 + 8;

零左移仍然是零。

相关问题