9.4: Genetic Algorithm: Looking at Code – The Nature of Code

[ad_1]
In part 4 of the series on Genetic Algorithm, I finally look at code! Using p5.js (and Processing / Java in the addendum), I implement the Shakespeare Monkey genetic algorithm example in JavaScript.

Support this channel on Patreon:

Send me your questions and coding challenges!:

Contact:

Links discussed in this video:
The Nature of Code:

Source Code for the Video Lessons:

p5.js:
Processing:

For More Genetic Algorithm videos:

For More Nature of Code videos:

Help us caption & translate this video!

Comments

27 responses to “9.4: Genetic Algorithm: Looking at Code – The Nature of Code”

  1. Dylan Park Avatar

    Thank you for your awesome vids. I got a question. in the process of picking two parents (a, b)16:40, you explained that we pick two of them based on their fitness which means the higher fitness rating they have, the more likely they might get picked. but I see that you pick two parents at total random, could you please explain why?

  2. kebman Avatar

    I'm still Norwegian since last time. No mutations. I'm trying to evove in to Swedish, though, but it's damn hard.

  3. Nils Herrmann Avatar

    Hey. I was just wondering if the mating pool generation will eventually become a problem if the fitness of your individual genes is very far apart from each other? Say for example, the fitness of A would be so much higher then the fitness of the rest of your elements that A should be picked with a probability of 90%. Then the resulting reproductions would in almost all cases lead to A crossing A, which of course would not change a thing (except in the event of a mutation). Would it be better in a general case to allow mating only once per element per generation?

    BTW: Very nice video series! I enjoyed it very much so far!

  4. CALEB OTIENO Avatar

    I like your delivery, very energetic.
    I would like to see it in Python too.

  5. Alex Apostolo Avatar

    Hey , I wanted to say that you have done a great job explaining the functionality of a genetic algorithm. I also tried making my own genetic algorithm, the only problem that i have encountered has been on small paragraphs that take many generations for the program to evolve the right phrases.

  6. Konstantin Dimitrov Avatar

    Is there any other way of picking a character (object) with a probability? Your approach is really interesting (really applause for that 🙂 ) I've never thought of doing it but can we do it say like a 2D array – 1 row for objects, row 2 for P(x)-s? Or give the random() some sort of bias? I really like your mating pool thing as it's just like real world way of how probabilities work the only drawback I recognize tho is the memory 'overkill' and that if it's 15,2% of chance you can't have it unless u go up to 1000 initialized examples and so on – again the memory draining thing.

  7. sahlool Avatar

    I can't find the source code

  8. Pri Kundnani Avatar

    The presentor is growing on me

  9. EtraStyle Avatar

    In what software do you make your presentations?

  10. Taeshawit Suwanwigo Avatar

    Man, you are the best. Really! All the afford you put in. The best tutorial on GA ever. Thank you!!

  11. An Solo Avatar

    Your the first person I found that teaches AI and shows the CODING aspect of what it is. For that, I promise you I am subscribed to you and turned on notifications. Keep up the good work!!

  12. Conner Campbell Avatar

    When i open index in chrome… It shows "Best phrase: Stats & All phrases:" Thats it.. any help??

  13. ibrahim laachichi Avatar

    salut j 'ai besoin d'un qui modéliser le minimum de la fonction x*x avec les algorithme genetique merci

  14. ASAT Avatar

    Man this can be implemented a lot easier using MATLAB

    Thank you very much, now I know what is Genetic Algorithm

  15. thisaintmyrealname1 Avatar

    Great series man! , I became a big fan of the way you teach stuff ever since I started reading your N.O.C. book. Keep up the good work! Greetings from Ecuador.

  16. UJJAYINI BOSE Avatar

    Hey , can you please write a code on web service composition using genetic algorithm! It would help a lot! Thanks!

  17. Infinitif Avatar

    funny that my algorithm needs 62322 generations in the same setup…

    But greate video, I came into genetic code just because of you 😀

  18. DerBossinPerson Avatar

    If you add the child immediately to the population doesn't that mean it can be the parent for the next child?

  19. NakZa Srithon Avatar

    This is really helpful video thank you 🙂

  20. NeverInterpreter Avatar

    Yay, finally something I can code myself 😀

  21. HAFEEZ ULLAH Jan Avatar

    hey sorry if i sound like a fool, but can i get the matlab code of the sample program?

  22. MibMoot Avatar

    Yes!

    The this dot song!

  23. cpaleop Avatar

    So, if you need 2 parents with a good amount of fitness, why don't you choose the best 2 fits? instead of placing all of them in an array and then "randomly" picking 2 of them?

  24. cpaleop Avatar

    Saying "4 out of 10 times will be an A" it's not true. The probability is that in 1 pick, I have 40% chance of picking "A".
    Many people confuse this.

  25. P-YAN Avatar

    If you don't start from scratch I think it would be good if you could also include the code from the starting point of the video instead of the finished one in your github so we can follow along. Thanks Dan, great stuff! Keep it up! 🙂

  26. toman222 Avatar

    Can someone explain the processing logo to me? Is it a p3? 13? pb?

Leave a Reply

Your email address will not be published. Required fields are marked *