Open snowfrogdev opened 6 years ago
Maybe this helps. Here's a pretty simple example of a server and browser workers that receive a large list of numbers and return some back. https://github.com/wagenaartje/neataptic/tree/master/src/multithreading/workers
@flesler I've hit a bit of a wall when it comes to multithreading Macao and it has to do with the way Workers and Node child_processes work. The main problem I'm having is that Macao's algorithm requires the Macao user to supply functions that allow Macao to 'play' the game. For multithreading to work, I have to find a way to pass these functions from the main thread to other threads. The problem is that multithreading in JS does not share memory and is done thru serialized message passing and you can't serialize a function, ergo I can't pass the functions to other threads. I have yet to find a solution. Do you have any ideas?
Right, also the states are potentially large JSON objects, not just arrays of numbers or bytes that you can optimize for. It's a hard one now that I think of, seems like all the simulation code and Macao integration functions need to be in a worker module and Macao calls it. So the user needs to put their code in a separate module explicitly, it's a more complex API and requirements no doubt
http://www.sciweavers.org/read/evaluating-root-parallelization-in-go-325169