Open albanm opened 9 years ago
For those looking for async support, I've forked this repo and rewrote it in TypeScript and added support for async fitness method (including unit tests): https://github.com/Glavin001/genetic-js Hope this helps you, too! 😃
This is actually some quite large modification. I am not sure you will be interested, but I think it is worth proposing.
First, I noticed that when running without web workers the page freezes, this is because everything is synchronous and genetic-js never releases the process. Making the fitness async with optional callback passing makes it possible to use at least a setTimeout. The page still lags of course, but it doesn't freeze.
Second, I needed to do some work with the DOM in my fitness function, but I still wanted to use web workers otherwise. So I used messages to simulate running functions in the worker that are actually in the caller context. It works well for me.