finished writing pseudo code for checkmate, needs to be tested, I'm sure it has errors