The second video in the series where we go over two techniques for selecting parents from a population while breeding offspring!
0:00 Introduction
0:50 Updated Repo & Changes
1:41 Selection Setup Code
3:31 Tournament Selection Explained
4:27 Implementing Tournament Selection
5:19 Uniqueness Lecture & Implementation
6:25 Biased Roulette Wheel Explained
9:27 Biased Roulette Wheel Implementation
11:43 Visualisation
12:10 Challenge Question & Outro
Links!
Visual Studio: visualstudio.microsoft.com/do...
Github: github.com/Gary-The-Cat/Selec...
Introduction Video: • Introduction to Geneti...
Pt. 1 Spawning: • Spawning - Writing you...
Join us on Discord:
/ discord
C# Notes:
Throughout this video, Linq is used quite heavily. Linq is a super convenient way to minimize code length and allows you to perform database-type operations on items that implement IEnumerable (like lists!). One example is:
(angle brackets omitted for ^ due to RU-vid)
var sum = Neighbours.Sum(n = n.GetFitness());
var proportions = Neighbours.Select(n = sum / n.GetFitness());
which is equivalent to
double sum = 0;
for(int i = 0; i ^ Neighbours.Count(); i++)
{
sum += Neighbours[i].GetFitness();
}
List^double^ proportions = new List^double^();
for(int i = 0; i ^ Neighbours.Count(); i++)
{
var neighbour = Neighbours[i];
proportions.Add(sum / neighbour.GetFitness());
}
Obviously, Linq's approach is much more succinct. Learn more here:
www.tutorialsteacher.com/linq...
12 авг 2024