O'Reilly logo

Genetic Algorithms and Machine Learning for Programmers by Frances Buontempo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required