There have been some major developments in the advance of Artificial Intelligence (AI) of late. Whilst taking a cuddly robot home with you is still a bit off, you can play chess against a machine that thinks and plays like a human. For free!

We will show you how to install a chess engine like no other, Leela Chess Zero, along with some helpful tips and tricks.

What is AI?

What is the major difference between an AI and, say Stockfish or another traditional chess engine?  It is not totally easy to explain, but in short:

Any of the brute force engines are quite rudimentary, they will ruthlessly calculate variations and come up with engine like variations which no human would ever come up with. Partially because it is outside of our "horizon" of moves we would consider, but also because these programs are very tactically oriented. In essence, they count material and base their search trees on what leads to the greatest material advantage. This can be great for analysing where you missed a tactical shot, but it also makes play against them incomprehensible, if not depressing. You don't understand what plans (because the computer does not make plans) are afoot, and it becomes frustrating. And if you choose a lower setting, the software will make random errors a human normally would not make, so you can't really learn to play against such an entity. 

Neural Network

Compare this with a self learning AI! Yes, that is right, the machine will have learnt to play chess by self study and watching other games. It achieves this learning in roughly the same way as you do, using a Neural Network (NN). This means the machine will play much like a human being, albeit quite a strong one if you choose the very latest network (more on this later). 

This means it is both entertaining and fun to play an AI. You can understand the plans, because they are human plans, and you can follow the reasoning for sacrifices, again because they are the same reasons a human would use. The big trick here is that you can download different networks of different strengths. So if you are a beginner, you will want to download one of the earlier iterations of the "brain" where the machine has not learnt so much. Then as you get stronger, you find a brain of sufficient strength to be combative.

This is entirely unlike playing the brute force engines which make silly moves. In early versions of the brain, you can see Leela is more interested in her own plans, missing simple mates because she wants to grab material. Later, as she has learnt more, she becomes more protective of her bishops, building up unstoppable attacks, doing long term positional sacrifices for passed pawns, all the things we as chess players learn as we go along. And by now, she is already beyond Super GM level, starting to beat top programs such as Stockfish and Komodo.

History

Google Deep Mind

The holy grail of AI was the game of Go. If you have not heard of it, it is an incredibly simple game that takes 5-10 minutes to learn, but is much more complicated than chess. You could not apply the minimax game theory to Go as you could to chess, and as a result professional Go players would simply laugh at engines.   Not worth their while!

Then came DeepMind, a British AI company founded by Demis Hassabis along with a couple of others. Demis used to play chess and reached master level at age 13 with ELO rating of 2300, captaining England's Junior team on several occasions.

DeepMind concentrated on machine learning, and this is one of their early successes where the machine learns how to play Pong:

As you can see, initially the machine does not understand anything that is going on, but then slowly learns until it becomes an expert.

DeepMind then set their sights on Go, and in October 2015 had AlphaGo which beat the then European Champion Fan Hui. A half-year later, in March 2016, AlphaGo beat the Go world champion Lee Sedol. If you have Netflix and want to watch more about AlphaGo and the two champions, there is a documentary that is very interesting.

https://www.netflix.com/gb/title/80190844 

Google, which had acquired the British company, then published an academic paper on how they had managed their achievement, which allowed others to read the research and replicate it. 

Leela Chess Zero

Female AI

This is where Leela Chess Zero comes in. Unfortunately, Google had not put in all the information needed to create a chess engine, so the Leela team had to do that themselves, and there were some network tuning issues that had to be resolved.

However, things are progressing well. The earliest brains were published in February, and if you choose to download one, you will see how bad Leela is at playing. The ELO rating that is published is clearly not the real one, there is a bit of a formula related to how to compute this, but it is also all very dependent on the graphics card you have in your computer.

Neural Networks require graphics processors for you to be able to get the best out of them. If you have a very good gaming graphics card, then Leela will be much stronger than on an entry level desktop or laptop. But even if you don't have a strong one you can still play her on a CPU. And I promise she will be a challenge, you just need to download progressively stronger brains until you find you are challenged. This is why you should not worry too much about calculating ELO strength and whatnot, just play and have fun!

Playing Leela over the web

If you don't want to install Leela, you have at least two options of playing her over the web. Firstly there is the demo website http://play.lczero.org/ which allows you to play at three different strengths. It is a good fun thing to do on a rainy day.

Or if you prefer, you can challenge her on Lichess https://lichess.org/@/LeelaChess 

Both ways allows you to test out Leela and hopefully have fun. However, she will have the latest brain (or near as), which sadly might be too strong for you (unless you are Magnus, in which case: Hello, do you fancy joining Watford Chess Club?). She is certainly way to strong for me on the latest networks. If you want to take full advantage of being able to download new brains and older versions of Leela that are more suited to the level you are at, then you need to install the software on your PC or laptop.

Installing Leela Chess Zero

It is quite simple to install Leela:

https://github.com/LeelaChessZero/lc0/wiki/Getting-Started

This ChessBase article which also shows you how to set it up in their software also has some screenshots and some more background information:

https://en.chessbase.com/post/leela-chess-zero-alphazero-for-the-pc

Of course, if you are interested in using Leela for analysis, then get the latest and bestest network you can find.

How to play Leela

After setting her up, all you need to do is point your favourite UCI interface to her. I can recommend both Arena and Lucas Chess. 

http://www.playwitharena.com/

https://lucaschess.pythonanywhere.com/

Personally I find Arena a little bit more straight forward, but it is only a matter of taste, you might have a different chess program you like to use.

Setting up brains

From the Leela network page: http://lczero.org/networks you can download any of the brains from when she was rated 0, to now where she will beat most players in the world. All you need to do is download the version you want, copy it to your Leela directory as the weights.txt file, and re-run the Leela command.

Now she has a new brain and you can start playing her.

Watch the video where Geir shows how to install and use Arena:

This is a quick video showing some of the more important aspects of how to get the best out of Leela at home

Kingscrusher videos

Here are a couple of videos by Kingscrusher that shows the strength of Leela at the time of writing:

 

 

This is interesting because it shows how to explore games: