def winner(game):
    """
    Returns winner of game. 0 for black, 1 white, -1 tie.
    """
    results = game.headers['Result']
    if (results == '0-1'):
        #print("Black wins.")
        return 0
    elif (results == '1-0'):
        #print("White wins.")
        return 1
    elif (results == "1/2-1/2"):
        #print("Tied.")
        return -1
    else:
        raise Exception("Can't tell who won. Is the header mangled?")