Stockfish.js
github.com
github.com
[0] https://github.com/hi-ogawa/Stockfish
[1] https://lichess.org/analysis (in the top-right corner: "Stockfish 14+ NNUE in local browser")
(edit: fixed link to the correct fork)
EDIT: nevermind, looks like you changed the link.
I'm not sure why either, because a while back I could use how ever many threads I wanted on Firefox.
Chrome: 15 threads, 1 GB memory
Firefox: 1 thread, 256 MB
Brave: 2 threads, 128 MB
Firefox: 7 threads, 256 MB
Brave: 3 threads, 1 GB
There’s reference to thread support in the library documentation.
#include <stdint.h>
uint64_t multiply(uint64_t a, uint64_t b){
return a * b;
}https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
goto statements can and sometimes do have good use cases, for instance finite state machines and error handling.
It's not because something is generally not a recommended construct that you should never consider using it: in my opinion you should use all the tools you have in your belt and consider each use case separately to determine usefulness, practicality and other criteria applicable to your project.
Five occurrences of goto, for anyone that's curious. The code is pretty easy to read, good variable names, some explanatory comments. The gotos don't make spaghetti. I'm inclined to think the writers knew what they were doing, though goto offends my sensibilities as much as anyone.
Could anyone with more experience explain the pattern? Why gotos for control flow along with >thousand line functions?
Consider two alternatives (written in pseudo-Javascript, I guess):
let xyz = 0;
if (!condition1) {
doSomething();
xyz = getValueSomehow();
if (!condition2) {
doSomethingElse();
xyz += getSomeOtherValueSomehow();
}
}
finishUpBusinessLogic();
return xyz;
that seems much less readable than: let xyz = 0;
if (condition1)
goto done;
doSomething();
xyz = getValueSomehow();
if (condition2)
goto done;
doSomethingElse();
xyz += getSomeOtherValueSomehow();
done:
finishUpBusinessLogic();
return xyz;
0: https://github.com/nmrugg/stockfish.js/blob/d96c98872103c60b... def computeSomething() {
if (condition1) return 0;
let value = getValueSomehow();
if (condition2) return value;
doSomethingElse();
return value + getSomeOtherValue();
}
let value = computeSomething();
finishUpBusinessLogic();
return value;¹ https://github.com/nmrugg/stockfish.js/search?q=goto&type=
If it works for the devs, then it's fine. Chess engines have a fairly low attack surface, all you have is moving pieces. Security is probably fine. Performance and strength are clearly fine.