I have quite a bit of programming background, and even game programming background, but have never looked at a real chess engine before.
I recently stumbled on this puzzle-question, which asks for the number of four-piece positions where the next move (whosever it is) will be checkmate. The number has to be somewhere between 400 (the count found by the OP) and 381,225,600 (the total count of four-piece positions), so it ought to be easy to enumerate them all by computer.
I'd like to make a quick program like this:
for white_king_pos in [0, 64):
for black_king_pos in [0, 64):
for white_piece_pos in [0, 64):
for black_piece_pos in [0, 64):
for white_piece_kind in {Q,B,N,R,P}:
for black_piece_kind in {Q,B,N,R,P}:
if next_move_wins_for(black) && next_move_wins_for(white):
count = count + 1
What library should I use in order to make writing the next_move_wins_for
function as painless as possible?
(My program is so simple that I don't care about the library's choice of programming language. But FWIW, my fluent languages are C++, Python, and C.)
Edited to add: Same question for other ways of accomplishing the goal, e.g. tablebases. :)