private static List <int> LocalSearch(SimParams par, Population pop, int territory, HashSet <int> unavaliable, int needed = 1) { //Get birds that are accaptable and local to a given territory List <int> CurrentIndex; for (int i = 0; i < pop.Local.Length; i++) { CurrentIndex = pop.Local[i][territory].ToList(); //Remove unacceptable birds for (int j = CurrentIndex.Count - 1; j >= 0; j--) { if (unavaliable.Contains(CurrentIndex[j])) { CurrentIndex.RemoveAt(j); } } if (CurrentIndex.Count >= needed) { return(CurrentIndex); } } throw new ArgumentOutOfRangeException("All males are dead or songless; Game Over."); }