added checkmate and stalemate detection