Your Mission: Crowd Control
The genetic algorithm helped cannonballs escape a paper bag, starting with random attempts and improving attempts using crossover and mutation. A PSO is another heuristic random search using particles. This time, you’ll draw on the HTML5 canvas using JavaScript.
You’ll start by moving a single particle around the canvas. Once you know how to move a single particle and draw on canvas, you will consider how to get several particles to follow their neighbors using the k-nearest neighbors’ algorithm. Finally, you adapt this into a particle swarm optimization algorithm to herd the particles out of the paper bag. The swarm needs to share information as they move, and you’ll see how to accomplish this in A Particle Swarm ...
Get Genetic Algorithms and Machine Learning for Programmers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.