Articifial Neural Network (AI)

Hello,
i’m very interested in Neural Network, Deep Learning and all this kind of stuff, and i recently was asking myself if it was possible to make an Artificial Neural Network in Defold with “genetical renforcement” (which means it learn by himself by selecting the best specimen of each generation and reproducing it with some mutation). So i created my own, it’s just a car who need to finish a race the fastest possible without hiting any wall. The network use 5 input, it’s 5 ray_cast on the front and side of the car with a length of 750pxl who react to the wall and give back the message.fraction to the network. The network have 5 hidden layers’s neurons and 2 output (turn left or right).

Visual representation of my neural network :

What the “generator” look like :

If some of you want to try it, or to modify/use it, here it is :
https://ufile.io/1kzlg (the file can only be hosted for 30 days)
To start the “generator” once you’ve build it, just left click

The best neural network of the last generation is saved here :
C:\Users\ UserName \AppData\Roaming\AI_test

12 Likes

My first response is about ‘waow’ interesting, maybe i’ll try to learn it for my final project…
Thanks for share~

1 Like

It’s really not that hard once you’ve hunderstood how it work ! I never watched any tutorial or whatever and i don’t have any special skill, but i was able in less than 12 hours to create one simple all by myself !

4 Likes

is it a defold project or a library that you’re sharing?
maybe share it as an Asset Portal project so people have less friction trying it out?

4 Likes

Done !

11 Likes

this is soooo coool! So you just implemented a simple NN in lua, right? Did you look into Torch or other Lua-NNs? Or did you just want to have a little fun implementing your own simple NN?

Anyways, the demo is so fun, and I have so many practical questions immediately :wink: Hope others can base their in-game AI on your code with some tweaking.

1 Like

Yeah it’s fun to see the cars “evolving” and finding their path all by themself ! No i haven’t look into any other Lua-NN, i just wanted to try to make my own to see if it’s hard and to learn how to make one by myself. It’s a really simple one though. :smile:

I just started a new project with a bigger/better NN with “modulable” input and output, to make some kind of game in which you “create” a fighter (you add different module which are the Input or the Output of the NN) and then you can train him.

1 Like

that is cool. I feel if you share your code on github, you may get other Defold users contributing something. I know there’s an interest in NNs in Defold community, and many people discussed options multiple times.

1 Like

Yep i linked my asset page with GitHub, https://github.com/nathan68560/Genetical_Neural_Network.
If something don’t work tell me, i made some changes and maybe forgot to update it everywhere…

6 Likes