queen seems ok
authorLaurent Mazet <mazet@softndesign.org>
Tue, 16 Jul 2024 21:56:09 +0000 (23:56 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Tue, 16 Jul 2024 21:56:09 +0000 (23:56 +0200)
checkers.c
display.c
function.c

index 7fcccbc9e2af3970104f7912b1fde37d0ac462ce..7ce4e04a1162bb24a9ff6ee83d6e52fc38180599 100644 (file)
@@ -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:
index dd004a202bcb59a49ad8ca2a663cfd3fdbb3708b..8a28544f88686dd26c8200a377d8c4c6bbdc12f7 100644 (file)
--- 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');
                 }
index a5418e5a0fa497700225e42067bde1ef5fdd9c1d..2341428f1d3274770470efb64bd6d0022f6d8087 100644 (file)
@@ -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;
 }