def hasLiberties(libertyList,game):
    """Given a list of pieces, determines if any of them touch
    an empty space."""
    
    if len(libertyList)==0:
        return True
    for gridLocation in libertyList:
        x,y = gridLocation
        for i in (-1,1):
            tmpx = x+i
            if tmpx<19 and tmpx>=0 and game[tmpx][y] == 0:
                return True
        for j in (-1,1):
            tmpy = y+j
            if tmpy<19 and tmpy>=0 and game[x][tmpy] == 0:
                return True
    return False