Train your engine !

General discussion about computer chess...
Post Reply
User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Train your engine !

Post by deeds » Tue Oct 26, 2021 10:47 am

There are several engines that use a learning algorithm, the best known are :
- brainlearn
- eman
- sugar

How it works ?
After each game, the engine saves in a experience file whether its moves are winners, draws or losers.
Before each game, the engine loads the experience file to get a better evaluation of its moves.

For the following examples, I chose Eman because :
- its source code is not public
- he hinders his competitors
- it allows to choose the experience file
- it displays the information contained in its experience file (thanks to the builtin commands "exp" and "expex")
- it allows to defragment the experiment file (thanks to the builtin command "exp-defrag")
- it allows to merge multiple experience files (thanks to the builtin command "exp-merge")
- there are different tools to modify/check the experience file (tools for eman/sugar chess engines)

Learn openings :
if Eman lost a game from a particular opening, it may be worthwhile to analyze in depth each move in that game.
So that Eman understands his mistakes and finds better moves in order to avoid to loose this again.
Eman can also play multiple games from this opening so that it could learn how to snatch a draw from an unfavorable position or get a win from a draw position.
It can take up to 500 or even 1000 games.

Here is a summary of a few openings where [Eman experience] tried to learn something against [Eman only] :
Image
[Eman only] didn't used an experience file and [Eman experience] started with an empty experience file.
Settings : both engines used 8 threads (e3-1275v2), a hash of 512 MB, no contempt, no syzygy, no book, no livebook, strongest net handled by the engines, cutechess-cli (concurrency 1) ran 2000 games with reversed colors at a time control of 60 sec + 1 sec.

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Tue Oct 26, 2021 5:05 pm

For example, let's look at the opening a01 a7a5 (r1bq1rk1/1pp2pbp/2np2p1/p3n3/4P3/1PN3P1/PBPQ1PBP/2KR2NR w - - 0 11).

Both engines agreed with 11. f2-f4 {+1.47/41} Ne5-d7 [+1.51/39}.

Then there were 3 main moves :
Image
- h2-h4 {+1.57/38} was played 1000 times by [Eman experience] and 935 times by [Eman only]
- Ng1-e2 {+1.19/24} was played 34 times by [Eman only]
- Ng1-f3 {+1.17/23} was played 31 times by [Eman only]
When [Eman experience] played as black against the white moves 12. Ng1-e2 and 12. Ng1-f3, he learned they weren't the bestmove here.

After 12. h2-h4 {+1.57/38}, 5 moves were played :
Image
- a5-a4 {+1.43/31} was played 295 times by [Eman experience] and 3 times by [Eman only]
- Nd7-f6 {+1.86/29} was played 633 times by [Eman experience] and 997 times by [Eman only]
- Nc6-b4 {+1.64/32) was played 3 times by [Eman experience]
- Nd7-c5 {+1.55/28) was played 3 times by [Eman experience]
- h7-h5 {+1.76/25) was played 1 time by [Eman experience]
After mostly played Nd7-f6 and tried some alternative moves, [Eman experience] learned that a5-a4 was the best countermove here.

After 12. ... Nd7-f6 {+1.86/29}, there were 3 main moves :
Image
- Ng1-h3 {+1.09/27} was played 987 times by [Eman experience] and 300 times by [Eman only]
- Bg2-f3 {+1.08/27} was played 10 times by [Eman experience] and 332 times by [Eman only]
- a2-a4 {+1.08/26} was played 1 time by [Eman only]
So [Eman only] didn't know which is the best move between 13. Ng1-h3 (wins @ 91.7%) and 13. Bg2-f3 (draws @ 98%).
Thanks to the experience file, [Eman experience] learned 13. Ng1-h3 wins more often here.

After 13. Ng1-h3 {+1.09/27}, 3 moves were played :
Image
- Bc8-g4 {+1.86/31} was played 2 times by [Eman experience]
- Nf6-h5 {+1.25/27} was played 296 times by [Eman experience] and 987 times by [Eman only]
- h7-h5 {+1.69/28} was played 2 times by [Eman experience]
[Eman experience] tried some alternative moves but Nf6-h5 was the best countermove here.

After 13. ... Nf6-h5 {+1.25/27}, both engines agreed with 14. Qd2-e3 {+1.45/24}.

And so on...

ps :
Image
blue = cumulated score each 10 games (+1 for a win, 0.5 for a draw, -1 for a loss)
red = evo curve of [Eman experience]

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Thu Oct 28, 2021 6:39 pm

Bad period for BrainLearn (nn-6762d36ad265) against Eman (nn-46832cfbead3) in the Torre attack (A46):
Image

elo curve :
Image

experience.bin :
Image

eman.exp :
Image

I hope both will learn strong moves in this opening...

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Sun Oct 31, 2021 6:01 pm

With the following openings, i replaced [Eman only] by [BrainlLearn13.1 nn-6762d36ad265]
[BrainlLearn13.1 nn-6762d36ad265] and [Eman experience] started with an empty experience file.
Settings : both engines used 8 threads (e3-1275v2), a hash of 512 MB, no contempt, no syzygy, no book, no livebook, strongest net handled by the engines, cutechess-cli (concurrency 1) ran 2000 games with reversed colors at a time control of 60 sec + 1 sec.

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Sun Oct 31, 2021 6:39 pm

A46 Torre attack :

[Event "Eman's learning"]
[Site "deeds"]
[Date "2021.05.24"]
[Round "000007"]
[White "A46"]
[Black "A46"]
[Result "*"]
[ECO "A46"]
[PlyCount "20"]

1. d4 Nf6 2. Nf3 e6 3. Bg5 h6 4. Bxf6 Qxf6 5. e4 d6 6. Nc3 Nd7 7. Qd2 a6
8. O-O-O Qd8 9. Ne1 Be7 10. Be2 O-O *

Code: Select all

   # PLAYER                             :  RATING  ERROR  POINTS  PLAYED   (%)    W    D    L  D(%)  OppAvg  OppN
   1 Eman experience                    :      72     14  1135.0    2000  56.8  708  854  438  42.7       0     1
   2 brainlearn 13.1 nn-6762d36ad265    :       0   ----   865.0    2000  43.3  438  854  708  42.7      72     1

White advantage = -237.08 +/- 7.45
Draw rate (equal opponents) = 50.00 % +/- 0.00
Image
brainlearn 13.1 nn-6762d36ad265 with 438/2000 wins (21,90%, D28/245, 1 492 ms) :

1. d4 @ 100,00%

Eman experience with 708/2000 wins (35,40%, D32/245, 1 738 ms) :

1. d4 @ 100,00%

Averages :
222 sec/game
159 plies/game
[brainlearn 13.1 nn-6762d36ad265] seemed stronger than [Eman only] but [Eman experience] is amazing here.

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Sat Nov 06, 2021 5:40 am

B34 Sicilian, Accelerated Fianchetto, Modern :

[Event "Eman's learning"]
[Site "deeds"]
[Date "2021.05.24"]
[Round "0059-0060"]
[White "B34"]
[Black "B34"]
[Result "*"]
[ECO "B34"]
[PlyCount "20"]

1. e4 c5 2. Nf3 Nc6 3. d4 cxd4 4. Nxd4 g6 5. Be3 Bg7 6. Nc3 Nf6 7. f3 O-O
8. Nb3 d6 9. Qd2 Be6 10. O-O-O a5 *

Code: Select all

   # PLAYER                             :  RATING  ERROR  POINTS  PLAYED   (%)    W    D    L  D(%)  OppAvg  OppN
   1 Eman experience                    :      17     13  1028.5    2000  51.4  625  807  568  40.4       0     1
   2 brainlearn 13.1 nn-6762d36ad265    :       0   ----   971.5    2000  48.6  568  807  625  40.4      17     1

White advantage = 241.62 +/- 6.70
Draw rate (equal opponents) = 50.00 % +/- 0.00
Image
brainlearn 13.1 nn-6762d36ad265 with 568/2000 wins (28,40%, D28/245, 1 470 ms) :

1. e4 @ 100,00%

Eman experience with 625/2000 wins (31,25%, D32/245, 1 624 ms) :

1. e4 @ 100,00%

Averages :
225 sec/game
167 plies/game
[brainlearn 13.1 nn-6762d36ad265] learned lately here but both engines learned this opening.

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Sun Nov 07, 2021 6:05 pm

Another example with a B89 Sicilian Velimirovic where BrainLearn learns slower than Eman :

[Event "Eman's learning"]
[Site "deeds"]
[Date "2021.05.24"]
[Round "0065-0066"]
[White "B89"]
[Black "B89"]
[Result "*"]
[ECO "B89"]
[PlyCount "20"]

1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 Nc6 6. Bc4 e6 7. Be3 Be7
8. Qe2 O-O 9. O-O-O Qc7 10. Rhg1 Na5 *

Both engines always played 11. Bd3 but then they tried 4 moves :

Image

Image

And as you can see, Brainlearn keeps playing 11. ... a6 when Eman even switched from 11. ... a6 to 11. ... g6

At the moment, Eman leads :

Code: Select all

   # PLAYER                             :  RATING  ERROR  POINTS  PLAYED   (%)    W    D    L  D(%)  OppAvg  OppN
   1 Eman experience                    :      98     30   324.5     570  56.9  235  179  156  31.4       0     1
   2 brainlearn 13.1 nn-6762d36ad265    :       0   ----   245.5     570  43.1  156  179  235  31.4      98     1

White advantage = 313.01 +/- 15.14
Draw rate (equal opponents) = 50.00 % +/- 0.00

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Sun Nov 07, 2021 8:11 pm

After 11. Bd3 a6 12. g4, the engines tried 5 moves :

Image

Image

While BrainLearn still hesitates between 12. ... g6 or 12. ... d5, Eman keeps 12. ... g6 and he seems to be right.

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Thu Nov 11, 2021 4:35 pm

B89 Sicilian Velimirovic :

[Event "Eman's learning"]
[Site "deeds"]
[Date "2021.05.24"]
[Round "0065-0066"]
[White "B89"]
[Black "B89"]
[Result "*"]
[ECO "B89"]
[PlyCount "20"]

1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 Nc6 6. Bc4 e6 7. Be3 Be7
8. Qe2 O-O 9. O-O-O Qc7 10. Rhg1 Na5 *

Code: Select all

   # PLAYER                             :  RATING  ERROR  POINTS  PLAYED   (%)    W    D    L  D(%)  OppAvg  OppN
   1 Eman experience                    :      93     16  1135.0    2000  56.8  815  640  545  32.0       0     1
   2 brainlearn 13.1 nn-6762d36ad265    :       0   ----   865.0    2000  43.3  545  640  815  32.0      93     1

White advantage = 306.56 +/- 7.94
Draw rate (equal opponents) = 50.00 % +/- 0.00
Image
brainlearn 13.1 nn-6762d36ad265 with 545/2000 wins (27,25%, D29/245, 1 480ms) :

1. e4 @ 100,00%

Eman experience with 815/2000 wins (40,75%, D33/245, 1 693 ms) :

1. e4 @ 100,00%

Averages :
232 sec/game
167 plies/game

User avatar
deeds
Posts: 652
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Train your engine !

Post by deeds » Mon Nov 15, 2021 10:54 am

B88 Sicilian, Sozin-Scheveningen :

[Event "Eman's learning"]
[Site "deeds"]
[Date "2021.05.24"]
[Round "0069-0070"]
[White "B88"]
[Black "B88"]
[Result "*"]
[ECO "B88"]
[PlyCount "20"]

1. e4 c5 2. Nf3 Nc6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 d6 6. Bc4 e6 7. Be3 Be7
8. Bb3 O-O 9. Qe2 Bd7 10. O-O-O Qb8 *

Code: Select all

   # PLAYER                             :  RATING  ERROR  POINTS  PLAYED   (%)    W     D    L  D(%)  OppAvg  OppN
   1 Eman experience                    :       4     11  1010.0    2000  50.5   96  1828   76  91.4       0     1
   2 brainlearn 13.1 nn-6762d36ad265    :       0   ----   990.0    2000  49.5   76  1828   96  91.4       4     1

White advantage = 25.28 +/- 5.60
Draw rate (equal opponents) = 50.00 % +/- 0.00
Image
brainlearn 13.1 nn-6762d36ad265 with 76/2000 wins (3,80%, D26/245, 1 506 ms) :

1. e4 @ 100,00%

Eman experience with 96/2000 wins (4,80%, D28/245, 1 885 ms) :

1. e4 @ 100,00%

Averages :
157 sec/game
114 plies/game

Post Reply