summaryrefslogtreecommitdiff
path: root/src/engine/moves.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/moves.c')
-rw-r--r--src/engine/moves.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/engine/moves.c b/src/engine/moves.c
index beaf8a6..3aff11e 100644
--- a/src/engine/moves.c
+++ b/src/engine/moves.c
@@ -2,6 +2,7 @@
#include "bitboard.h"
#include "moves/vec.c"
+#include "moves/magic.c"
#include "moves/knight.c"
#include "moves/pawn.c"
#include "moves/rook.c"
@@ -258,12 +259,38 @@ bool test_perft_kiwipete_position() {
"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1"
).position;
int d;
- d = count_positions(position, 1); printf("d0: %d\n", d); if (d != 48) return false;
- d = count_positions(position, 2); printf("d1: %d\n", d); if (d != 2039) return false;
- d = count_positions(position, 3); printf("d2: %d\n", d); if (d != 97862) return false;
- d = count_positions(position, 4); printf("d3: %d\n", d); if (d != 4085603) return false;
- d = count_positions(position, 5); printf("d4: %d\n", d); if (d != 193690690) return false;
- d = count_positions(position, 6); printf("d5: %d\n", d); if (d != 8031647685) return false;
+ d = count_positions(position, 1); printf("d1: %d (expected 48)\n", d); if (d != 48) return false;
+ printf("--- Kiwipete d2 divide ---\n"); perft_divide(position, 2);
+ d = count_positions(position, 2); printf("d2: %d (expected 2039)\n", d); if (d != 2039) return false;
+
+ printf("\n--- Debug: investigate e5g6 ---\n");
+ {
+ moves_t moves;
+ moves_init(&moves);
+ get_legal_moves(&moves, position);
+ for (int i = 0; i < moves.length; i++) {
+ if (moves.moves[i].from == 36 && moves.moves[i].to == 46) {
+ position_t copy = position;
+ position_make_move(&copy, moves.moves[i]);
+ printf("After Nxe5g6, turn=%d, is e8 attacked by white? %d\n",
+ copy.turn, square_attacked(copy, 60, WHITE_TURN));
+ moves_t black_moves;
+ moves_init(&black_moves);
+ get_legal_moves(&black_moves, copy);
+ printf("Black has %d legal moves:\n", black_moves.length);
+ for (int j = 0; j < black_moves.length; j++) {
+ printf(" %c%d%c%d flags=%d\n",
+ 'a' + (black_moves.moves[j].from % 8), 1 + (black_moves.moves[j].from / 8),
+ 'a' + (black_moves.moves[j].to % 8), 1 + (black_moves.moves[j].to / 8),
+ black_moves.moves[j].flags);
+ }
+ moves_deinit(black_moves);
+ break;
+ }
+ }
+ moves_deinit(moves);
+ }
+
return true;
}