frpays / lc0-js Goto Github PK
View Code? Open in Web Editor NEWThe LC0 engine ported to javascript with Emscripten.
License: GNU General Public License v3.0
The LC0 engine ported to javascript with Emscripten.
License: GNU General Public License v3.0
Hi there,
I'm trying to use lc0_js asynchronously, one idea to do so would be a constunct like the following:
class Lc0 {
constructor(){
//the functions from your library
CreateLC0Worker()
.then(this.initEngine.bind(this))
.catch(this.showError.bind(this));
}
initEngine(worker) {
this.worker = worker;
this.worker.onmessage = null;
this.worker.onerror = this.engineError.bind(this);
this.worker.postMessage('load ' + this.weightsUrl);
}
computeMove() {
this.worker.onmessage = e => {
return new Promise((resolve,reject) => {
/* ... */
if (Array.isArray(message)) {...}
else {
var match = message.split(" ");
if (match.includes("bestmove")) {
alert("bestmove found");
resolve();
}
}
});
};
}
async goDepth(d){
let s = this.computeMove();
this.send(`go depth ${d}`);
await s;
alert("Promise resolved");
}
}
Remark that it works just fine for engines like stockfish.
There are other ways to make this asynchronous, but the idea is always to resolve a promise on "bestmove".
Probably it has to do with your implementation of the worker (also it is less than optimal that the console is blocked...).
Do you have an idea where the problem could originate from? Or do you have a better idea on how to expose the worker to an asynchronous function?
Best regards,
Patrick
P.S.: Thanks for putting this awesome project out there, I like it a lot ๐ฏ
hi,
thank you for this great analysis tool
the only issue is it doesn't recognize new lc0 networks ( tried more than 10 no luck)
Could you please fix this issue
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.