Closed ghost closed 8 years ago
Hi! Until we have a patch, let's call this an issue. :-)
I'm glad you like Pachi! Running it in Javascript could be fun, though Pachi probably will not be very strong, especially single threaded. (By the way, take a look at Michi if you would like to think about implementing a Go program in Javascript from scratch.)
What you seek to do should not be very difficult, though it's not totally trivial either. I'm just not sure how to do it in a way that would be mergeable back to the main codebase.
First, take a look at the comment "Pachi threading structure:" in uct/search.c. Basically, you will want to just run a single worker (uct_playouts()) in uct_search() instead of the whole threads machinery, and modify the uct_playouts() to call uct_search_check_stop() time by time (not on every iteration, it's not entirely cheap check). Shouldn't be too hard.
(Or if you'd like to avoid touching uct_playouts(), you could do something crazy like set up a timer with timer_start() which will call the uct_search_check_stop() periodically. That might make this easier to merge back. But I don't know if that can be handled by emscripten, and if it won't end up being too horrid (or way too slow in emscripten) anyway.)
Good luck!
Pachi is working on Node! (without threads of course ^^). Strangely though, I couldn't get Pachi to work on the web environment yet. There is a problem when allocating a board struct:
Uncaught abort("Assertion failed: undefined") at Error
at _board_copy (file:///D:/pachi/pachi.js:8470:8)
I will keep on trying to fix this, any comment is welcome ^^.
Thanks for all the time and help,
Update: Pachi is working on web environment too!, Yay!, I love Pachi :D.
Thanks for the guideline Pasky, you really told me how to do it :).
Glad that helped :)
Hello, not sure if this an issue or pull request, here I go: First, thanks for making this project open source, not only that, it is beautifully documented.
I am trying to run pachi in a javascript environment using emscripten. Compilation is OK, but thread related functions are not defined.
If I understand correctly, the only workaround is modifying the source code and avoid threads.
I would like to invest my time on this; do you think is possible?, do you have any recommendation?.
Thanks and again; awesome project!.