Logic of mate in three

Sort:
Vance917

The words that jump out at me are recursion, iteration, and mathematical induction.  You can already do it for n=1.  Now if you can do it for n=k, then can you also do it for n=k+1?  It would seem that you can by applying whatever logic allowed you to jump from n=1 to n=2.

DonnieDarko1980

> If a move can be played where the opponent only has one response and afterward a mate in two exists then do that move.

You won't catch all mates in three with this logic - the opponent might have more than one response, all of them leading to mate in two.

I'm a programmer, but I've never tried to write chess programs - however this sounds a lot like recursion is needed. Something like:

function mate(x)

if x = 1 and (criteria for mate fulfilled) then leave

else if mate(x-1) then leave

omnipaul

A simple mate in 3 that utilizes the flaw you're worrying about:

pauix

This problem needs recursion. In Pseudo-code, it would be like this:

find_checkmate(board_position, number_of_moves){

for(all_possible_moves){

update_board;

for(all possible_responses){

find_checkmate(updated_board, n-1);  

}

if(all the responses lead to mate) return checkmate line; //You're done! 

else check next move;

}

if(found checkmate) return checkmate line;

else return no checkmate;

}

And this can be demonstrated by mathematical induction (mating in n moves equals finding the correct first move and then mating in n-1 moves after all the possible responses). The problem is that this algorithm is going to be extremely slow for big number of moves.

pauix

By the way, what programming language are you using?