cell:

239 ts--ns---nd ; to square -- next square -- next direction

240 35 241 244 ; d5,,if d5 is empty next square is in cell 241 otherwise it is in cell 244

241 42 242 244

242 49 243 244

243 56 244 244

244 37 245 247 ; f5 starts the next direction

245 46 246 247

246 55 247 247

247 19 248 250 ; d3

248 10 249 250

249 01 250 250

250 21 251 000 ; f3 0 here means no more directions

251 14 252 000

252 07 000 000 ; the first 0 means no next square

Just for clarity here is the bishop on a1.

000 09 001 000 ; b2; only one direction so 0

001 18 002 000 ; c3

002 27 003 000 ; d4

003 36 004 000 ; e5

004 45 005 000 ; f6

005 54 006 000 ; g7

006 63 000 000 ; h8

I have finished both the bishop and the rook initialization. Ran the debugger and checked every cell manually to make sure all entries are correct. The bishop and rook require 1455 cells. Here is the code so far.

Code: Select all

```
typedef struct {
int ts;
int ns;
int nd;
} mt;
mt m[3000];
int b[64];
int r[64];
int q[64];
int n[64];
int k[64];
int p[64];
void InitMovTbl();
void Initialize();
int main();
void InitMovTbl() {
int sq, ns, y, x, dy, dx, o, p, i;
for (sq = ns = 0; sq < 64; sq++) {
y = sq >> 3;
x = sq & 7;
b[sq] = ns;
for (p = ns, dy = 1, dx = -1; y + dy < 8 && x + dx > -1; dy++, dx--) {
o = p;
m[ns].ts = sq + (dy << 3) + dx;
m[ns].ns = ns + 1; ns++;
} for (i = p; i < ns; i++) m[i].nd = ns;
for (p = ns, dy = 1, dx = 1; y + dy < 8 && x + dx < 8; dy++, dx++) {
o = p;
m[ns].ts = sq + (dy << 3) + dx;
m[ns].ns = ns + 1; ns++;
} for (i = p; i < ns; i++) m[i].nd = ns;
for (p = ns, dy = -1, dx = -1; y + dy > -1 && x + dx > -1; dy--, dx--) {
o = p;
m[ns].ts = sq + (dy << 3) + dx;
m[ns].ns = ns + 1; ns++;
} for (i = p; i < ns; i++) m[i].nd = ns;
for (p = ns, dy = -1, dx = 1; y + dy > -1 && x + dx < 8; dy--, dx++) {
o = p;
m[ns].ts = sq + (dy << 3) + dx;
m[ns].ns = ns + 1; ns++;
} for (i = p; i < ns; i++) m[i].nd = ns;
m[ns - 1].ns = 0;
for (i = o; i < ns; i++) m[i].nd = 0;
}
for (sq = 0; sq < 64; sq++) {
y = sq >> 3;
x = sq & 7;
r[sq] = ns;
for (p = ns, dx = -1; x + dx > -1; dx--) {
o = p;
m[ns].ts = sq + dx;
m[ns].ns = ns + 1; ns++;
} for (i = p; i < ns; i++) m[i].nd = ns;
for (p = ns, dy = 1; y + dy < 8; dy++) {
o = p;
m[ns].ts = sq + (dy << 3);
m[ns].ns = ns + 1; ns++;
} for (i = p; i < ns; i++) m[i].nd = ns;
for (p = ns, dx = 1; x + dx < 8; dx++) {
o = p;
m[ns].ts = sq + dx;
m[ns].ns = ns + 1; ns++;
} for (i = p; i < ns; i++) m[i].nd = ns;
for (p = ns, dy = -1; y + dy > -1; dy--) {
o = p;
m[ns].ts = sq + (dy << 3);
m[ns].ns = ns + 1; ns++;
} for (i = p; i < ns; i++) m[i].nd = ns;
m[ns - 1].ns = 0;
for (i = o; i < ns; i++) m[i].nd = 0;
}
}
void Initialize() {
InitMovTbl();
}
int main() {
Initialize();
}
```