How to Run Leela Chess Engine (LCZero) in Arena at a Specific ELO

Leela chess is an open fork of AlphaZero. Unfortunately, Google didn’t let us have the program, but they released a paper detailing how they did it , and Leela is the result. Since no single person has the resources of Google, this is a distributed project where Leela trains herself across hundreds of computers. We make up in numbers, what we lack in sheer power.

If you want to contribute your GPU to helping Leela chess get stronger, visit the project page and get started! You can also play an online version of Leela at her strongest current strength at http://play.lczero.org/.

However, the great thing about Leela is that you can also download the engine and play her at lower ELOs. This is a completely different compared to playing an engine like Stockfish at half strength. Modern chess engines will artificially lower their strength by blundering unnaturally and then play like a GM for the rest of the game. Leela’s games at lower ELOs are much more “human”, making her an excellent sparring partner!

In this tutorial, I’ll show you how to set up Leela on your local PC and plug her into a chess GUI like Arena.

Step 1: What you Need

Here’s what you need to have/know in preparation for Leela:

  1. The Arena chess program. Available here.
  2. You need to know what “rating” you want to play Leela at (more on this later)

Step 2: Determining your Rating

As Leela trains herself, she keeps increasing her rating – with a rating of “0” being random moves. Unfortunately, these self play ratings don’t translate directly into “human” ratings. As of this writing, Leela’s self plaly rating is 4343. But her ELO as understood by us is ~2000.

So to download a version of Leela that matches your ELO, use the following formula:

x = (y+511.7)/0.6

where:

x = Leela’s self play rating and
y = Your rating/the ELO you want to play Leela at

So for example, if I want to play a version of Leela at ELO 1500, her self calculated rating at that level will be:

(1500+511.7)/0.6 = 3352

Step 3: Download the Appropriate Network Weight

With the rating you obtained in Step 2, head over to Leela’s network weights page. This page contains the snapshots of Leela as she gets stronger. Each snapshot is represented by an ID. You can see her self play ELO in column 3. Scroll down till you find the ID that most closely corresponds to the self play ELO you calculated in step 2.

In this case, network ID 19 has an ELO of 3319, which is pretty close to 3352 which I calculated in the previous step. So I’ll use that one.

Click the link and it’ll download a file onto your desktop. This is a compressed file, that needs a program to open it. To get your software to recognize it as compressed, you need to rename it with a “.gz” extension. Like this:

Once your computer recognizes it, decompress the contents.

It will be a single file. Make a note of its location.

Step 4: Download the Leela Engine Bundle

Get the latest engine bundle for your system from the project download link. I’ve chosen the CPU version for Windows, because that’s my system configuration.

This will be a zip file. Unzip the contents into a folder called “Leela”.

Step 5: Put the Files Together into the “Engine” Folder in Arena

Now you have two downloads. Namely:

  1. The network weight file you downloaded in step 3
  2. The Leela engine (lczero.exe) that you downloaded in step 4

Put all these files in the same folder. Call the folder “Leela”, or “LCzero”, or whatever name you want to appear in Arena. Now transfer this entire folder into the “Engines” directory of Arena. This is the folder structure with the files:

Now it’s time to configure Arena with Leela!

Step 6: Installing the Leela LCZero Engine in Arena

Open the Arena program, click the “Engines” tab on top and click “Manage”

In the resulting window, click the “Details” tab and click the “New” button as shown here:

This will open a dialogue box asking for the location of the engine. Navigate to the “Leela” folder you created in step 5, and select “lczero.exe” as the engine.

In the next box, select “UCI” as the type of engine:

After selecting the engine, we need to enter the command line parameters in the box provided. Here, use the network weight file you extracted in step 3, in the following:

-w 209032b7

Replace the text in bold, with the name of your network weight file.

Then click “Apply” and then the button “Start this engine right now!”

And you’re done! The dialogue box will vanish, and Leela will now be the engine in Arena, running at the ELO strength you selected. Here’s a sample output from the Queen’s Gambit Accepted line.

What if the Above Doesn’t Work?

Sometimes the above steps fail for some reason. Leela just won’t start. So here’s something that has worked for a lot of people.

Step 1: Go to your engines folder in Arena

Step 2: Create a “lczero.bat” file and open it for editing

Step 3: Type the following into it:

@lczero.exe -w [network weight name]

Make sure you replace the section in square brackets with the network weight name you downloaded and unzipped in Step 3.

Step 4: Now go set up the engine again. This time, instead of choosing lczero.exe, click the drop down box labelled “Files of type” and select “Batch files (*.bat) instead.

Step 5: Now lczero.bat should be visible. Click on it and choose it as the engine.

Now just run your engine! Wait for a while for it to load and do its thing. No need to enter any command line parameters like before. These steps have helped a lot of people when just using lczero.exe directly didn’t work.

I hope these instructions make it easy for people to get started with running and experimenting with Leela. If you have a GPU, you can also use the bundled “client.exe” file to contribute your own GPU cycles for training games to help make Leela better!

What do you think of this post?
  • Agree (38)
  • You're an asshole (11)
  • Don't Agree but Interesting (8)

1 2

Comments

  1. Some IDs I can use after unpacking but some not, especially IDs with more weight.
    why when I unzip the gz files (ex: ID 480) it changes to txt files and I can not use its ?

    Reply

    • In reply to ALISON

      Yeah, it’s a bit weird right?

      Reply

      • In reply to bhagwad

        Well, if anyone knows how to solve this, please teach us. will be a great help.
        And sorry for my English (google translator, lol)

        Reply

      • In reply to ALISON

        Did you try to put in command line “-w weights_486.txt” without the ” ” charactes. probably file extensions are hidden by your operating system?

        Reply

      • In reply to JimmyB

        But the strange thing is that in IDs with less weight this problem does not happen. I will try and return with the result. Tks

        Reply

      • In reply to ALISON

        Problem solved! I ran the file “Client ” and started downloading the file “network” with more weight. I followed the steps explained above and it worked. Leela Chess on my PC with Max Power. I hope this information helps other people.
        TKS for all

        Reply

      • In reply to ALISON

        So we can just replace the max network file with an older one and it works as usual?

        Reply

      • In reply to bhagwad

        Yes, but you have to go back to step 5. I did it!!

        Reply

      • In reply to ALISON

        I created several folders with the names, leela1500, leela1700, leela2000 and LeelaMax, with all the files for each folder, as explained in the above steps and in step 6 I did for everyone changing the name. Now I have several engines with different rating to train.
        But my problem was when I unzipped the “network” because I could not use it. Only after I executed the file “Client ” that downloaded the correct

        Reply

  2. I had ID 486 in my example.

    Reply

1 2

Speak Your Mind

*