wrote some pseudo code for half of checkmate, not sure if it will work