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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access