GithubHelp home page GithubHelp logo

knut0815 / selfdrivingcargeneticalgo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sophiewalden/selfdrivingcargeneticalgo

0.0 0.0 0.0 64 KB

2d car learns to drive through genetic algorithims

License: MIT License

Python 100.00%

selfdrivingcargeneticalgo's Introduction

selfDrivingCarGeneticAlgo

2d car learns to drive through genetic algorithims

MAKE SURE TO EXTRACT AFTER DOWNLOADING, that was my main problem when I tried to redownload this from github

Using my new and improved genetic algorithim that fixes a bunch of previous bugs, this one actually finds a solution evauntally. It runs a bit slow as doing 25 cars at once, with all the calculations might not be the best, but you can expirement with lower population it just takes longer to converge on the optimal solution.

1/21/20 Update: Improved speeds by 2-3 times which should mean you can try higher populations easier. 25 Population goes as fast as 10 Population pre-patch and I'm probably gonna optimize this more in the future

(The blue car is the best one from last generation)

THINGS TO MESS WITH IF YOU WANT TO:

Under game.py: self.show_bounds, set it to True if you want to see all car sights, the boundaries, and the gates which give fitness.

Under neuralNetwork.py: self.populationSize, how many cars you want.

Under neuralNetwork.py: self.alive_after_death, how many cars, ranked by highest fitness, to breed and create the next generation


Some basic explanation on how the model works:

Step 1: Make 25 random neural networks, with the model.nodes being the nodes in the network and model.connections having a connection between the node with each strength

Step 2: Run the models through the simulated game and see how far they get

Step 2.5: The neural networks during the game are taking in the data called their sights based on how far away each wall is from them on left, forward, and right sides, but also the two 45 degree angles in front of them and predict whether to turn or go forward.

Step 3: Sorts them by their score which is determined by how many invisible gates they go through, and then keeps the best ones for crossover

Step 4: Refill the population with either crossovers (Basically combining two neural networks to get a slightly tweaked, but similar child of the two) or duplications of already alive neural networks with a slight mutation.

Repeats step 2-4 as long as you want

selfdrivingcargeneticalgo's People

Contributors

sophiewalden avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.