Evolving Neural Network Race Cars!

Hey BGE users! I’ve been sitting on this project for awhile now so I thought, it’s time to share one of the earlier but more functional versions of my neural network racing car demo for people to play around with.

The few people i’ve shown it to think its pretty neat, so I hope many of you can find this thing fun to watch or maybe even play with into your own project!

At a later date, I’ll be starting a new youtube Channel with tutorials on the more recent version, includes physics based cars instead of placeholder blocks, more efficient neural network, simpler controller script, better coding in general. I have some ragdoll neural network projects as well as procedural level building projects all of which are at various stages of completion as well as plenty of other AI related projects people may find useful.

Feel free to discuss, mess with the code, ask me anything really :slight_smile:

Instructions: download the .blend and top.car file into the same directory. The 'L’oad/'S’ave is pretty lame, I just threw it together in case anyone wanted to see a more trained example. If you save first, the file will be overwritten with whatever is best current car.

Vanilla_BGE_NN_racer.V0.1.6.demo_version.blend (296.7 KB)
top.car (2.4 KB)

edit: This is for vanilla blender 2.79b, compatible UPBGE versions have an unresolved physics memory leak issue that make this simulation quickly use up available ram.

4 Likes

another guy is working on the same subject.

Maybe make little videos ? Few people will test your .blend if they don’t have a video first :wink:

Yes there is he is helping me to create AI

Both are car related but both are completely different approaches to AI. I should know, they’re both written by me. I only spent < hour on a simpler example for the other other guys project and a couple weeks on various parts on this one.

I even made you a little video of the trained car I included above.

2 Likes

Great work Sam!

1 Like

Hey Jacob, thanks for the feedback!

1 Like

i wish there were more projects like this for the bge.

1 Like

Im happy you enjoyed it. Theres many more projects like this incoming, I don’t have an ETA on my first tutorial, but think, physics based cars (instead of block shaped cars of this demo) prettier maps, cleaner code etc. Even with this clunky older code, its more than possible to use it for other kinds of AI’s, in fact, I made it for hunter/seeker enemy units originally that would learn the players play style but people really seem to prefer when its used for driving cars :smiley:

If anyone wants to play around with the code to understand and/or offer better solutions id love to hear about it. I did comment quite a lot of the code so hopefully it’s not too tough to understand.

do you know about neuroevolution?

Neuro evolution of topologies (NEAT) ? Yes, I experimented with PyroEvils BGE implementation and recently I learned to use the NEAT module in python and a week or two ago I figured out how to install the NEAT module in blender. I’m planning to get around to testing it out in the BGE soon. It shouldn’t be difficult to swap with my implementation but I don’t think performance was as good as numpy feed forward networks.

Very interesting project! :clap:

To me, this is exactly the type of awesome engineering/computer science experiments, which the BGE encouraged to build due to it’s quite low barrier of entry.

I tried to run it (Windows, BGE 2.79b), but my Python complains, that numpy doesn’t have the attribute random. My assumption is that you built the code on Linux, where another Python install was present.

Could you confirm? Has someone else tried to run it successfully?

1 Like

Thanks for the feedback, its built in linux but using blenders packaged numpy module, so that error is a little disconcerting.

@socoto what OS were you and your friend using?

I’ll definitely have a look into it, Ive purposely been using only whats available by default with blender to maximize who can run it.

Hey man, I use windows 7 and it works perfectly, and a lot of other people I shared work with windows 7 too


maybe you made some changes to the blender.
I always use it by default from the beginning.

2 Likes

try checking also in UPBGE.


print a console image

1 Like

i would love to see a video of it.

Thankyou for reporting that it works for you and your friends in windows!

Even if it runs in UPBGE, there is a physics implementation bug in UPBGE that causes a serious memory leak so you should avoid running it in UPBGE.

The NEAT stuff? Heres a playlist of his videos: https://www.youtube.com/playlist?list=PLfFwRwf-R6BpHlLyDHV2Wqaw4SjOrV0sB I haven’t made any NEAT videos yet but check back, I’ll be sure to drop videos of that kind of stuff in the future.

1 Like

Could you please run this .blend and paste the output as well as original error? That’ll help me narrow down the problem, hopefully we can resolve it.

versions.blend (584.1 KB)

this is my output:

Blender version: 2.79 (sub 0)
Python version: 3.5.3
Numpy version: 1.10.1
1 Like

Shame on me.

It as actually the other way around. My Python install was modified - I have messed with it in the last months and my install was not vanilla BGE (2.79b) any more. I didn’t investigate what was wrong, but running your files with fresh copy of BGE from first post now works.

This is what I see:

Thanks for sharing!

Edit: I am just wondering, why you limit the execution by VSYNC and use Frame Rate. I turned off these two and set the FPS of Bullet to some large number…

grafik

…and my PC starts running your sim 10x faster :slight_smile:

I am not sure though if this affects your algorithm though.

PS: I just found out that you can embed videos on blenderartists directly, as long as they don’t exceed 5 MB or so.

2 Likes

Great! Glad to hear the problem was resolved :slight_smile:

I don’t generally mess around with the fps/vsync stuff but its a good idea. @socoto showed me how to do that a few days ago. You can also increase the number of cars from 20 to something like 70-90. I lowered the number to help performance for people with slower machines than mine.

2 Likes

I do not recommend you to move here, in this part as changes occur differently!
NOT

1 Like