Code: Select all

```
#define FALSE 0
#define TRUE 1
#define QUIT 0
#define THINK 1
#define GETCMD 2
#define s32 signed __int32
#define u64 unsigned __int64
void Think(void);
void Initialize(void);
void GetCmd(void);
s32 main(void);
u64 dir7p[64];
u64 dir9p[64];
u64 dir7m[64];
u64 dir9m[64];
u64 dir1p[64];
u64 dir8p[64];
u64 dir1m[64];
u64 dir8m[64];
u64 dirKn[64];
u64 dirKi[64];
s32 mode = GETCMD;
u64 *dirPtr[8] = { dir7p, dir9p, dir7m, dir9m, dir1p, dir8p, dir1m, dir8m };
void Think() {
}
void GetCmd() {
mode = QUIT;
}
void Initialize() {
s32 i, j, k, x, y, sq, ts;
s32 dir[8] = { 9, 11, -9, -11, 1, 10, -1, -10 };
s32 din[8] = { 8, 12, 18, 22, -8, -12, -18, -22 };
s32 initBoard[120] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for (i = 21; i < 99; i++) {
if (initBoard[i]) {
y = i / 10; x = i - y * 10 - 1; y -= 2;
sq = y * 8 + x;
dirKi[sq] = 0;
dirKn[sq] = 0;
for (j = 0; j < 8; j++) {
k = i + din[j];
if (initBoard[k]) {
y = k / 10; x = k - y * 10 - 1; y -= 2;
ts = y * 8 + x;
dirKn[sq] |= (u64)1 << ts;
}
dirPtr[j][sq] = 0;
k = i + dir[j];
if (initBoard[k]) {
y = k / 10; x = k - y * 10 - 1; y -= 2;
ts = y * 8 + x;
dirKi[sq] |= (u64)1 << ts;
do {
dirPtr[j][sq] |= ((u64)1 << ts);
k += dir[j];
y = k / 10; x = k - y * 10 - 1; y -= 2;
ts = y * 8 + x;
} while (initBoard[k]);
}
}
}
}
}
s32 main()
{
Initialize();
while (mode) {
if (mode == THINK) Think();
GetCmd();
}
return 0;
}
```

Code: Select all

```
k = i + dir[j];
if (initBoard[k]) {
y = k / 10; x = k - y * 10 - 1; y -= 2;
ts = y * 8 + x;
dirKi[sq] |= (u64)1 << ts;
do {
dirPtr[j][sq] |= ((u64)1 << ts);
k += dir[j];
} while (initBoard[k]) {
y = k / 10; x = k - y * 10 - 1; y -= 2;
ts = y * 8 + x;
}
}
```