+
+ // do the move, and look up the new position
+ memcpy(newboard, board, 64);
+ strcpy(nkr, castling_rights);
+ execute_move(newboard, nkr, invert, neps, from_square, to_square);
+ invert_board(newboard);
+
+ if (needs_flipping(newboard, nkr)) {
+ flip_board(newboard, neps);
+ flip = !flip;
+ }
+
+ encode_position(newboard, !invert, nkr, neps);
+ ret = lookup_position(position, pos_len, result);
+ if (!ret) {
+#if DUMP_FEN
+ if (!invert)
+ invert_board(newboard);
+
+ dump_fen(newboard, !invert, flip, nkr, neps);
+#endif
+ fprintf(stderr, "Destination move not found in book.\n");
+ exit(1);
+ }
+
+#if DUMP_FEN
+ // very useful for regression testing (some shell and
+ // you can walk the entire book quite easily)
+ if (!invert)
+ invert_board(newboard);
+ dump_fen(newboard, !invert, flip, nkr, neps);
+ return;
+#endif