title
Coding Challenge #29: Smart Rockets in p5.js

description
In this coding challenge, I implement a "smart rockets" algorithm (based on a simulation by Jer Thorp). Code: https://thecodingtrain.com/challenges/29-smart-rockets-in-p5js 🕹ī¸ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/o5PwECj42 đŸŽĨ Previous video: https://youtu.be/ccYLb7cLB1I?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH đŸŽĨ Next video: https://youtu.be/KWoJgHFYWxY?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH đŸŽĨ All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH Videos: đŸŽĨ My Genetic Algorithm playlist: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6bJM3VgzjNV5YxVxUwzALHV 🔴 Livestream Archive: https://youtu.be/A01_aKgIeCo Related Coding Challenges: 🚂 #69 Evolutionary Steering Behaviors: https://youtu.be/flxOkx0yLrY 🚂 #100 Neuroevolution Flappy Bird: https://youtu.be/c6y21FkaUqw 🚂 #147 Chrome Dinosaur Game: https://youtu.be/l0HoJHc-63Q Timestamps: 0:00 Introduction 3:10 Rocket object 7:07 Population object 10:48 DNA object 15:09 Add target 17:24 Evaluate function 19:35 Mating pool 23:26 Selection function 25:36 Crossover function 33:56 Is the genetic algorithm working? 35:50 Check if rocket has reached target 38:05 Mutation function 40:17 Add obstacle 43:34 Check if rocket hits canvas edges 46:55 Conclusion and possible improvements Editing by Mathieu Blanchette Animations by Jason Heglund Music from Epidemic Sound 🚂 Website: http://thecodingtrain.com/ 👾 Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide 🚩 Suggest Topics: https://github.com/CodingTrain/Suggestion-Box 💡 GitHub: https://github.com/CodingTrain đŸ’Ŧ Discord: https://discord.gg/hPuGy2g 💖 Membership: http://youtube.com/thecodingtrain/join 🛒 Store: https://standard.tv/codingtrain 🖋ī¸ Twitter: https://twitter.com/thecodingtrain 📸 Instagram: https://www.instagram.com/the.coding.train/ đŸŽĨ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH đŸŽĨ Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA 🔗 p5.js: https://p5js.org 🔗 p5.js Web Editor: https://editor.p5js.org/ 🔗 Processing: https://processing.org 📄 Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new #geneticalgorithm #dna #evolutionaryalgorithm #p5js #javascript

detail
{'title': 'Coding Challenge #29: Smart Rockets in p5.js', 'heatmap': [{'end': 1811.665, 'start': 1755.152, 'weight': 1}], 'summary': 'Showcases the smart rockets project in javascript using p5.js, featuring genetic algorithms and rockets launching to reach a target. it covers rocket population creation, genetic algorithm implementation, mating pool creation, and rocket evolution challenges, resulting in improved obstacle navigation over 400 cycles.', 'chapters': [{'end': 423.838, 'segs': [{'end': 61.702, 'src': 'embed', 'start': 20.726, 'weight': 0, 'content': [{'end': 23.267, 'text': 'which is a environment for programming ActionScript.', 'start': 20.726, 'duration': 2.541}, {'end': 26.747, 'text': "I'm going to do this in JavaScript using the p5.js framework.", 'start': 23.867, 'duration': 2.88}, {'end': 34.749, 'text': "The reason why I love this project is it's a great example of genetic algorithms in the wild at play with an animation physics-based system.", 'start': 27.028, 'duration': 7.721}, {'end': 40.531, 'text': "So what you'll see here is that there are these rockets being launched from the bottom, and they're trying to reach that target up there.", 'start': 35.149, 'duration': 5.382}, {'end': 47.112, 'text': 'And they have built into them this DNA, this DNA, this virtual DNA that tells them how to move about the screen.', 'start': 40.851, 'duration': 6.261}, {'end': 49.953, 'text': 'So let me briefly talk to you about how that works.', 'start': 47.392, 'duration': 2.561}, {'end': 55.497, 'text': 'So the rockets actually have a bunch of thrusters on them.', 'start': 50.393, 'duration': 5.104}, {'end': 58.019, 'text': 'This is my pathetic, terrible drawing of that.', 'start': 55.797, 'duration': 2.222}, {'end': 61.702, 'text': 'And all of those point in a certain direction.', 'start': 58.78, 'duration': 2.922}], 'summary': 'Using javascript and p5.js, a genetic algorithm simulates rockets reaching a target in a physics-based animation system.', 'duration': 40.976, 'max_score': 20.726, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g20726.jpg'}, {'end': 114.413, 'src': 'embed', 'start': 82.384, 'weight': 4, 'content': [{'end': 84.547, 'text': 'So what I need is a couple things.', 'start': 82.384, 'duration': 2.163}, {'end': 88.054, 'text': 'I need to ultimately have a rocket object.', 'start': 85.532, 'duration': 2.522}, {'end': 91.357, 'text': 'And that rocket object is going to have to have physics built into it.', 'start': 88.414, 'duration': 2.943}, {'end': 97.421, 'text': "I'm also going to need to have some DNA object, which is DNA, to control the physics.", 'start': 91.957, 'duration': 5.464}, {'end': 103.346, 'text': 'And then the DNA object is going to need to have functions like mutation and crossover.', 'start': 97.822, 'duration': 5.524}, {'end': 107.129, 'text': 'These are pieces of functionality that exist as part of a genetic algorithm.', 'start': 103.706, 'duration': 3.423}, {'end': 109.35, 'text': 'Hey, if you want to know about genetic algorithms,', 'start': 107.529, 'duration': 1.821}, {'end': 114.413, 'text': 'I have a whole set of video tutorials linked to the description of this video that go through the algorithm in detail.', 'start': 109.35, 'duration': 5.063}], 'summary': 'Create a rocket object with physics and dna for genetic algorithm.', 'duration': 32.029, 'max_score': 82.384, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g82384.jpg'}, {'end': 203.653, 'src': 'embed', 'start': 174.633, 'weight': 2, 'content': [{'end': 176.194, 'text': 'And I just started with basically nothing.', 'start': 174.633, 'duration': 1.561}, {'end': 178.495, 'text': 'I have create canvas and background.', 'start': 176.494, 'duration': 2.001}, {'end': 179.936, 'text': 'This is the only code I have.', 'start': 178.715, 'duration': 1.221}, {'end': 181.837, 'text': 'Create a canvas and draw a black background.', 'start': 180.176, 'duration': 1.661}, {'end': 187.841, 'text': 'The first thing I want to do is create this rocket object.', 'start': 183.649, 'duration': 4.192}, {'end': 191.451, 'text': "So I'm going to do that with a constructor function.", 'start': 188.523, 'duration': 2.928}, {'end': 194.729, 'text': 'And I want my rocket to have a position.', 'start': 192.928, 'duration': 1.801}, {'end': 196.75, 'text': "And I'm going to say create vector.", 'start': 194.749, 'duration': 2.001}, {'end': 199.051, 'text': 'I want it to have a velocity.', 'start': 196.77, 'duration': 2.281}, {'end': 200.512, 'text': "I'm going to say create vector.", 'start': 199.071, 'duration': 1.441}, {'end': 203.653, 'text': 'And I want it to have an acceleration.', 'start': 200.532, 'duration': 3.121}], 'summary': 'Started with nothing, created canvas, background, and a rocket object with position, velocity, and acceleration.', 'duration': 29.02, 'max_score': 174.633, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g174633.jpg'}], 'start': 0.236, 'title': 'Smart rockets and genetic algorithms', 'summary': 'Discusses the smart rockets project, originally in flash and now in javascript using p5.js, showcasing genetic algorithms with rockets launching to reach a target. it also covers the concept of smart rockets and genetic algorithms, emphasizing virtual dna control of rocket movement and the use of a population object to manage evolution.', 'chapters': [{'end': 40.531, 'start': 0.236, 'title': 'Smart rockets coding challenge', 'summary': 'Discusses the smart rockets project, originally developed in flash, now being programmed in javascript using p5.js framework, showcasing genetic algorithms in action with rockets launching to reach a target.', 'duration': 40.295, 'highlights': ['The Smart Rockets project, originally developed in Flash, is now being reprogrammed in JavaScript using the p5.js framework to showcase genetic algorithms in action with rockets launching to reach a target.', 'The project demonstrates genetic algorithms in the wild, functioning within an animation physics-based system.']}, {'end': 173.573, 'start': 40.851, 'title': 'Smart rockets and genetic algorithms', 'summary': "Discusses the concept of smart rockets and genetic algorithms, which utilize virtual dna to control rocket movement, with emphasis on the rockets' dna structure and functionality, as well as the use of a population object to manage an array of rockets for evolution.", 'duration': 132.722, 'highlights': ['Smart rockets are controlled by virtual DNA, determining the number of thrusters, their direction, and firing sequence, facilitating efficient movement towards a target.', 'The implementation involves creating a rocket object with built-in physics, a DNA object to control the physics with functions like mutation and crossover, and a population object to manage an array of rocket objects for evolution.', 'The smart rockets utilize genetic algorithms, and their evolution can be observed as they navigate obstacles to reach the top, demonstrating the effectiveness of the DNA-controlled movement.']}, {'end': 423.838, 'start': 174.633, 'title': 'Creating a rocket object with physics', 'summary': 'Outlines the process of creating a rocket object with position, velocity, and acceleration through constructor functions, applying forces and updating its position, and visualizing it on a canvas using p5.js, resulting in the successful creation and movement of a single rocket on the screen.', 'duration': 249.205, 'highlights': ['The chapter demonstrates the process of creating a rocket object with position, velocity, and acceleration through constructor functions, applying forces and updating its position, and visualizing it on a canvas using P5.js.', 'The rocket object has a position, a velocity, and acceleration, with the acceleration being controlled by forces in the environment or forces by its rocket thrusters.', 'The process involves creating a rocket object, applying forces to it, updating its position, and visualizing it on a canvas, resulting in the successful creation and movement of a single rocket on the screen.']}], 'duration': 423.602, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g236.jpg', 'highlights': ['The Smart Rockets project, originally developed in Flash, is now being reprogrammed in JavaScript using the p5.js framework to showcase genetic algorithms in action with rockets launching to reach a target.', 'Smart rockets are controlled by virtual DNA, determining the number of thrusters, their direction, and firing sequence, facilitating efficient movement towards a target.', 'The chapter demonstrates the process of creating a rocket object with position, velocity, and acceleration through constructor functions, applying forces and updating its position, and visualizing it on a canvas using P5.js.', 'The project demonstrates genetic algorithms in the wild, functioning within an animation physics-based system.', 'The implementation involves creating a rocket object with built-in physics, a DNA object to control the physics with functions like mutation and crossover, and a population object to manage an array of rocket objects for evolution.', 'The smart rockets utilize genetic algorithms, and their evolution can be observed as they navigate obstacles to reach the top, demonstrating the effectiveness of the DNA-controlled movement.']}, {'end': 939.755, 'segs': [{'end': 519.583, 'src': 'embed', 'start': 455.417, 'weight': 0, 'content': [{'end': 461.04, 'text': 'So what I want to say is this.rockets index i equals a new rocket.', 'start': 455.417, 'duration': 5.623}, {'end': 471.781, 'text': "And one thing I'm going to do is have their initial velocity, just for right now, be just so I can see a random vector.", 'start': 462.712, 'duration': 9.069}, {'end': 476.545, 'text': "And what I'm going to do now is create a population.", 'start': 472.521, 'duration': 4.024}, {'end': 483.752, 'text': "And I'm going to say the population should update.", 'start': 480.649, 'duration': 3.103}, {'end': 486.694, 'text': "And I'm just going to actually write a function called run.", 'start': 484.372, 'duration': 2.322}, {'end': 492.182, 'text': "And then in the population object itself, I'm going to write a function called run.", 'start': 488.058, 'duration': 4.124}, {'end': 498.288, 'text': 'And what I want to do there is back again.', 'start': 493.323, 'duration': 4.965}, {'end': 502.452, 'text': 'And what I want to do is now say, oh, this.rockets.', 'start': 498.368, 'duration': 4.084}, {'end': 508.639, 'text': 'Whoops I need to say this.rockets index i.update.', 'start': 502.472, 'duration': 6.167}, {'end': 513.881, 'text': 'And this dot rockets index i dot show.', 'start': 510.801, 'duration': 3.08}, {'end': 519.583, 'text': "I'm back after some technical difficulties, and there's a big bug in my code.", 'start': 514.422, 'duration': 5.161}], 'summary': 'Creating rockets with initial velocity, updating population, encountering a bug.', 'duration': 64.166, 'max_score': 455.417, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g455417.jpg'}, {'end': 564.749, 'src': 'embed', 'start': 538.03, 'weight': 1, 'content': [{'end': 544.675, 'text': 'for population and that variable pop is now my global variable which overrides the p5 function named pop.', 'start': 538.03, 'duration': 6.645}, {'end': 546.596, 'text': "so I really shouldn't have done that.", 'start': 544.675, 'duration': 1.921}, {'end': 547.837, 'text': 'I need to name this something else.', 'start': 546.596, 'duration': 1.241}, {'end': 551.96, 'text': "I'll call it popule for population, and you know what I don't know.", 'start': 547.837, 'duration': 4.123}, {'end': 553.701, 'text': 'I can actually just say population.', 'start': 551.96, 'duration': 1.741}, {'end': 564.749, 'text': "I'll do this population run and now we should see there's one rocket lifting off and now I can change the population size to like 25 and we can see there we go,", 'start': 553.701, 'duration': 11.048}], 'summary': "Renamed global variable 'pop' to 'population' for clarity.", 'duration': 26.719, 'max_score': 538.03, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g538030.jpg'}, {'end': 619.47, 'src': 'embed', 'start': 575.195, 'weight': 4, 'content': [{'end': 585.882, 'text': "let's say no stroke, let's give them fill 255 with a little bit of alpha and we should see now there we go.", 'start': 575.195, 'duration': 10.687}, {'end': 589.624, 'text': 'so this is these are our smart rockets lifting off from the bottom of the screen.', 'start': 585.882, 'duration': 3.742}, {'end': 590.445, 'text': "so we're getting somewhere.", 'start': 589.624, 'duration': 0.821}, {'end': 591.926, 'text': "we've got the physics system.", 'start': 590.445, 'duration': 1.481}, {'end': 599.818, 'text': 'now, If I return to over here,', 'start': 591.926, 'duration': 7.892}, {'end': 608.44, 'text': 'in the original smart rockets there are actually a set of specific thrusters positioned on the rocket that push off a force in a given direction.', 'start': 599.818, 'duration': 8.622}, {'end': 610.26, 'text': "I'm gonna do something a little bit simpler.", 'start': 608.76, 'duration': 1.5}, {'end': 615.642, 'text': "What I'm gonna do as the object's DNA is I'm just gonna create an array.", 'start': 610.761, 'duration': 4.881}, {'end': 619.47, 'text': 'the array of DNAs.', 'start': 617.148, 'duration': 2.322}], 'summary': 'Developing smart rockets with a physics system and dna array', 'duration': 44.275, 'max_score': 575.195, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g575195.jpg'}, {'end': 917.726, 'src': 'embed', 'start': 887.792, 'weight': 2, 'content': [{'end': 890.695, 'text': 'I got lost in my own thought with all my computers and typing and coding thing.', 'start': 887.792, 'duration': 2.903}, {'end': 891.796, 'text': 'so here we are.', 'start': 890.695, 'duration': 1.101}, {'end': 893.417, 'text': 'and yes, here we are.', 'start': 891.796, 'duration': 1.621}, {'end': 898.3, 'text': 'we now have a system So far where I have a population of rockets.', 'start': 893.417, 'duration': 4.883}, {'end': 899.78, 'text': 'the rockets have DNA.', 'start': 898.3, 'duration': 1.48}, {'end': 904.842, 'text': 'the DNA has embedded into it an array of vectors that tell it how to move around the screen.', 'start': 899.78, 'duration': 5.062}, {'end': 907.443, 'text': 'Now what I need is a target.', 'start': 905.262, 'duration': 2.181}, {'end': 913.405, 'text': 'I need to have a place where these rockets are trying to reach.', 'start': 908.043, 'duration': 5.362}, {'end': 917.726, 'text': "So I'm going to create a variable called target, a global variable.", 'start': 914.125, 'duration': 3.601}], 'summary': 'Creating a system with rockets having dna to move towards a target.', 'duration': 29.934, 'max_score': 887.792, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g887792.jpg'}], 'start': 423.858, 'title': 'Rocket population and smart rockets simulation', 'summary': 'Introduces the creation of a population of rockets with initial velocity and addresses a bug related to variable naming conflict. it also explores the creation of a smart rockets simulation with dna encoded rockets programmed to reach a target, showcasing the development process and application of physics principles.', 'chapters': [{'end': 553.701, 'start': 423.858, 'title': 'Rocket population and code bug', 'summary': 'Introduces the creation of a population of rockets with initial velocity and the development of a function called run. it also addresses a bug related to a variable naming conflict, impacting the p5 function.', 'duration': 129.843, 'highlights': ['The chapter discusses the creation of a population of rockets with an array of rockets and a population size of 100, along with assigning an initial random velocity to each rocket.', 'It introduces the development of a function called run for the population to update and a run function within the population object.', "The transcript addresses a bug related to a variable naming conflict, where the variable 'pop' overrides the p5 function named 'pop', impacting the code functionality."]}, {'end': 939.755, 'start': 553.701, 'title': 'Smart rockets simulation', 'summary': 'Explores the creation of a smart rockets simulation, where a population of rockets with dna encoded with arrays of vectors are programmed to move around the screen and reach a specific target, showcasing the development process and the application of physics principles.', 'duration': 386.054, 'highlights': ['The chapter explores the creation of a smart rockets simulation Describes the development of a simulation involving smart rockets', 'Population of rockets with DNA encoded with arrays of vectors Discusses the programming of rockets with DNA containing arrays of vectors for movement', 'Rockets programmed to move around the screen and reach a specific target Details the objective of the rockets to move around the screen and reach a specific target', 'Application of physics principles Showcases the application of physics principles in the simulation']}], 'duration': 515.897, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g423858.jpg', 'highlights': ['The chapter discusses the creation of a population of rockets with an array of rockets and a population size of 100, along with assigning an initial random velocity to each rocket.', "The transcript addresses a bug related to a variable naming conflict, where the variable 'pop' overrides the p5 function named 'pop', impacting the code functionality.", 'Population of rockets with DNA encoded with arrays of vectors Discusses the programming of rockets with DNA containing arrays of vectors for movement', 'Rockets programmed to move around the screen and reach a specific target Details the objective of the rockets to move around the screen and reach a specific target', 'Application of physics principles Showcases the application of physics principles in the simulation', 'It introduces the development of a function called run for the population to update and a run function within the population object.', 'The chapter explores the creation of a smart rockets simulation Describes the development of a simulation involving smart rockets']}, {'end': 1322.626, 'segs': [{'end': 1000.699, 'src': 'embed', 'start': 973.206, 'weight': 1, 'content': [{'end': 976.768, 'text': 'okay, so now we should see when this gets to 200.', 'start': 973.206, 'duration': 3.562}, {'end': 979.29, 'text': "so we've got the system working here.", 'start': 976.768, 'duration': 2.522}, {'end': 983.352, 'text': "we have, and I'm just going to kind of zoom on this, zoom in on this to talk about it for a second.", 'start': 979.29, 'duration': 4.062}, {'end': 992.799, 'text': "okay, so over here we have a system now where I am every 200 frames, launching 200 rockets into space and I'm counting up to 200.", 'start': 983.352, 'duration': 9.447}, {'end': 993.96, 'text': 'when I get to 200 I start 200 rockets over.', 'start': 992.799, 'duration': 1.161}, {'end': 1000.699, 'text': "What I'm missing now from this example is the genetic algorithm itself.", 'start': 996.874, 'duration': 3.825}], 'summary': 'Testing a system to launch 200 rockets into space every 200 frames.', 'duration': 27.493, 'max_score': 973.206, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g973206.jpg'}, {'end': 1050.619, 'src': 'embed', 'start': 1018.209, 'weight': 0, 'content': [{'end': 1023.352, 'text': 'I want the rockets with the highest fitness that did the best to pass on their genetic information to the next generation.', 'start': 1018.209, 'duration': 5.143}, {'end': 1032.557, 'text': "The next step that I need to do in population is I'm going to call, say, this.evaluate.", 'start': 1023.913, 'duration': 8.644}, {'end': 1036.358, 'text': 'Uh-oh, my camera went off.', 'start': 1035.398, 'duration': 0.96}, {'end': 1046.616, 'text': 'So what do I want to do in evaluate? I want to run through all of the rockets.', 'start': 1042.213, 'duration': 4.403}, {'end': 1050.619, 'text': 'And I want to calculate their fitness.', 'start': 1048.697, 'duration': 1.922}], 'summary': 'Select rockets with highest fitness for genetic inheritance.', 'duration': 32.41, 'max_score': 1018.209, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1018209.jpg'}, {'end': 1139.141, 'src': 'embed', 'start': 1112.941, 'weight': 2, 'content': [{'end': 1122.888, 'text': "So and I'm going to say this.fitness equals 1 divided by distance, right? Because if the distance is 1, my fitness is 1.", 'start': 1112.941, 'duration': 9.947}, {'end': 1128.793, 'text': "If the distance is 100, it's further away, my fitness should be lower, like 0.01, like 1 divided by 100.", 'start': 1122.888, 'duration': 5.905}, {'end': 1132.616, 'text': 'So in this sense, I now have a fitness of 1 divided by distance.', 'start': 1128.793, 'duration': 3.823}, {'end': 1134.057, 'text': 'OK, this is good.', 'start': 1133.016, 'duration': 1.041}, {'end': 1139.141, 'text': 'So in the population, Back to the population.', 'start': 1134.437, 'duration': 4.704}], 'summary': 'Fitness is determined by 1/distance, with lower distance resulting in higher fitness.', 'duration': 26.2, 'max_score': 1112.941, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1112941.jpg'}, {'end': 1191.137, 'src': 'embed', 'start': 1160.339, 'weight': 4, 'content': [{'end': 1162.921, 'text': 'The higher their fitness, I want the higher chance of picking them.', 'start': 1160.339, 'duration': 2.582}, {'end': 1169.866, 'text': 'So rockets that did really well or that get closer to the target are more likely to pass their genetic information down to the next generation.', 'start': 1163.241, 'duration': 6.625}, {'end': 1172.628, 'text': 'So what I want to do is create a variable.', 'start': 1170.367, 'duration': 2.261}, {'end': 1174.07, 'text': "I'm going to call it a mating pool.", 'start': 1172.648, 'duration': 1.422}, {'end': 1176.591, 'text': "And it's an empty array.", 'start': 1174.83, 'duration': 1.761}, {'end': 1181.634, 'text': 'and the first thing I want to do actually I need to make sure I clear it.', 'start': 1177.832, 'duration': 3.802}, {'end': 1191.137, 'text': 'so every time I do this, I want to like make it an empty array again, and then what I want to do is I want to.', 'start': 1181.634, 'duration': 9.503}], 'summary': 'Fitness determines genetic pass down; creates mating pool.', 'duration': 30.798, 'max_score': 1160.339, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1160339.jpg'}, {'end': 1283.174, 'src': 'embed', 'start': 1251.544, 'weight': 3, 'content': [{'end': 1253.919, 'text': 'and divide it by the maximum fitness.', 'start': 1251.544, 'duration': 2.375}, {'end': 1263.229, 'text': "So that should normalize them, right? If the maximum fitness is 1, 000, the one with 1, 000, divide by 1, 000, I'll get the value 1.", 'start': 1255.287, 'duration': 7.942}, {'end': 1267.15, 'text': 'All the fitness values will be between 0 and 1 at the moment.', 'start': 1263.229, 'duration': 3.921}, {'end': 1277.532, 'text': "There's a few divide by 0 issues we could have, but I'm not going to worry about that too much right now.", 'start': 1268.63, 'duration': 8.902}, {'end': 1283.174, 'text': "OK Another way instead of doing, I did just realize though, here's another thing I could do.", 'start': 1277.853, 'duration': 5.321}], 'summary': 'Normalizing fitness values between 0 and 1, with potential divide by 0 concerns.', 'duration': 31.63, 'max_score': 1251.544, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1251544.jpg'}], 'start': 939.755, 'title': 'Genetic algorithm implementation and mating pool', 'summary': 'Discusses implementing a genetic algorithm to create a new population of rockets based on fitness, focusing on distance and launching 200 rockets every 200 frames, along with creating a mating pool for selecting parents based on fitness values and normalizing them for passing genetic information to the next generation.', 'chapters': [{'end': 1139.141, 'start': 939.755, 'title': 'Genetic algorithm implementation', 'summary': 'Discusses implementing a genetic algorithm by creating a new population of rockets based on their fitness, with a focus on calculating fitness based on distance and launching 200 rockets every 200 frames.', 'duration': 199.386, 'highlights': ['Creating a new population of rockets based on their fitness The author discusses the intention to create a new population of rockets from the previous population based on their fitness.', "Launching 200 rockets every 200 frames The chapter highlights the system's functionality of launching 200 rockets into space every 200 frames.", 'Calculating fitness based on distance The chapter emphasizes the calculation of fitness based on the distance a rocket makes it to the target, with a fitness formula of 1 divided by distance.']}, {'end': 1322.626, 'start': 1139.161, 'title': 'Genetic algorithm mating pool', 'summary': 'Discusses the process of creating a mating pool for selecting parents based on their fitness values and normalizing them to ensure a higher chance of passing genetic information to the next generation of rockets.', 'duration': 183.465, 'highlights': ['The process involves calculating the fitness of rockets and then normalizing their fitness values by dividing them by the maximum fitness, ensuring that all fitness values are between 0 and 1.', 'The higher the fitness of a rocket, the higher the chance of it being selected as a parent to pass genetic information to the next generation of rockets, contributing to the creation of a mating pool for the genetic algorithm.', 'An alternative approach is considered, involving mapping the distance of rockets to a value between the width of the window and inverting that value, potentially eliminating the need for normalization.', 'The chapter emphasizes the importance of finding the maximum fitness among all elements to facilitate the selection of parents for the next generation of rockets.']}], 'duration': 382.871, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g939755.jpg', 'highlights': ['Creating a new population of rockets based on their fitness', 'Launching 200 rockets every 200 frames', 'Calculating fitness based on distance', 'The process involves calculating the fitness of rockets and then normalizing their fitness values by dividing them by the maximum fitness', 'The higher the fitness of a rocket, the higher the chance of it being selected as a parent to pass genetic information to the next generation of rockets', 'The chapter emphasizes the importance of finding the maximum fitness among all elements to facilitate the selection of parents for the next generation of rockets']}, {'end': 1948.71, 'segs': [{'end': 1383.248, 'src': 'embed', 'start': 1356.735, 'weight': 0, 'content': [{'end': 1363.344, 'text': "i. so the idea behind this bit of code right here that you've seen already if you watch my other genetic algorithms videos,", 'start': 1356.735, 'duration': 6.609}, {'end': 1371.822, 'text': "is that what I'm doing is I'm saying basically Take the rocket's fitness, which is between 0 and 1..", 'start': 1363.344, 'duration': 8.478}, {'end': 1373.463, 'text': 'And then multiply it by 100.', 'start': 1371.822, 'duration': 1.641}, {'end': 1378.285, 'text': 'So I now have fitness values between 0 and 100.', 'start': 1373.463, 'duration': 4.822}, {'end': 1383.248, 'text': 'A rocket with a value of 100, a fitness of 100, should be in the mating pool 100 times.', 'start': 1378.285, 'duration': 4.963}], 'summary': 'Adjusts rocket fitness values to a range of 0-100 for mating pool selection.', 'duration': 26.513, 'max_score': 1356.735, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1356735.jpg'}, {'end': 1612.939, 'src': 'embed', 'start': 1579.523, 'weight': 1, 'content': [{'end': 1592.027, 'text': "But what I want to do is, I want to say if i is greater than 0, I want the new DNA to come from this, this object's genes otherwise.", 'start': 1579.523, 'duration': 12.504}, {'end': 1601.333, 'text': "and I want, if i is greater than the midpoint, and otherwise, I want the new DNA to come from the partner's genes.", 'start': 1592.027, 'duration': 9.306}, {'end': 1607.576, 'text': 'And then I want to return new DNA.', 'start': 1604.974, 'duration': 2.602}, {'end': 1611.218, 'text': "So what I'm doing here is I now have written a crossover function.", 'start': 1608.416, 'duration': 2.802}, {'end': 1612.939, 'text': 'This is going to be a long video.', 'start': 1611.238, 'duration': 1.701}], 'summary': 'The transcript discusses creating a crossover function based on conditions for dna selection.', 'duration': 33.416, 'max_score': 1579.523, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1579523.jpg'}, {'end': 1811.665, 'src': 'heatmap', 'start': 1755.152, 'weight': 1, 'content': [{'end': 1767.749, 'text': 'In the population object, which is, I guess, closer to the top here, where I have selection, I now have, this is child DNA.', 'start': 1755.152, 'duration': 12.597}, {'end': 1771.432, 'text': 'Now what I need to do, and I want to do this how many times?', 'start': 1768.289, 'duration': 3.143}, {'end': 1788.025, 'text': "I want to do this first I want to say new population is an array, and then I want to loop through and I'm going to say new rockets, new rockets,", 'start': 1773.113, 'duration': 14.912}, {'end': 1804.32, 'text': 'and I want to loop through the existing rockets And I want to do this for every single existing, and this should say this.rockets.', 'start': 1788.025, 'duration': 16.295}, {'end': 1811.665, 'text': 'So now what I want to say is new rockets index i equals a new rocket with that child DNA.', 'start': 1804.84, 'duration': 6.825}], 'summary': 'Creating new rockets with child dna for each existing rocket.', 'duration': 56.513, 'max_score': 1755.152, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1755152.jpg'}, {'end': 1844.851, 'src': 'embed', 'start': 1814.606, 'weight': 3, 'content': [{'end': 1818.351, 'text': 'I want to have parent A pick a DNA from one parent.', 'start': 1814.606, 'duration': 3.745}, {'end': 1820.955, 'text': 'Parent B pick a DNA from another parent.', 'start': 1818.632, 'duration': 2.323}, {'end': 1825.14, 'text': 'Cross over those two DNAs and make a new rocket with that DNA.', 'start': 1821.275, 'duration': 3.865}, {'end': 1827.223, 'text': 'Now does my rocket?', 'start': 1825.501, 'duration': 1.722}, {'end': 1830.745, 'text': 'where is the rocket object?', 'start': 1828.484, 'duration': 2.261}, {'end': 1832.606, 'text': 'scrolling like crazy once again.', 'start': 1830.745, 'duration': 1.861}, {'end': 1835.347, 'text': 'now the rocket object should have an optional argument.', 'start': 1832.606, 'duration': 2.741}, {'end': 1838.909, 'text': 'the rocket constructor should have an optional argument called DNA.', 'start': 1835.347, 'duration': 3.562}, {'end': 1844.851, 'text': 'so I could say if it receives DNA, then this dot DNA equals that DNA.', 'start': 1838.909, 'duration': 5.942}], 'summary': 'Create a new rocket by crossing dnas from parent a and parent b, with an optional dna argument for the rocket constructor.', 'duration': 30.245, 'max_score': 1814.606, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1814606.jpg'}], 'start': 1323.646, 'title': 'Genetic algorithm in rocket simulation', 'summary': 'Discusses calculating rocket fitness, selecting parents, and performing crossover, ensuring higher fitness rockets are prioritized. it also involves utilizing p5 features and defining a crossover function.', 'chapters': [{'end': 1401.807, 'start': 1323.646, 'title': 'Genetic algorithm fitness calculation', 'summary': 'Discusses the process of calculating the fitness of rockets, multiplying it by 100, and adding the rockets to the mating pool based on their fitness values, ensuring higher fitness rockets have a higher likelihood of being selected.', 'duration': 78.161, 'highlights': ["The process involves multiplying the rocket's fitness by 100 to obtain fitness values between 0 and 100, where a rocket with a fitness of 100 is added to the mating pool 100 times, and a rocket with a fitness value of 3 is added 3 times, ensuring higher fitness rockets have a higher likelihood of being selected.", 'The code loops through the rockets to calculate their fitness, multiplies it by 100, and adds the rockets to the mating pool based on their fitness values.']}, {'end': 1948.71, 'start': 1402.367, 'title': 'Genetic algorithm in p5: selecting parents and performing crossover', 'summary': 'Outlines the process of selecting two parents and performing crossover to create a new dna object for a rocket, utilizing features of p5 like the random function and array manipulation. a crossover function is also defined to mix genes from two parents and create new dna.', 'duration': 546.343, 'highlights': ['The process of selecting two parents and performing crossover is explained, utilizing features of p5 like the random function and array manipulation.', 'A crossover function is defined to mix genes from two parents and create new DNA, with a midpoint being selected randomly to divide the genes.', 'The concept of creating a DNA object from genes, either by receiving genes or generating random DNA, is detailed, including adjustments in the constructor function and error corrections in the code.', 'The steps for creating a new rocket with the child DNA obtained from the crossover process are outlined, along with incorporating the optional argument of DNA in the rocket constructor.', 'The process of updating the population with the new rockets and making adjustments in the main program is discussed, along with identifying and correcting errors in the code.']}], 'duration': 625.064, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1323646.jpg', 'highlights': ["The process involves multiplying the rocket's fitness by 100 to obtain fitness values between 0 and 100, ensuring higher fitness rockets have a higher likelihood of being selected.", 'A crossover function is defined to mix genes from two parents and create new DNA, with a midpoint being selected randomly to divide the genes.', 'The code loops through the rockets to calculate their fitness, multiplies it by 100, and adds the rockets to the mating pool based on their fitness values.', 'The steps for creating a new rocket with the child DNA obtained from the crossover process are outlined, along with incorporating the optional argument of DNA in the rocket constructor.']}, {'end': 2381.044, 'segs': [{'end': 1998.039, 'src': 'embed', 'start': 1970.979, 'weight': 0, 'content': [{'end': 1974.121, 'text': 'No, new rockets is an array that I want to assign to the current rockets.', 'start': 1970.979, 'duration': 3.142}, {'end': 1975.402, 'text': "So I'm going to do that.", 'start': 1974.541, 'duration': 0.861}, {'end': 1978.124, 'text': "And let's see if we get now it running again.", 'start': 1975.682, 'duration': 2.442}, {'end': 1981.319, 'text': "OK, so it looks like we're getting a new generation.", 'start': 1979.276, 'duration': 2.043}, {'end': 1981.859, 'text': 'Look at that.', 'start': 1981.359, 'duration': 0.5}, {'end': 1987.947, 'text': 'You can see how even just that second generation, the rockets are now kind of pointing more straight up.', 'start': 1982.06, 'duration': 5.887}, {'end': 1991.291, 'text': 'So the ones that have kind of made it.', 'start': 1988.267, 'duration': 3.024}, {'end': 1993.093, 'text': "Now, there's a bunch of issues with this.", 'start': 1991.331, 'duration': 1.762}, {'end': 1994.174, 'text': 'Number one.', 'start': 1993.473, 'duration': 0.701}, {'end': 1998.039, 'text': 'I need to sort of figure out how do I know if the genetic algorithm is working?', 'start': 1994.174, 'duration': 3.865}], 'summary': 'Testing new rockets generates second generation with improved direction.', 'duration': 27.06, 'max_score': 1970.979, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1970979.jpg'}, {'end': 2166.584, 'src': 'embed', 'start': 2131.927, 'weight': 3, 'content': [{'end': 2135.489, 'text': "they're done, they've achieved their goal and they should get like a super high fitness.", 'start': 2131.927, 'duration': 3.562}, {'end': 2144.514, 'text': "so one of the things I'm going to do in the rocket itself is I am going to look for the rocket and in I guess what.", 'start': 2135.489, 'duration': 9.025}, {'end': 2145.094, 'text': "I'll just do this.", 'start': 2144.514, 'duration': 0.58}, {'end': 2156.079, 'text': "in the update function I'm going to check the distance between this particular rockets position and the target's position.", 'start': 2145.094, 'duration': 10.985}, {'end': 2166.584, 'text': "Ooh And if that distance is less than like, I'm just going to say if it's less than like 10 pixels, then it's reached the target.", 'start': 2156.099, 'duration': 10.485}], 'summary': 'Rocket achieved goal of reaching target with high fitness.', 'duration': 34.657, 'max_score': 2131.927, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2131927.jpg'}, {'end': 2327.282, 'src': 'embed', 'start': 2299.243, 'weight': 4, 'content': [{'end': 2311.951, 'text': 'So I could just write a simple function that just loops through all of their genes again, and what it does is it just picks a random number,', 'start': 2299.243, 'duration': 12.708}, {'end': 2316.975, 'text': "and let's just have a mutation rate of 1%, meaning if I pick a random number less than.", 'start': 2311.951, 'duration': 5.024}, {'end': 2327.282, 'text': '01. what I want is for that particular gene to just become a new random vector.', 'start': 2316.975, 'duration': 10.307}], 'summary': 'Function loops through genes, mutates at 1% rate.', 'duration': 28.039, 'max_score': 2299.243, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2299243.jpg'}], 'start': 1948.91, 'title': 'Genetic algorithm for rocket evolution', 'summary': 'Discusses implementing a genetic algorithm in java and javascript to evolve a generation of rockets towards a target, highlighting process issues and observations. it also describes using genetic algorithm to evolve rockets towards a target, ensuring they achieve their goal and improve fitness function, ultimately leading to a more optimal path.', 'chapters': [{'end': 2029.77, 'start': 1948.91, 'title': 'Genetic algorithm in java and javascript', 'summary': 'Discusses implementing a genetic algorithm in java and javascript to evolve a generation of rockets towards a target, highlighting issues and observations with the process.', 'duration': 80.86, 'highlights': ['The rockets in the second generation are seen pointing more straight up, indicating progress in the genetic algorithm. Observation of rockets pointing more straight up in the second generation.', 'Over time, it appears that more rockets are starting to move towards the target, suggesting progress in the genetic algorithm. Observation of rockets moving towards the target over time.', 'Initial observation of rockets going off in random directions and eventually evolving towards vectors pointing straight up, indicating progress in the genetic algorithm. Observation of rockets evolving from random directions to pointing straight up.']}, {'end': 2381.044, 'start': 2029.77, 'title': 'Evolving rockets with genetic algorithm', 'summary': 'Describes the process of using genetic algorithm to evolve rockets towards a target, ensuring they achieve their goal and improve fitness function, ultimately leading to a more optimal path.', 'duration': 351.274, 'highlights': ['Implemented tracking of maximum fitness value and range of fitness values to monitor improvement The speaker creates a function to track the maximum fitness value and observes that the fitness values are reasonable and increasing from frame to frame, indicating progress.', "Modified rockets' behavior upon reaching the target to achieve super high fitness The speaker updates the rocket's behavior upon reaching the target by setting a condition to move it to the target and increase its fitness by a factor of 10, resulting in the evolution of a more optimal path.", 'Added mutation function to introduce variability in the genetic algorithm The speaker adds a mutation function with a 1% mutation rate to introduce variability in the genetic algorithm, allowing the rockets to evolve a more optimal path over time.']}], 'duration': 432.134, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g1948910.jpg', 'highlights': ['Observation of rockets evolving from random directions to pointing straight up.', 'Observation of rockets moving towards the target over time.', 'Observation of rockets in the second generation pointing more straight up.', "The speaker updates the rocket's behavior upon reaching the target to achieve super high fitness.", 'The speaker adds a mutation function with a 1% mutation rate to introduce variability in the genetic algorithm.']}, {'end': 2895.957, 'segs': [{'end': 2437.547, 'src': 'embed', 'start': 2381.044, 'weight': 1, 'content': [{'end': 2382.524, 'text': "now Here's something.", 'start': 2381.044, 'duration': 1.48}, {'end': 2390.867, 'text': "here's an exercise that you could think about adding to this The length of time it takes for the rocket to make it to the target.", 'start': 2382.524, 'duration': 8.343}, {'end': 2394.628, 'text': 'that could absolutely be a part of its fitness.', 'start': 2390.867, 'duration': 3.761}, {'end': 2402.71, 'text': 'right if it, if it makes it to the target faster, what is the current value of count when it makes the target?', 'start': 2394.628, 'duration': 8.082}, {'end': 2406.473, 'text': "that's something I could save, and the lower that count, the higher its fitness.", 'start': 2402.71, 'duration': 3.763}, {'end': 2409.055, 'text': 'so I might leave that as an exercise for you to add in.', 'start': 2406.473, 'duration': 2.582}, {'end': 2419.224, 'text': "but what I'm going to do right now is I am going to add just a quick obstacle, because I think that will be worth it to sort of see.", 'start': 2409.055, 'duration': 10.169}, {'end': 2424.418, 'text': "so let's make, let's make a rectangle in the window.", 'start': 2419.224, 'duration': 5.194}, {'end': 2434.745, 'text': "Whoops I'm going to draw a rectangle that's like start at x is 200, x is 200, y is 50.", 'start': 2425.198, 'duration': 9.547}, {'end': 2437.547, 'text': "It's going to be 200 pixels across and 10 pixels high.", 'start': 2434.745, 'duration': 2.802}], 'summary': "Suggests adding an exercise to measure rocket's time to target and introduces a quick obstacle in the code.", 'duration': 56.503, 'max_score': 2381.044, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2381044.jpg'}, {'end': 2517.538, 'src': 'embed', 'start': 2480.918, 'weight': 3, 'content': [{'end': 2488.886, 'text': 'So what I want to test in the rocket object and where is my rocket?', 'start': 2480.918, 'duration': 7.968}, {'end': 2492.392, 'text': 'Here it is what I want to check.', 'start': 2490.832, 'duration': 1.56}, {'end': 2494.673, 'text': 'here is in the update function, right?', 'start': 2492.392, 'duration': 2.281}, {'end': 2503.695, 'text': "This is checking hasn't reached the target, but let's also see if it knocks into that obstacle, if Pause dot X is great.", 'start': 2494.893, 'duration': 8.802}, {'end': 2517.538, 'text': 'Okay, this dot, pause dot X Is greater than that Rx value and this dot, Pause dot X is less than Rx plus Rw,', 'start': 2503.755, 'duration': 13.783}], 'summary': "Testing rocket object's position in update function.", 'duration': 36.62, 'max_score': 2480.918, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2480918.jpg'}, {'end': 2606.109, 'src': 'embed', 'start': 2582.114, 'weight': 0, 'content': [{'end': 2590.679, 'text': "But let's set it to 1, OK? So now we should see, let's see if these rockets over time evolve to go around the obstacle.", 'start': 2582.114, 'duration': 8.565}, {'end': 2598.507, 'text': "OK, so you can see now it's been running for a little bit, but they haven't really evolved to go around the obstacle yet.", 'start': 2592.566, 'duration': 5.941}, {'end': 2599.788, 'text': "So let's add a few things.", 'start': 2598.687, 'duration': 1.101}, {'end': 2602.528, 'text': 'Number one is they need a bit of a longer lifespan.', 'start': 2600.048, 'duration': 2.48}, {'end': 2606.109, 'text': "So I'm going to let them go for 400 cycles.", 'start': 2602.928, 'duration': 3.181}], 'summary': 'Rockets need longer lifespan of 400 cycles to evolve around obstacle', 'duration': 23.995, 'max_score': 2582.114, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2582114.jpg'}, {'end': 2731.501, 'src': 'embed', 'start': 2704.781, 'weight': 2, 'content': [{'end': 2708.065, 'text': "So I'm going to make that maximum force 0.2,, which I think.", 'start': 2704.781, 'duration': 3.284}, {'end': 2717.356, 'text': "And then I also, though, want to limit their velocity, which I think will be helpful, just to make it so they don't sort of spiral out of control.", 'start': 2708.065, 'duration': 9.291}, {'end': 2719.258, 'text': "I'm in the rocket object.", 'start': 2717.736, 'duration': 1.522}, {'end': 2720.559, 'text': "I'm going to.", 'start': 2719.618, 'duration': 0.941}, {'end': 2728.959, 'text': 'here say this dot velocity, dot limit, like to four.', 'start': 2722.975, 'duration': 5.984}, {'end': 2731.501, 'text': "and now that's a bunch of things that I've added.", 'start': 2728.959, 'duration': 2.542}], 'summary': 'Limiting maximum force to 0.2 and velocity to 4 for control.', 'duration': 26.72, 'max_score': 2704.781, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2704781.jpg'}, {'end': 2781.765, 'src': 'embed', 'start': 2753.758, 'weight': 5, 'content': [{'end': 2758.862, 'text': "So what I'm actually going to do is I'm just going to divide their fitness by 10 when they crash.", 'start': 2753.758, 'duration': 5.104}, {'end': 2762.525, 'text': 'And that way, we still have the fitness scaled, so to speak.', 'start': 2759.162, 'duration': 3.363}, {'end': 2771.661, 'text': "So Let's have this run for a little bit longer and see what happens.", 'start': 2765.408, 'duration': 6.253}, {'end': 2773.662, 'text': "I'm back.", 'start': 2773.182, 'duration': 0.48}, {'end': 2776.123, 'text': 'So these rockets have now successfully evolved.', 'start': 2773.982, 'duration': 2.141}, {'end': 2781.765, 'text': 'And you can see that one of them figured out how to get around this target and get around the obstacle and hit the target.', 'start': 2776.363, 'duration': 5.402}], 'summary': "Rockets' fitness divided by 10 on crash. one rocket evolved to hit target.", 'duration': 28.007, 'max_score': 2753.758, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2753758.jpg'}, {'end': 2888.769, 'src': 'embed', 'start': 2863.591, 'weight': 6, 'content': [{'end': 2872.936, 'text': 'looking at how a neural network or other types of machine learning algorithms might also be used to train agents to move around the screen with a certain path.', 'start': 2863.591, 'duration': 9.345}, {'end': 2874.898, 'text': 'so I hope you enjoyed this.', 'start': 2872.936, 'duration': 1.962}, {'end': 2877.899, 'text': 'rather, I think, insanely long and scattered.', 'start': 2874.898, 'duration': 3.001}, {'end': 2882.123, 'text': 'Scattered, a coding challenge.', 'start': 2879.7, 'duration': 2.423}, {'end': 2888.769, 'text': 'the code itself will be available on both github as well as a link to this Pen, this code pen that I created here.', 'start': 2882.123, 'duration': 6.646}], 'summary': 'Using machine learning to train agents for screen navigation. code available on github and codepen.', 'duration': 25.178, 'max_score': 2863.591, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2863591.jpg'}], 'start': 2381.044, 'title': 'Rocket evolution challenges', 'summary': 'Discusses overcoming obstacles in rocket evolution by adding crash conditions, adjusting force limits, and modifying fitness functions, resulting in improved obstacle navigation over 400 cycles.', 'chapters': [{'end': 2606.109, 'start': 2381.044, 'title': 'Rocket evolution with obstacles', 'summary': 'Discusses adding obstacles to a rocket simulation, setting fitness criteria based on time taken to reach the target, implementing obstacle detection, and adjusting rocket lifespan for evolution, aiming to improve obstacle navigation over 400 cycles.', 'duration': 225.065, 'highlights': ['Adjusting rocket lifespan for evolution The rockets are given a longer lifespan of 400 cycles to evolve and navigate around the obstacle.', "Implementing obstacle detection Obstacle detection is implemented in the update function to check if a rocket crashes into the obstacle, setting its 'crashed' variable to true.", "Setting fitness criteria based on time taken to reach the target The fitness of the rocket is based on the time taken to reach the target, with faster completion resulting in higher fitness and a lower 'crashed' count.", 'Adding obstacles to the rocket simulation An obstacle in the form of a rectangle is added to the window, introducing a challenging element for the rockets to navigate around.']}, {'end': 2895.957, 'start': 2606.509, 'title': 'Improving rocket evolution', 'summary': 'Discusses various improvements to the rocket evolution system, including adding crash conditions, adjusting maximum force and velocity limits, and modifying the fitness function to address crashing and optimize pathfinding, ultimately leading to successful evolution of the rockets.', 'duration': 289.448, 'highlights': ['Adjusting maximum force and velocity limits Changing the maximum force to 0.2 and limiting the velocity to four to improve rocket behavior and prevent spiraling out of control.', 'Addressing crashing and optimizing pathfinding Dividing the fitness by 10 when rockets crash, and considering adding a fitness function that rewards faster reaching of the target to optimize pathfinding.', 'Exploring neural networks and other machine learning algorithms for agent training Considering the use of neural networks or other machine learning algorithms to train agents for specific path navigation in future iterations.']}], 'duration': 514.913, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bGz7mv2vD6g/pics/bGz7mv2vD6g2381044.jpg', 'highlights': ['Adjusting rocket lifespan for evolution The rockets are given a longer lifespan of 400 cycles to evolve and navigate around the obstacle.', 'Adding obstacles to the rocket simulation An obstacle in the form of a rectangle is added to the window, introducing a challenging element for the rockets to navigate around.', 'Adjusting maximum force and velocity limits Changing the maximum force to 0.2 and limiting the velocity to four to improve rocket behavior and prevent spiraling out of control.', "Implementing obstacle detection Obstacle detection is implemented in the update function to check if a rocket crashes into the obstacle, setting its 'crashed' variable to true.", "Setting fitness criteria based on time taken to reach the target The fitness of the rocket is based on the time taken to reach the target, with faster completion resulting in higher fitness and a lower 'crashed' count.", 'Addressing crashing and optimizing pathfinding Dividing the fitness by 10 when rockets crash, and considering adding a fitness function that rewards faster reaching of the target to optimize pathfinding.', 'Exploring neural networks and other machine learning algorithms for agent training Considering the use of neural networks or other machine learning algorithms to train agents for specific path navigation in future iterations.']}], 'highlights': ['The Smart Rockets project, originally developed in Flash, is now being reprogrammed in JavaScript using the p5.js framework to showcase genetic algorithms in action with rockets launching to reach a target.', 'Smart rockets are controlled by virtual DNA, determining the number of thrusters, their direction, and firing sequence, facilitating efficient movement towards a target.', 'The project demonstrates genetic algorithms in the wild, functioning within an animation physics-based system.', 'The implementation involves creating a rocket object with built-in physics, a DNA object to control the physics with functions like mutation and crossover, and a population object to manage an array of rocket objects for evolution.', 'The smart rockets utilize genetic algorithms, and their evolution can be observed as they navigate obstacles to reach the top, demonstrating the effectiveness of the DNA-controlled movement.', 'The chapter discusses the creation of a population of rockets with an array of rockets and a population size of 100, along with assigning an initial random velocity to each rocket.', "The transcript addresses a bug related to a variable naming conflict, where the variable 'pop' overrides the p5 function named 'pop', impacting the code functionality.", 'Rockets programmed to move around the screen and reach a specific target Details the objective of the rockets to move around the screen and reach a specific target', 'The chapter explores the creation of a smart rockets simulation Describes the development of a simulation involving smart rockets', 'Launching 200 rockets every 200 frames', 'The process involves calculating the fitness of rockets and then normalizing their fitness values by dividing them by the maximum fitness', 'The higher the fitness of a rocket, the higher the chance of it being selected as a parent to pass genetic information to the next generation of rockets', "The process involves multiplying the rocket's fitness by 100 to obtain fitness values between 0 and 100, ensuring higher fitness rockets have a higher likelihood of being selected.", 'A crossover function is defined to mix genes from two parents and create new DNA, with a midpoint being selected randomly to divide the genes.', 'The code loops through the rockets to calculate their fitness, multiplies it by 100, and adds the rockets to the mating pool based on their fitness values.', 'The steps for creating a new rocket with the child DNA obtained from the crossover process are outlined, along with incorporating the optional argument of DNA in the rocket constructor.', 'Observation of rockets evolving from random directions to pointing straight up.', "The speaker updates the rocket's behavior upon reaching the target to achieve super high fitness.", 'The speaker adds a mutation function with a 1% mutation rate to introduce variability in the genetic algorithm.', 'Adjusting rocket lifespan for evolution The rockets are given a longer lifespan of 400 cycles to evolve and navigate around the obstacle.', 'Adding obstacles to the rocket simulation An obstacle in the form of a rectangle is added to the window, introducing a challenging element for the rockets to navigate around.', 'Adjusting maximum force and velocity limits Changing the maximum force to 0.2 and limiting the velocity to four to improve rocket behavior and prevent spiraling out of control.', "Implementing obstacle detection Obstacle detection is implemented in the update function to check if a rocket crashes into the obstacle, setting its 'crashed' variable to true.", "Setting fitness criteria based on time taken to reach the target The fitness of the rocket is based on the time taken to reach the target, with faster completion resulting in higher fitness and a lower 'crashed' count.", 'Addressing crashing and optimizing pathfinding Dividing the fitness by 10 when rockets crash, and considering adding a fitness function that rewards faster reaching of the target to optimize pathfinding.', 'Exploring neural networks and other machine learning algorithms for agent training Considering the use of neural networks or other machine learning algorithms to train agents for specific path navigation in future iterations.']}