Summary

A personal research project for college. I wanted to dive into neural networks and see if it'd be viable for game development in this case.  I ended up with a neural network that can learn to race on different tracks.

Controls

Steering: Left & Right arrow

Acceleration: Up & Down arrow

R: Restart Scene

P: Go back to the main menu

9: Slowdown time (can bug the Neural Network when trained at a different speed)

0: Speed up time (can bug the Neural Network when trained at a different speed)

Idea

This is an open (research) assignment for college where I chose to study how to create a neural network from scratch to use in game development. I had about 3 weeks for this assignment.

I wanted to create an AI opponent which was based of the data of an evolutionary neural network. I'd run the network multiple times, write the data to CSV and import it when a player wants to play. The AI will always play as good as it can get, which is sometimes quite unfair as it can become nearly perfect at times. So I'd run it to perfection and then run it again while giving extra fitness for taking large turns, slowing down while turning and such.

This idea proved to be a bit too much to handle in such a short time-frame while having no prior experience with coding a neural network and training it, so I brought the scope down to just a working Racing Car that can complete 3 laps on the tracks I made. I made the player, normal bot and general race logic in the first week and a half. Leaving ample time to learn and work on the neural network, but it somehow came together when I asked a class mate to pair program it. Cas is the best vocal rubber duck.

Credits

UI & Race Pack Graphics by KennyNL

Additional Support: Cas Jansen

StatusIn development
CategoryOther
PlatformsHTML5
Rating
Rated 4.0 out of 5 stars
(2 total ratings)
AuthorTwinGhosts
GenreRacing
Made withUnity
Tagsartificial-intelligence, machine-learning, neural-network

Comments

Log in with itch.io to leave a comment.

Looks cool but a bit confusing: I don't know much of neural networks, but I thought they were based on iterations and trial and error.

Last time I've seen them (elsewhere), they tried to complete a level, died, tried again, died, tried again, etc.

Here I don't know what I'm seeing instead :D although I'm pretty sure someone who does know neural networks will understand it.

That being said, I have an unrelated small piece of advice: adjust the layers so that the player is on top, the bots below, and the yellow agents below the bots.

Hey thanks for leaving such a thorough comment, I really appreciate it!

It's a bit of a mess right now, but it was uploaded to serve as the technical result of a college assignment, that's probably why there's little to no time spent on design and user-friendliness... Sorry about that.

Each car has a neural network with a couple of sensors (6 wall sensors and 1 flow sensor, I will update the page with additional information about this asap). They have a fitness value based on how far they got and how fast. This is a bit different from the usual car racing along a track network as it has to abide by the same rules as the player and finish laps etc. Once all agents turned inactive (10/20 sec of no real progress) they reset and gain neural weights from the best agents of the previous generation and weight values from the overall best agents ever. A really small percentage stays randomized to possibly reset the agents when they have a major screw up near the start or to find a breakthrough with luck.

I'm planning on drawing the sensors of the networks to show a bit better what's going on, but life is quite busy at the moment, so this might take a while to be updated haha

The 'player' aspect of the game was just something that was left over from my first research question, which I changed later on. I just left it in, together with the generic AI. 

Thanks against for checking it out and pointing out some of the many flaws!