Skip to content

manassarpatwar/WatchCarsLearn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WatchCarsLearn

watchcarslearn

Watch cars learn right in your browser! https://manassarpatwar.github.io/WatchCarsLearn/

The Car

car

  • Each car has 5 distance sensors which serve as inputs to its brain (neural network)
  • Each sensor has a max length and the input passed to the network is a normalized value of the sensor input (length/maxLength)
  • The brain of the car outputs 2 values, both between 0 and 1
  • The first value controls the throttle and brake of the car. If the value is greater than 0.66, the car accelerates else if it is less than 0.33, it brakes.
  • The second value controls the steering of the car. If the value is greater than 0.66, the car steers right, else if it is less than 0.33, it steers left.
  • The physics of the car is inspired by spacejack's implementation of Marco Monster's Car Physics for games paper

The Track

track

Procedural Track Generation

Beziers, Beziers, Beziers!

  • I used bezier.js for working with beziers
  • The track is made up of a lot of bezier curves
  • There exists a hidden path of bezier curves that runs through the middle of the track. I use this path to calculate score of each car, and check whether the car is on the track or it has crashed
  • The input sensor length is measured on every physics step. It is measured by calculating the intersection point between the sensor line and a nearest bezier curve

Editing and randomizing

  • The track is completely editable and randomizable on the fly
  • The simulation is paused while the user is editing otherwise the window will freeze up
  • To Edit, simply click on the pencil icon and drag any of the control points

Neural Network

network

Activation

  • The network is a feed forward neural network and stops any recurrent connections from being mutated
  • The network is activated using a list of nodes sorted topologically(Kahn's algorithm)

Nodes

  • Brightness of each node is the output of that node when activated

Connections

  • Connections which are green have a positive weight
  • Connections which are blue have a negative weight
  • Connections which are red are disabled

Neuro Evolution of Augmenting Topologies (NEAT)

Icons

All icons were created in p5.js web editor by me

Pencil

pencil_black
p5.js editor sketch for pencil

Randomize

random_black
p5.js editor sketch for randomize

Steering wheel

steering_black
p5.js editor sketch for steering wheel

License

MIT
Copyright (c) 2020-present Manas Sarpatwar