int mode = 1;
if (ispet (*board, *xcursor, *ycursor, player, 0, -1)) {
if ((jump) && (testjump (*board, *xcursor, *ycursor, direction))) {
- pushcache (cache, *board, *xcursor, *ycursor);
+ pushcache (cache, *board, *xcursor, *ycursor, -1);
*board = copyboard (*board);
dopetjump (*board, xcursor, ycursor, direction);
if (!testalljumps (*board, *xcursor, *ycursor)) {
int petmove = (((player == 0) && ((direction == 2) || (direction == 3))) ||
((player == 1) && ((direction == 0) || (direction == 1))));
if (petmove && isempty (*board, *xcursor, *ycursor, 1, direction)) {
- pushcache (cache, *board, *xcursor, *ycursor);
+ pushcache (cache, *board, *xcursor, *ycursor, -1);
*board = copyboard (*board);
dopetmove (*board, xcursor, ycursor, direction);
mode = 2;
if (isqueen (*board, *xcursor, *ycursor, player, 0, -1)) {
if (testqueenmove (*board, *xcursor, *ycursor, queen, direction)) {
- pushcache (cache, *board, *xcursor, *ycursor);
+ pushcache (cache, *board, *xcursor, *ycursor, queen);
*board = copyboard (*board);
dopetmove (*board, xcursor, ycursor, direction);
queen = direction;
} else if (testqueenjump (*board, *xcursor, *ycursor, direction)) {
- pushcache (cache, *board, *xcursor, *ycursor);
+ pushcache (cache, *board, *xcursor, *ycursor, queen);
*board = copyboard (*board);
dopetjump (*board, xcursor, ycursor, direction);
- queen = -1;
+ queen = 4 + direction;
}
}
case '\b':
case 'x':
if (cache->board) {
- board = popcache (cache, &xcursor, &ycursor);
+ board = popcache (cache, &xcursor, &ycursor, &queen);
mode = 1;
}
break;
break;
}
if (mode) {
+ int d;
switch (id) {
case '0':
case '1':
break;
case '6':
case '7':
- if (((queen ==-1) || (queen == 0)) && isempty (board, x, y, 1, 0)) {
- _element (board, x + 1, y - 1, 'S');
- } else if (testjump (board, x, y, 0)) {
- _element (board, x + 2, y - 2, 'S');
- }
- if (((queen == -1) || (queen == 1)) && isempty (board, x, y, 1, 1)) {
- _element (board, x - 1, y - 1, 'S');
- } else if (testjump (board, x, y, 1)) {
- _element (board, x - 2, y - 2, 'S');
- }
- if (((queen == -1) || (queen == 2)) && isempty (board, x, y, 1, 2)) {
- _element (board, x - 1, y + 1, 'S');
- } else if (testjump (board, x, y, 2)) {
- _element (board, x - 2, y + 2, 'S');
- }
- if (((queen == -1) || (queen == 3)) && isempty (board, x, y, 1, 3)) {
- _element (board, x + 1, y + 1, 'S');
- } else if (testjump (board, x, y, 3)) {
- _element (board, x + 2, y + 2, 'S');
+ switch (queen) {
+ case -1:
+ if (isempty (board, x, y, 1, 0)) {
+ _element (board, x + 1, y - 1, 'S');
+ } else if (testjump (board, x, y, 0)) {
+ _element (board, x + 2, y - 2, 'S');
+ }
+ if (isempty (board, x, y, 1, 1)) {
+ _element (board, x - 1, y - 1, 'S');
+ } else if (testjump (board, x, y, 1)) {
+ _element (board, x - 2, y - 2, 'S');
+ }
+ if (isempty (board, x, y, 1, 2)) {
+ _element (board, x - 1, y + 1, 'S');
+ } else if (testjump (board, x, y, 2)) {
+ _element (board, x - 2, y + 2, 'S');
+ }
+ if (isempty (board, x, y, 1, 3)) {
+ _element (board, x + 1, y + 1, 'S');
+ } else if (testjump (board, x, y, 3)) {
+ _element (board, x + 2, y + 2, 'S');
+ }
+ break;
+ case 0:
+ if (isempty (board, x, y, 1, 0)) {
+ _element (board, x + 1, y - 1, 'S');
+ } else if (testjump (board, x, y, 0)) {
+ _element (board, x + 2, y - 2, 'S');
+ }
+ break;
+ case 1:
+ if (isempty (board, x, y, 1, 1)) {
+ _element (board, x - 1, y - 1, 'S');
+ } else if (testjump (board, x, y, 1)) {
+ _element (board, x - 2, y - 2, 'S');
+ }
+ break;
+ case 2:
+ if (isempty (board, x, y, 1, 2)) {
+ _element (board, x - 1, y + 1, 'S');
+ } else if (testjump (board, x, y, 2)) {
+ _element (board, x - 2, y + 2, 'S');
+ }
+ break;
+ case 3:
+ if (isempty (board, x, y, 1, 3)) {
+ _element (board, x + 1, y + 1, 'S');
+ } else if (testjump (board, x, y, 3)) {
+ _element (board, x + 2, y + 2, 'S');
+ }
+ break;
+ case 4: /* 0 -> 1, 3*/
+ if (isempty (board, x, y, 1, 0)) {
+ _element (board, x + 1, y - 1, 'S');
+ }
+ if ((d = testqueenjump (board, x, y, 1)) != 0) {
+ _element (board, x - (1 + d), y - (1 + d), 'S');
+ }
+ if ((d = testqueenjump (board, x, y, 3)) != 0) {
+ _element (board, x + (1 + d), y + (1 + d), 'S');
+ }
+ break;
+ case 5: /* 1 -> 0, 2*/
+ if (isempty (board, x, y, 1, 1)) {
+ _element (board, x - 1, y - 1, 'S');
+ }
+ if ((d = testqueenjump (board, x, y, 0)) != 0) {
+ _element (board, x + (1 + d), y - (1 + d), 'S');
+ }
+ if ((d = testqueenjump (board, x, y, 2)) != 0) {
+ _element (board, x - (1 + d), y + (1 + d), 'S');
+ }
+ break;
+ case 6: /* 2 -> 1, 3 */
+ if (isempty (board, x, y, 1, 2)) {
+ _element (board, x - 1, y + 1, 'S');
+ }
+ if ((d = testqueenjump (board, x, y, 1)) != 0) {
+ _element (board, x - (1 + d), y - (1 + d), 'S');
+ }
+ if ((d = testqueenjump (board, x, y, 3)) != 0) {
+ _element (board, x + (1 + d), y + (1 + d), 'S');
+ }
+ break;
+ case 7: /* 3 -> 0, 2*/
+ if (isempty (board, x, y, 1, 3)) {
+ _element (board, x + 1, y + 1, 'S');
+ }
+ if ((d = testqueenjump (board, x, y, 0)) != 0) {
+ _element (board, x + (1 + d), y - (1 + d), 'S');
+ }
+ if ((d = testqueenjump (board, x, y, 2)) != 0) {
+ _element (board, x - (1 + d), y + (1 + d), 'S');
+ }
+ break;
}
break;
}