How do I use brain.js in PC without slowing the browser down massively?

Hi all,

I would like to use the brain.js AI library in our upcoming game. How do I go about this?

Raw Source:-

Please help, this is quite urgent!

Given it’s a full on deep learning framework, it’s going to be quite heavyweight.

Are you sure it’s the library that is causing the slow down?

If so, is the profiler giving any clues on which part of the library is causing the worse of it?

Are there any parameters of brain.js that you can change to reduce the load per frame (such as prediction length?) The timeout property looks like it could be a good first step.

I was just copy pasting the raw code into my file, and then typing my neural networking code. I need a way to reference it in my files. Copy pasting makes it much slower. Also, there were no hints via the profiler, just Firefox saying that the page was slowing down the browser.

Oh, you mean actually working on the code, not the runtime performance of the app.

Is brain.js in a separate file? And you are writing neural code in a different file?

Can you post a screenshot of the files and folders from the code editor please?

@yaustar I’m sorry, but I’m on my phone now. The brain.js file is the raw code I linked above. The coding file is a simple XOR neural network program.

I’ve hijacked a spare project and added brain.js without editor slow down:

Brain.js is in a separate file.
The Neural example that was on github readme is in the test.js

No problems with using the editor.

Also make sure that brain.js loads first:

Thanks a ton for this! I can finally finish the AI code in my game.