## Announcing lczero

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
koedem
Posts: 91
Joined: Fri Mar 18, 2016 9:45 pm

### Re: Announcing lczero

So I just read up on the basic ideas of NNs and thought this might be a nice testbed to try it out in practice.
Sorry for the stupid question, but how do you input the position? (I got a bit lost in the code... ) 64 * 13 input neurons for each possible piece on each square? (that would seem a bit weird to me but I don't see anything cleaner)

And another question, it's probably a bad idea but could one also let the NN learn the rules by itself? By letting it try random square combinations and have the cost function e.g. X - legal moves played at the start? (and by minimizing the cost function it learns to only play legal moves)
That might be slow but like that one doesn't force it to take moves in whatever format and instead let it decide itself how it wants to generate them. (and in what order if that makes sense)

FWCC
Posts: 117
Joined: Wed Aug 22, 2007 2:39 pm

### Re: Announcing lczero

Nice Project,the opening of that game looks like a 5 year old was playing it(Not 5 year old Capablanca)but we are at the beginning!If I can contribute CPU power let me know.Lets watch this grow.Is any of the implication from the A0 papers as it is not open source?

FWCC
TAL WAS CORRECT

Posts: 566
Joined: Tue Dec 12, 2006 9:10 am
Full name: Gary Linscott

### Re: Announcing lczero

A small progress update as well. From training so far, the network seems to be learning to draw incredibly well, but then nearly all the training samples end up being draws. This leads to a situation where predicting a draw as the value of the position is all the training learns. One potential way around the draw problem is including 33% wins, 33% losses, and 33% draws in the training set.

First though, taking a step back and going to train a net based on Stockfish self-play games (thanks gcp!), and we'll see how strong the engine is. That will hopefully flush out any major bugs in the search.

Posts: 566
Joined: Tue Dec 12, 2006 9:10 am
Full name: Gary Linscott

### Re: Announcing lczero

Training from SF self-play games seems to be working well. Here is self-play game on the latest network:
[pgn]
1. d4 Nf6 2. c4 e6 3. Nf3 d5 4. Nc3 c6 5. Bg5 h6 6. Bh4 dxc4 7. e4 g5 8.
Bg3 b5 9. h4 g4 10. Ne5 a5 11. f4 gxf3 12. Qxf3 a4 13. Bf4 Qxd4 14. Rc1 Nbd7
15. Nxc6 Qxc3+ 16. bxc3 Bb7 17. Bxc4 bxc4 18. Bxh6 Bxc6 19. Bg5 Ne5 20.
Qxf6 Bxe4 21. h5 Rxh5 22. Rxh5 Ng6 23. Qxg6 fxg6 24. Rh4 Bxg2 25. Rh6 Bxh6
26. Bxh6 Bh3 27. Bg7 Bg4 28. Bf6 Kf7 29. Bh8 Rxh8 30. Kf2 Rh2+ 31. Kg3 a3
32. Kxh2 Kf6 33. Kg3 Kf5 34. Re1 e5 35. Rxe5+ Kxe5 36. Kxg4 Kf6 37. Kf4 g5+
38. Ke4 Ke6 39. Kd4 g4 40. Kxc4 g3 41. Kb5 g2 42. c4 g1=Q 43. c5 Qb1+ 44.
Ka5 Kd7 45. Ka4 Qb2 46. Ka5 Kc6 47. Ka6 Kxc5 48. Ka7 Qxa2 49. Ka6 Qb1 50.
Ka7 Qa2 51. Ka8 Qb1 52. Ka7 a2 53. Ka8 a1=Q+
[/pgn]

It is starting to understand chess . Still, a long, long ways to go of course.

The weights are available for download from https://github.com/glinscott/lczero-wei ... _64.txt.gz if you want to try at home. It has working UCI support, so it could even play against other engines now!

Daniel Shawul
Posts: 4073
Joined: Tue Mar 14, 2006 10:34 am
Location: Ethiopia
Contact:

### Re: Announcing lczero

Here are three games against ScorpioMCTS, which uses monte-carlo-tree-search but replaces the value network with a qsearch. It doesn't have a policity network.

It seems lczero is far weeker at the moment mainly due to tactics issues i suppose.

[pgn]
[Event "Tour8"]
[Site "daniel-Satellite-C855"]
[Date "2018.01.15"]
[Round "1"]
[White "ScorpioMCTS"]
[Black "Lczero"]
[Result "1-0"]
[BlackElo "2200"]
[Time "06:41:30"]
[WhiteElo "2200"]
[TimeControl "60"]
[SetUp "1"]
[FEN "rq2kb1r/p2p1ppp/1pb1pn2/8/2P1P3/P1N5/1PQ1BPPP/R1B1K2R w KQkq - 0 1"]
[Termination "normal"]
[PlyCount "21"]
[WhiteType "program"]
[BlackType "program"]

1. Be3 {(Bc1-e3 Bf8-d6 Ke1-c1 Ke8-g8 Kc1-b1 Qb8-c7 Rh1-e1 Bd6-e5 Nc3-b5
Bc6xb5 c4xb5 Qc7xc2 Kb1xc2 Ra8-c8 Kc2-b1 d7-d5 e4xd5) -0.12/17 2} Bb4 2.
axb4 {(a3xb4 a7-a6 c4-c5 b6xc5 b4xc5) -0.78/5 1} d5 3. b5 {(b4-b5 Bc6-b7
e4xd5 e6xd5 c4xd5) -0.83/5 2} dxc4 4. bxc6 {(b5xc6 Qb8-c7 e4-e5 Nf6-d5
Nc3xd5) -1.27/5 1} Nd7 5. cxd7+ {(c6xd7 Ke8xd7 Qc2-a4 Kd7-e7) -1.89/4 1}
Kd8 6. Bxc4 {(Be2xc4 Qb8-c7 Bc4-b5 a7-a6) -1.93/4 1} Kxd7 7. Qa4+ {(Qc2-a4
Kd7-e7 Ke1-g1 Qb8-c7) -2.03/4 2} b5 8. Nxb5 {(Nc3xb5 Kd7-e7 Ke1-c1) -2.12/3
3} Kc6 9. Rd1 {(Ra1-d1 Kc6-b7 Rd1-d7 Kb7-c8) -3.04/4 4} a6 10. Na7+
{(Nb5-a7 Kc6-b7 Qa4-c6) -10.00/3 1} Kb7 11. Qc6# {(Qa4-c6) -10.00/1 1} 1-0

[Event "Tour8"]
[Site "daniel-Satellite-C855"]
[Date "2018.01.15"]
[Round "2"]
[White "Lczero"]
[Black "ScorpioMCTS"]
[Result "0-1"]
[BlackElo "2200"]
[Time "06:42:45"]
[WhiteElo "2200"]
[TimeControl "60"]
[SetUp "1"]
[FEN "rq2kb1r/p2p1ppp/1pb1pn2/8/2P1P3/P1N5/1PQ1BPPP/R1B1K2R w KQkq - 0 1"]
[Termination "normal"]
[PlyCount "41"]
[WhiteType "program"]
[BlackType "program"]

1. Bg5 Qe5 {(Qb8-e5 f2-f4 Qe5-d4 Ra1-d1 Qd4-e3 Qc2-d3 Qe3xd3 Be2xd3 Ra8-c8
Bd3-c2 Nf6-g4 Ke1-e2 f7-f6 Bg5-h4 Bf8-c5 Bc2-b3 Ke8-g8)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o "2200"]
[TimeControl "60"]
[SetUp "1"]
[FEN "rq2kb1r/p2p1ppp/1pb1pn2/8/2P1P3/P1N5/1PQ1BPPP/R1B1K2R w KQkq - 0 1"]
[Termination "normal"]
[PlyCount "21"]
[WhiteType "program"]
[BlackType "program"]

1. Be3 {(Bc1-e3 Bf8-d6 Ke1-c1 Ke8-g8 Kc1-b1 Qb8-c7 f2-f3 Bd6-e5 Nc3-b5
Bc6xb5 c4xb5 Qc7xc2 Kb1xc2 d7-d5 f3-f4 Ra8-c8 Kc2-b1 Be5-d6) -0.13/18 3}
Bb4 2. axb4 {(a3xb4 a7-a6 c4-c5 b6xc5 b4xc5 Ke8-g8) -0.78/6 2} d5 3. b5
{(b4-b5 Bc6-b7 e4xd5 e6xd5 c4xd5) -0.82/5 2} dxc4 4. bxc6 {(b5xc6 Qb8-c7
e4-e5 Nf6-d5 Nc3xd5) -1.27/5 1} Nd7 5. cxd7+ {(c6xd7 Ke8xd7 Qc2-a4 Kd7-e7)
-1.89/4 1} Kd8 6. Bxc4 {(Be2xc4 Qb8-c7 Be3-g5 f7-f6) -1.93/4 1} Kxd7 7.
Qa4+ {(Qc2-a4 Kd7-e7 Qa4-d1) -2.05/3 2} b5 8. Nxb5 {(Nc3xb5 Kd7-e7 Ke1-c1)
-2.12/3 3} Kc6 9. Rd1 {(Ra1-d1 Kc6-b7 Rd1-d7 Kb7-c8) -3.04/4 3} a6 10. Na7+
{(Nb5-a7 Kc6-b7 Qa4-c6) -10.00/3 3} Kb7 11. Qc6# {(Qa4-c6) -10.00/1 1} 1-0

[/pgn]

Henk
Posts: 6716
Joined: Mon May 27, 2013 8:31 am

### Re: Announcing lczero

gladius wrote:Training from SF self-play games seems to be working well. Here is self-play game on the latest network:
[pgn]
1. d4 Nf6 2. c4 e6 3. Nf3 d5 4. Nc3 c6 5. Bg5 h6 6. Bh4 dxc4 7. e4 g5 8.
Bg3 b5 9. h4 g4 10. Ne5 a5 11. f4 gxf3 12. Qxf3 a4 13. Bf4 Qxd4 14. Rc1 Nbd7
15. Nxc6 Qxc3+ 16. bxc3 Bb7 17. Bxc4 bxc4 18. Bxh6 Bxc6 19. Bg5 Ne5 20.
Qxf6 Bxe4 21. h5 Rxh5 22. Rxh5 Ng6 23. Qxg6 fxg6 24. Rh4 Bxg2 25. Rh6 Bxh6
26. Bxh6 Bh3 27. Bg7 Bg4 28. Bf6 Kf7 29. Bh8 Rxh8 30. Kf2 Rh2+ 31. Kg3 a3
32. Kxh2 Kf6 33. Kg3 Kf5 34. Re1 e5 35. Rxe5+ Kxe5 36. Kxg4 Kf6 37. Kf4 g5+
38. Ke4 Ke6 39. Kd4 g4 40. Kxc4 g3 41. Kb5 g2 42. c4 g1=Q 43. c5 Qb1+ 44.
Ka5 Kd7 45. Ka4 Qb2 46. Ka5 Kc6 47. Ka6 Kxc5 48. Ka7 Qxa2 49. Ka6 Qb1 50.
Ka7 Qa2 51. Ka8 Qb1 52. Ka7 a2 53. Ka8 a1=Q+
[/pgn]

It is starting to understand chess . Still, a long, long ways to go of course.

The weights are available for download from https://github.com/glinscott/lczero-wei ... _64.txt.gz if you want to try at home. It has working UCI support, so it could even play against other engines now!
Using chess knowledge is against the zero rules. It's like cheating. Of course you can rename your engine to LCFish.

Jhoravi
Posts: 284
Joined: Wed May 08, 2013 4:49 am

### Re: Announcing lczero

gladius wrote:Training from SF self-play games seems to be working well. Here is self-play game on the latest network:
[pgn]
1. d4 Nf6 2. c4 e6 3. Nf3 d5 4. Nc3 c6 5. Bg5 h6 6. Bh4 dxc4 7. e4 g5 8.
Bg3 b5 9. h4 g4 10. Ne5 a5 11. f4 gxf3 12. Qxf3 a4 13. Bf4 Qxd4 14. Rc1 Nbd7
15. Nxc6 Qxc3+ 16. bxc3 Bb7 17. Bxc4 bxc4 18. Bxh6 Bxc6 19. Bg5 Ne5 20.
Qxf6 Bxe4 21. h5 Rxh5 22. Rxh5 Ng6 23. Qxg6 fxg6 24. Rh4 Bxg2 25. Rh6 Bxh6
26. Bxh6 Bh3 27. Bg7 Bg4 28. Bf6 Kf7 29. Bh8 Rxh8 30. Kf2 Rh2+ 31. Kg3 a3
32. Kxh2 Kf6 33. Kg3 Kf5 34. Re1 e5 35. Rxe5+ Kxe5 36. Kxg4 Kf6 37. Kf4 g5+
38. Ke4 Ke6 39. Kd4 g4 40. Kxc4 g3 41. Kb5 g2 42. c4 g1=Q 43. c5 Qb1+ 44.
Ka5 Kd7 45. Ka4 Qb2 46. Ka5 Kc6 47. Ka6 Kxc5 48. Ka7 Qxa2 49. Ka6 Qb1 50.
Ka7 Qa2 51. Ka8 Qb1 52. Ka7 a2 53. Ka8 a1=Q+
[/pgn]

It is starting to understand chess . Still, a long, long ways to go of course.

The weights are available for download from https://github.com/glinscott/lczero-wei ... _64.txt.gz if you want to try at home. It has working UCI support, so it could even play against other engines now!
It's working!! The first dozen moves are no random anymore! Proof is that whites dark Bishop retreated twice when threatened by blacks h6 and g5 pawn moves and so does the Knight at Nf3 moved to Ne5 when threatened by g4.

Interesting is that the remaining moves goes back to random proving that the learning concentration starts at the opening phase then moving forward meaning it may master the endgame last.

jpqy
Posts: 532
Joined: Thu Apr 24, 2008 7:31 am
Location: Belgium

### Re: Announcing lczero

Is it possible to get a working compile Lczero for windows..

Now that we can still beat it..or to follow it up till we can't anymore

I think more people would like to play against it so long it makes crazy moves..

JP.

Rodolfo Leoni
Posts: 545
Joined: Tue Jun 06, 2017 2:49 pm
Location: Italy

### Re: Announcing lczero

jpqy wrote:Is it possible to get a working compile Lczero for windows..

Now that we can still beat it..or to follow it up till we can't anymore

I think more people would like to play against it so long it makes crazy moves..

JP.
+1
I'm very curious too...
F.S.I. Chess Teacher