A UCI Javascript chess engine.
Lozza was primarily created for use in browsers, but can also be used with traditional chess user interfaces (see below).
All you need is lozza.js from the latest release (not the repo).
Here is a little example to do a 10 ply search:-
var lozza = new Worker('lozza.js');
lozza.onmessage = function (e) {
$('#dump').append(e.data); // assuming jquery and a div called #dump
// parse messages from here as required
};
lozza.postMessage('uci'); // lozza uses the uci communication protocol
lozza.postMessage('ucinewgame'); // reset tt
lozza.postMessage('position startpos');
lozza.postMessage('go depth 10'); // 10 ply searchTry this example here:-
Note that Lozza must be fired up in a web worker.
A sister repo has more browser-based examples for playing and analysing with Lozza.
The most straightfoward way is to use one of the binaries from the latest release.
Alternatively install Node or Bun and use lozza.js via a batch file; for example:
"c:\program files\nodejs\node.exe" "c:\path\to\lozza.js"
option name Hash type spin default 16 min 1 max 1024
option name MultiPV type spin default 1 min 1 max 500
Again, use one of the binaries from the latest release or for example:-
node lozza.js
Commands can be given as arguments:-
node lozza.js uci ucinewgame "position startpos" "go depth 10" quit
./lozza-win-x64.exe ucinewgame "position startpos" board quit
There is also an online console:-
- quit - close Lozza.
- board - display the board for the current position.
- moves - display the moves for the current position.
- eval - display the evaluation for the current position.
- net - display network attributes.
- bench - run a sequence of searches returning the toal node count and nps.
- perft depth - run a perft search from the current position using depth .
- pt - run a sequence of perft searches.
- et - run a sequence of evaluations.
If you clone the repo with the intention of tweaking Lozza or you want to load the weights from quantised.bin, you need to be aware of the build process in build.sh. This is a script that creates ./lozza.js from src/*.js (contingent on quantised.bin) and ./releases/lozza.js which has the weights from quantised.bin inlined into it. It also creates binaries in ./releases but you can remove that section. The version that reads quantised.bin (./lozza.js) is what I use for development and is what is in the root of the repo. The version in ./releases is what I ship. build.sh will run natively on Linux and macOS but will need to run in WSL or git bash etc on Windows.
- https://nodejs.org - Node
- https://www.chessprogramming.org/Main_Page - Chess programming wiki
- https://computerchess.org.uk/ccrl/4040 - CCRL rating list
- https://backscattering.de/chess/uci - UCI protocol
- https://talkchess.com - Talkchess forums
- https://www.chessprogramming.org/Fruit - Early versions of Lozza used a HCE based on Fruit 2.1