If you're using TSCP (Tom Kerrigan's Simple Chess Program) and XBoard, you might be interested in the following bugfix to source file main.c, routine parse_move():
Code: Select all
/* parse the move s (in coordinate notation) and return the move's
index in gen_dat, or -1 if the move is illegal */
int parse_move(char *s)
{
int from, to, i;
/* make sure the string looks like a move */
if (s[0] < 'a' || s[0] > 'h' ||
s[1] < '0' || s[1] > '9' ||
s[2] < 'a' || s[2] > 'h' ||
s[3] < '0' || s[3] > '9')
return -1;
from = s[0] - 'a';
from += 8 * (8 - (s[1] - '0'));
to = s[2] - 'a';
to += 8 * (8 - (s[3] - '0'));
for (i = 0; i < first_move[1]; ++i)
if (gen_dat[i].m.b.from == from && gen_dat[i].m.b.to == to) {
/* if the move is a promotion, handle the promotion piece;
assume that the promotion moves occur consecutively in
gen_dat. */
if (gen_dat[i].m.b.bits & MMpromote)
switch (s[4]) {
case 'N':
case 'n':
return i;
case 'B':
case 'b':
return i + 1;
case 'R':
case 'r':
return i + 2;
case 'Q':
case 'q':
return i + 3;
default: /* assume it's a queen */
return i + 3;
}
return i;
}
/* didn't find the move */
return -1;
}
----
I've made a big bunch of changes in tscp to greatly reduce the use of naked literals. I'l probably make some more changes after further testing. If you're interested, send me a message in another week or two and I'll upload the revised source.