if (!testalljumps (board, xcursor, ycursor)) {
mode = 2;
}
- } else if ((player == 1) && (!jump) && (getvalue (board, xcursor + 1, ycursor - 1) == '.')) {
+ } else if ((player == 1) && (!jump) && (isempty (board, xcursor, ycursor, 1, 0))) {
pushcache (cache, board, xcursor, ycursor);
board = copyboard (board);
dopetmove (board, &xcursor, &ycursor, 0);
if (!testalljumps (board, xcursor, ycursor)) {
mode = 2;
}
- } else if ((player == 1) && (!jump) && (getvalue (board, xcursor - 1, ycursor - 1) == '.')) {
+ } else if ((player == 1) && (!jump) && (isempty (board, xcursor, ycursor, 1, 1))) {
pushcache (cache, board, xcursor, ycursor);
board = copyboard (board);
dopetmove (board, &xcursor, &ycursor, 1);
if (!testalljumps (board, xcursor, ycursor)) {
mode = 2;
}
- } else if ((player == 0) && (!jump) && (getvalue (board, xcursor - 1, ycursor + 1) == '.')) {
+ } else if ((player == 0) && (!jump) && (isempty (board, xcursor, ycursor, 1, 2))) {
pushcache (cache, board, xcursor, ycursor);
board = copyboard (board);
dopetmove (board, &xcursor, &ycursor, 2);
if (!testalljumps (board, xcursor, ycursor)) {
mode = 2;
}
- } else if ((player == 0) && (!jump) && (getvalue (board, xcursor + 1, ycursor + 1) == '.')) {
+ } else if ((player == 0) && (!jump) && (isempty (board, xcursor, ycursor, 1, 3))) {
pushcache (cache, board, xcursor, ycursor);
board = copyboard (board);
dopetmove (board, &xcursor, &ycursor, 3);
return (id == -1) ?
(_testcell (board, xcursor, ycursor, '0', delta, mode) &&
_testcell (board, xcursor, ycursor, '1', delta, mode)) :
- _testcell (board, xcursor, ycursor, '0' + id, delta, mode);
+ _testcell (board, xcursor, ycursor, (id == 0) ? '0' : '1', delta, mode);
}
int isqueen (board_t *board, int xcursor, int ycursor, int id, int delta, int mode)
break;
}
if (ret) {
- int id = getvalue (board, x, y) - '0';
+ int id = (getvalue (board, x, y) == '0') ? 0 : 1;
ret = ispet (board, x, y, 1 - id, 1 + delta, mode) && isempty (board, x, y, 2 + delta, mode);
}
return ret;
int evalmaxjumps (board_t *board, int x, int y, int id)
{
int maxjumps = 0;
- if (getvalue (board, x, y) != '0' + id) {
+ if (getvalue (board, x, y) != ((id == 0) ? '1' : '0')) {
return 0;
}