How AIs learn part 2 || Coded example
Why Stack Overflow recommends it
Stack Overflow users link it as the tutorial they were following when they ported the smart dots genetic algorithm to Java or Python and then hit bugs with movement, mutation or selection.
Recommended by 0 people across 0 different months, 2018 to 2021.
What it is
Code Bullet walks through writing a genetic algorithm in Processing where a population of 'smart dots' evolves to reach a goal, covering the Brain, Dot and Population classes, selection and mutation. It is the coded follow-up to his earlier conceptual video on genetic algorithms and links the full source on GitHub.
What people said
Cites V. Red · 2018-05 · Stack Overflow · on “Dots moving primarily in one direction rather than randomly”
I am trying to write a Java version of Code Bullet's AI tutorial [this video] and while I've managed to build the JFrame and I get the dots to render properly, they are not behaving like expected. For context, when the population of dots are initialized, they are initialized with a "brain" that is a random list of 1000 directions that tell them how to move at each step. These directions are generated by the following code: //Further up they are initialized with 1000 as the argument //Also, an int array called directions is an attribute public Brain(int size){ directions = new int[size]; Random dir = new Random(); for (int i = 0; i < size; i++){ directions[i] = dir.nextInt(8); } } The reason 0 to
Cites Sparsh · 2018-09 · Stack Overflow · on “Python - Genetic Algorithm mutation function is not working”
I created an AI in python/pygame but even after spending hours of debugging, I could not find why the individuals(dots) are not getting mutated. After few generations, all the individuals just overlap each other and follow the same exact path. But after mutation they should move a little bit differently. Here is what a population size of 10 looks like after every 2-3 generations.. Image 1 [LINK] Image 2 [LINK] Image 3 [LINK] As you can see, just after few generations they just overlap and all the individuals in the population move together, following exact same path! We need mutations!!! I would be really grateful to you if you could find any mistake. Thank! I saw the code from: [this video] and
Cites Sip_ · 2020-07 · Stack Overflow · on “Genetic algorithm for "smart dots" in python doesn't work”
For the past few days I've been trying to implement the so called "Smart dots" game. I first saw it on Code Bullet youtube channel: [this video] . Unfortunately it was coded in Processing language, while the only language I barely know is Python. I finished my python version of the game but some bugs have appeared. The problem is that on the second generation dots that are selected to be the best just stop moving almost instantly. I think that it has something to do with me being bad at OOP and copying the Brain class wrong. Steps(which i use for movement) Jump from zero(that is set at the beginning) to max value(200) at the first or second looping of the main loop. But the problems don't stop th
Cites HackLord monster · 2021-07 · Stack Overflow · on “What is the problem in this genetic algorithm?”
I recently started learning AI and i watched this [this video] video of Code Bullet, presenting a very simple genetic algorithm of a simple game where dots need to reach to a goal. I wanted to recreate this game in python using pygame . Since it didn't work at all, I tried redesigning it a bit. Here is the code: import pygame as pg from DotGame.DotGameFunctions import * import random as r import time pg.init() WIN_WIDTH = 500 WIN_HEIGHT = 500 win = pg.display.set_mode((WIN_WIDTH, WIN_HEIGHT)) pg.display.set_caption('DotGame') SPAWN = Vector2(WIN_WIDTH / 2, WIN_HEIGHT - 40) GOAL = Vector2(WIN_WIDTH / 2, 10) class Dot: def __init__(self, pos: Vector2): self.pos = pos self.dead = False self.reachedG