Coding Challenge #29: Smart Rockets in p5.js

The Coding Train · 410K views · 2016 · 48:17

Open on YouTube

Creative coding & generative artMachine learning & deep learningAlgorithms & data structurestutorial

Why Stack Overflow recommends it

Stack Overflow users link it as a worked example of a genetic algorithm in JavaScript where agents evolve paths to a target around obstacles.

Recommended by 2 people across 2 different months, 2016 to 2021.

What it is

Daniel Shiffman of The Coding Train live-codes a 'smart rockets' genetic algorithm in p5.js, based on a simulation by Jer Thorp. He builds the rocket, population and DNA objects, then adds selection, crossover, mutation, a target and an obstacle so the rockets evolve paths toward the goal.

What people said

Recommends Kim Steinhaug · 2016-12 · Stack Overflow · on “If I have a collection of random websites, how do I get specific information from each?”

AI and machine learning is the way to go, I have startet studying alot on it. Here are some youtube study for you, machine learning in P5 in the browser. Second example till will get updated with real AI. Daniel Shiffman's : [this video] [LINK] Now Sirajology's will be making an AI gaming bot to learn playing that game the most efficiently also on youtube but not there yet! Do update it you get started - we could collaborate as I myself in interested in the same you are working on here! kim at steinhaug dot com

Recommends Dev Oskii · 2017-10 · Stack Overflow · on “Genetic Algorithm in .Net - Variable Chromosomes - Alien Spaceship Scenario”

Here is a very good tutorial on a machine learning implementation in javascript which guides rockets around an obstacle. It's pretty much exactly what you're trying to achieve with your project [this video] It explains in details how to set up the evolution of the rockets path based on fitness. The algorithm adds values to an array which are the steps the rockets take to avoid the obstacle. Every round, the path arrays of each rocket are updated based on the the ones that were most successful last round. Over time the paths improve.

Cites Bigboss01 · 2021-12 · Stack Overflow · on “How to find position for collision detection with rotated and non rotated objects?”

[LINK] This sketch illustrates the problem I'm having. I'd like to check the intersection of the arrowhead and the rectangle, but because the arrowhead is in a rotated space, it does not register the intersection appropriately. I've seen this great tutorial on the separating axis theorem : [LINK] , but I would appreciate some help connecting the dots as I don't fully understand how to implement this solution. I found this library [LINK] , but I would appreciate it if someone knew of a simpler way of doing this, as this seems like a fairly basic problem. The problem I'm trying to solve is in this sketch [LINK] (a lot more code here, skip to this.update() in the rocket object for collision log