'return true if having current_player play at <action> would be suicide'

def is_suicide(self, action):

    (x, y) = action
    num_liberties_here = len(self.liberty_sets[x][y])
    if (num_liberties_here == 0):
        for (nx, ny) in self._neighbors(action):
            is_friendly_group = (self.board[(nx, ny)] == self.current_player)
            group_has_other_liberties = (len((self.liberty_sets[nx][ny] - set([action]))) > 0)
            if (is_friendly_group and group_has_other_liberties):
                return False
            is_enemy_group = (self.board[(nx, ny)] == (- self.current_player))
            if (is_enemy_group and (not group_has_other_liberties)):
                return False
        return True
    return False
