public List <myAnimal> Solve() { List <myAnimal> boat = new List <myAnimal>(); var priorityQueue = new PriorityQueue(Animals); while (priorityQueue.Animals.Count != 0) { var animal = priorityQueue.GetMax(); var newBoat = new List <myAnimal>(boat); newBoat.Add(animal); if (AnimalTask.CheckBoat(newBoat)) { boat = newBoat; } } return(boat); }
public List <List <myAnimal> > Breeding(List <List <myAnimal> > animals, double a) { Random r = new Random(); var childs = new List <List <myAnimal> >(); for (int i = 0; i < animals.Count; i += 2) { if (i + 1 < animals.Count) { var child = Compound(animals[i], animals[i + 1]); if (a < r.NextDouble()) { child = Mutation(child); } if (AnimalTask.CheckBoat(child)) { childs.Add(child); } } } return(childs); }