How do I make my first A.I?

I have read Kironte’s neural networks documentation, but I seems to not understand most of them.

I have watched many videos about neural networks but I don’t get it at all
My problem is I don’t know how to make an actual working A.I

Like I got the module, but I don’t know how can I apply it for my A.I

Like how do I make my NPC move using it. I would like an example model of it instead of calculating, I’m 13 and tbh, I don’t know much maths so the entire 2 code examples just confused me up.

Please, I have tried my best, I’m not going to steal a working model, but I just want to know how would u make it and how will it work?

Thanks you for reading!

Credits:
Documentation: Neural Network Library (Obsolete)
ANNs Library: https://www.roblox.com/library/4484194943/Neural-Network-Library-V1-04
And the creator: @Kironte

1 Like

Neural networks are quite advanced and math heavy, I suggest starting out with something more simple such as an npc that uses pathfinding service, and work your way up in the difficulty.

As stated, nueral networks are advanced stuff and you should work your way up to understand them, even to day not even the most advanced of scripters find them easy so don’t jump ahead.

Although the library does all of the complicated math for you, its still a good idea to understand how it works at least on the surface level.
NNs require knowledge in algebra on the surface level, along with vector-math and calculus on the deep level.
The library has an explanation over how the node system in perceptron NNs works. If you don’t understand, try to ignore the hidden nodes and only look at the input and output nodes; they are self explanatory. The input nodes ask for a specific order of information, while the output gives you a specific order of information as a result. If you have an addition NN for whatever reason and it has 2 inputs and 1 output, if the inputs are 1 and 2 (scaled properly of course), you will get 3 on that single output (scaled). Its as simple as that.
For the learning methods, they are pretty simple. Backpropagation just uses the given inputs and correct answer associated with them to adjust the NN so it is closer to achieving that answer as well. If you think that inputs 1 and 2 should give you 4, but you are told that they actually should give you 3, you will use this information to correct yourself in the future.
Genetic learning is far simpler on the inside, but if you struggle with NNs, its better to stick to backpropagation for now.

As an example NN, lets think about a self aiming car that avoids obstacles.
For inputs, you will want to add 5 directional sensors for the car. Spread out your hand; that is where the sensors will point. 1 forward, 1 left, 1 right, 1 left forward, and 1 right forward. Simply take a raycast of these directions from the car and give the distances outputted a reasonable maximum; 100 studs.
Scale all of these distances by dividing them by the maximum number: 100. NNs prefer number ranges from 0 to 1 most of the time.
For the number of hidden layers and hidden nodes, its a bit of a guess as there is no exact science for it, but generally you assign an amount based on the complexity of the task. I would give the NN 2 layers of 4-5 hidden nodes each.
For your output, you just need 1 node. This node will give you a number that will determine which direction to steer, left or right. If the number is close to 0, steer left. If the number is close to 1, steer right. The amount you steer by should depend on the number.

And thats the NN. For the learning process, you will have to learn how to use the genetic algorithm as backpropagation cannot be used for such live NNs. This should give you a better understanding as to how NNs work in concept. You should still investigate how the individual nodes work though.

8 Likes