int queenturn (board_t **board, cache_t *cache, int *xcursor, int *ycursor, int queen, int direction)
{
+ int delta;
int player = getid (*board, *xcursor, *ycursor);
if (isqueen (*board, *xcursor, *ycursor, player, 0, -1)) {
if (queen == -1) {
queen = direction;
}
- } else if (testqueenjump (*board, *xcursor, *ycursor, direction)) {
+ } else if ((delta = testqueenjump (*board, *xcursor, *ycursor, direction)) != 0) {
pushcache (cache, *board, *xcursor, *ycursor, queen);
*board = copyboard (*board);
- dopetjump (*board, xcursor, ycursor, direction);
+ doqueenjump (*board, xcursor, ycursor, delta - 1, direction);
queen = 4 + direction;
}
}
/* test: { echo jiclv; sleep 1; echo llciv; sleep 1; echo q; } | checkers.exe -f tests/queens.chk -s 1 2>_ && grep -q 0xeee384a8 _ */
/* test: { echo jiclv; sleep 1; echo llciv; sleep 1; echo q; } | checkers.exe -f tests/queens.chk -s 2 2>_ && grep -q 0xeee384a8 _ */
/* test: { echo jiclv; sleep 1; echo llciv; sleep 1; echo q; } | checkers.exe -f tests/queens.chk -s 3 2>_ && grep -q 0xeee384a8 _ */
+/* test: { echo -n iilc; sleep 1; echo iijjklv; sleep 1; echo q; } | checkers.exe -f tests/queens2.chk 2>_ && grep -q 0x0bd368fa _ */
+/* test: { echo -n iilc; sleep 1; echo jjiilkv; sleep 1; echo -n kkc; sleep 1; echo kliijv; sleep 1; echo q; } | checkers.exe -f tests/queens2.chk 2>_ && grep -q 0xede48902 _ */
+/* test: { echo -n llic; sleep 1; echo jxixlxkxkkkv; sleep 1; echo q; } | checkers.exe -f tests/queens3.chk 2>_ && grep -q 0xb5a71bd2 _ */
+/* test: { echo -n lilillc; sleep 1; echo kjv; sleep 1; echo q; } | checkers.exe -f tests/queens3.chk 2>_ && grep -q 0xcf8873bf _ */
/* vim: set ts=4 sw=4 et: */
void domove (board_t *board, int *x, int *y, int mode);
+void doqueenjump (board_t *board, int *x, int *y, int delta, int mode);
+
void dopetjump (board_t *board, int *x, int *y, int mode);
void dopetmove (board_t *board, int *x, int *y, int mode);
int testqueenjump (board_t *board, int xcursor, int ycursor, int mode);
-int testqueenturn (board_t *board, int xcursor, int ycursor, int id, int queen, int mode);
-
-void doqueenturn (board_t *board, int *xcursor, int *ycursor, int *queen, int mode);
-
cache_t *initcache (board_t *board);
board_t *pushcache (cache_t *cache, board_t *board, int xcursor, int ycursor, int opt);