From 2b62ea0162b3ba4bf1ef7f6162da520155f56775 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Tue, 16 Jul 2024 23:56:09 +0200 Subject: [PATCH] queen seems ok --- checkers.c | 8 ++++++-- display.c | 4 ++-- function.c | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/checkers.c b/checkers.c index 7fcccbc..7ce4e04 100644 --- a/checkers.c +++ b/checkers.c @@ -94,7 +94,9 @@ int queenturn (board_t **board, cache_t *cache, int *xcursor, int *ycursor, int pushcache (cache, *board, *xcursor, *ycursor, queen); *board = copyboard (*board); dopetmove (*board, xcursor, ycursor, direction); - queen = direction; + if (queen == -1) { + queen = direction; + } } else if (testqueenjump (*board, *xcursor, *ycursor, direction)) { pushcache (cache, *board, *xcursor, *ycursor, queen); *board = copyboard (*board); @@ -413,7 +415,9 @@ int main (int argc, char *argv[]) case 'x': if (cache->board) { board = popcache (cache, &xcursor, &ycursor, &queen); - mode = 1; + if (mode == 2) { + mode = 1; + } } break; //case ERR: diff --git a/display.c b/display.c index dd004a2..8a28544 100644 --- a/display.c +++ b/display.c @@ -474,7 +474,7 @@ int cursorwindow (board_t *board, int x, int y, int queen, int mode) _element (board, x + 2, y + 2, 'S'); } break; - case 4: /* 0 -> 1, 3*/ + case 4: /* 0 -> 1, 3 */ if (isempty (board, x, y, 1, 0)) { _element (board, x + 1, y - 1, 'S'); } @@ -485,7 +485,7 @@ int cursorwindow (board_t *board, int x, int y, int queen, int mode) _element (board, x + (1 + d), y + (1 + d), 'S'); } break; - case 5: /* 1 -> 0, 2*/ + case 5: /* 1 -> 0, 2 */ if (isempty (board, x, y, 1, 1)) { _element (board, x - 1, y - 1, 'S'); } diff --git a/function.c b/function.c index a5418e5..2341428 100644 --- a/function.c +++ b/function.c @@ -445,7 +445,9 @@ int _testjump (board_t *board, int x, int y, int delta, int mode) } if (ret) { int id = getid (board, x, y); - ret = ispet (board, x, y, 1 - id, 1 + delta, mode) && isempty (board, x, y, 2 + delta, mode); + ret = (ispet (board, x, y, 1 - id, 1 + delta, mode) || + isqueen (board, x, y, 1 - id, 1 + delta, mode)) && + isempty (board, x, y, 2 + delta, mode); } return ret; } -- 2.30.2