Summary

https://github.com/lucasdino/AI-Driving

<aside> šŸš— I built a racing game and trained a neural network to drive a course and grab coins

</aside>

<aside> ā“ Motivation: 2-for-1 teaching myself reinforcement learning and larger coding projects (Python)

</aside>

S/o CodeBullet for giving me the idea for what to build in my first project. This was inspired by his video but improved upon by adding the ability to play multiple courses and have the AI generalize fairly well against courses it had not yet seen before. I think his memorized the map but not shamingā€¦this stuff is FINICKY.


šŸ“ŗCouple GIFs

Track the car was trained on - performs fairly well on this one!

Track the car was trained on - performs fairly well on this one!

Letā€™s make this a bit harderā€¦

Found this racetrack on Google Maps. A lot more windy than the othersā€¦this AI is lacking on the ā€˜Iā€™.

Found this racetrack on Google Maps. A lot more windy than the othersā€¦this AI is lacking on the ā€˜Iā€™.

Unseen track - slightly more difficult. Itā€™s not bad but a bit of a downgrade.

Unseen track - slightly more difficult. Itā€™s not bad but a bit of a downgrade.

Took a ton of different prompts to get a closed circuit top-down course from DALL-E 3 but itā€™s pretty groovy! At least I think it is. The AI doesnā€™t šŸ« 

Took a ton of different prompts to get a closed circuit top-down course from DALL-E 3 but itā€™s pretty groovy! At least I think it is. The AI doesnā€™t šŸ« 


Major Takeaways

  1. Coding: Relearned how to code larger projects after my 2-year banking hiatus. Iā€™m happy with how the code turned out though there are obvious improvements I could make.
  2. Reinforcement Learning: If I had a dollar for the number of times I wanted to throw my laptop out the window I wouldnā€™t hesitate to put guac on my burrito bowl at Chipotle. Learned a lot by having to build the physics and data pipeline from the ground up. More on that below.

Coding

Only thing worthy of sharing here - initially I was getting around 40 FPS on training runs.

Note ā€” all these measurements refer to when training my Neural Net (i.e., backprop is running and the model is updating). When my game starts and it hasnā€™t accumulated enough training data yet, I was clocking in over 200 FPS after all of these šŸ¤ 

Thatā€™s kind of slow. Like I needed this program to be Level 100 Pacer Test and it was just getting a passing grade.

So I stepped in an made a couple of improvementsā€¦

  1. Smart Collision / Vision Line Detection: (~40 FPS to ~80FPS)
  2. Concept of a Session: (~80 FPS to ~100FPS)
  3. Numpy / I actually now know linear algebra: (~100 FPS to ~120FPS)