def fmt_mate(mate_score):
    """Format a mate value as a proper string."""
    if mate_score < 0: # mate in X for black
        return "-M{:d}".format(abs(mate_score))
    else: # mate in X for white
        return "+M{:d}".format(abs(mate_score))