# $ % దԠ $ func Select(indi Individuals) (Individuals, error) { if len(indi) < t.NContestants { return nil, errors.New("NContestants is too large") } selected := make(Individuals, len(indi)) for i := range selected { winner := indi[rand.Intn(len(indi))] for j := 0; j < t.NContestants; j++ { next := indi[rand.Intn(len(indi))] if winner.Fitness > next.Fitness { winner = next } } selected[i] = winner } return selected, nil }