A complete 2000 lines of code engine

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

Moderators: hgm, Rebel, chrisw

User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: A complete 2000 lines of code engine

Post by xr_a_y »

M ANSARI wrote: Mon Jul 29, 2019 11:13 am Can I ask what the present number of line the code is now? Would be interesting to see if it can still do well without going over 2000 lines or if 2000 is a number that hurts progress significantly.
There are 3395 real lines of code in a file with 3806 total lines.
Being under 2000 seems not possible or very hard with SMP/Bitboards and including protocol (xboard or uci).
Minic code is still very readable, pushing it under 3000 lines would make not easy to read.

Code: Select all

3806 lines (3395 sloc) 197 KB 
Protocol is around 400 lines
Search is around 600 lines
TB is around 100 lines
Eval is around 300 lines
Material hash thing is about 400 lines
Bitboard & tools 400 lines
Position, tools, ... 1100 lines => some lines can be gained here ...

I can/will get under 3000 used lines if I clean up the code.
JohnWoe
Posts: 491
Joined: Sat Mar 02, 2013 11:31 pm

Re: A complete 2000 lines of code engine

Post by JohnWoe »

Regarding lines. Stockfish's search 743 lines. :D

starts -> line 560: https://github.com/official-stockfish/S ... h.cpp#L560
ends -> line: 1303: https://github.com/official-stockfish/S ... .cpp#L1303
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: A complete 2000 lines of code engine

Post by xr_a_y »

Recent Gauntlet for Minic dev

Code: Select all

   1 zurichess-neuchatel           194      51     168   75.3%   23.2%
   2 Winter                        143      48     169   69.5%   24.3%
   3 Topple                         90      46     169   62.7%   26.0%
   4 asymptote_v0.6                 33      45     170   54.7%   27.1%
   5 ruy-1.1.9                       0      45     169   50.0%   25.4%
User avatar
flok
Posts: 481
Joined: Tue Jul 03, 2018 10:19 am
Full name: Folkert van Heusden

Re: A complete 2000 lines of code engine

Post by flok »

Micah is 1842 lines! With UCI, lazy-SMP, tuning, table-bases!





(but to be honest: it uses libchess & fathom 8-) )
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: A complete 2000 lines of code engine

Post by xr_a_y »

flok wrote: Mon Aug 05, 2019 4:05 pm Micah is 1842 lines! With UCI, lazy-SMP, tuning, table-bases!
(but to be honest: it uses libchess & fathom 8-) )
I think it is good to keep the code small and simple.
Minic is still easily readable despite the long lines.
My advice would be to keep Micah this way, especially as it is based on some useful dependency, this is a great opportunity to stay clean as mainly search and eval has to be implemented.

Really hope the next 600 elo won't cost you 1200 lines :wink:

Code: Select all

Score of Micah vs minic_dev: 3 - 196 - 8 [0.034]
Elo difference: -582.4 +/- 126.9, LOS: 0.0 %, DrawRatio: 3.9 %
Here is one of the 3 Micah's wins as black successfully pushing a passed pawn! Totally outplaying Minic 8-) (this was short TC 40/20sec and Minic is finding 46. h2h3 only at depth 14 ... only reached depth 13 during the game ... too bad)

[pgn] [Event "My Tournament"] [Site "?"] [Date "2019.08.05"] [Round "34"] [White "minic_dev"] [Black "Micah"] [Result "0-1"] [ECO "A00"] [GameDuration "00:01:02"] [GameEndTime "2019-08-05T18:56:53.464 CEST"] [GameStartTime "2019-08-05T18:55:50.743 CEST"] [Opening "Dunst (Sleipner, Heinrichsen) Opening"] [PlyCount "132"] [TimeControl "40/20"] 1. Nc3 {book} Nf6 {book} 2. Nf3 {book} Nc6 {book} 3. e4 {0s} e5 {-0.16/10 0.44s} 4. Bb5 {0s} Nd4 {-0.06/10 0.22s} 5. O-O {0s} Nxb5 {+0.16/11 0.24s} 6. Nxb5 {0s} c6 {-0.05/12 0.39s} 7. Nc3 {0s} d5 {-0.11/12 0.29s} 8. Nxe5 {+0.49/16 0.33s} d4 {+0.14/10 0.23s} 9. Ne2 {+1.08/15 0.60s} Nxe4 {+0.01/10 0.47s} 10. d3 {+1.21/16 0.43s} Nf6 {+0.14/11 0.29s} 11. Re1 {+1.14/17 0.37s} Be7 {+0.18/11 0.47s} 12. Bg5 {+1.13/16 0.62s} O-O {+0.11/10 0.24s} 13. Qd2 {+0.49/14 0.62s} h6 {+0.65/11 0.35s} 14. Bf4 {+0.22/14 0.62s} c5 {+0.67/9 0.48s} 15. Nc4 {+0.27/15 0.36s} b5 {+1.03/9 0.27s} 16. Ne5 {+0.26/13 0.45s} Bb7 {+1.11/11 0.47s} 17. a4 {+0.37/14 0.63s} b4 {+1.26/11 0.43s} 18. Ng3 {+0.60/15 0.63s} Re8 {+1.20/10 0.34s} 19. a5 {+0.35/17 0.55s} Qd5 {+1.18/10 0.32s} 20. f3 {+0.22/16 0.43s} Bd6 {+1.05/10 0.42s} 21. Nc4 {+0.67/20 0.40s} Bf8 {+0.93/11 0.34s} 22. Ne4 {+0.65/11 0.070s} Nxe4 {+0.75/10 0.30s} 23. fxe4 {+0.48/17 0.40s} Qd7 {+0.90/11 0.31s} 24. a6 {+0.42/14 0.71s} Bc8 {+0.75/12 0.43s} 25. e5 {+0.75/12 0.089s} Re6 {+0.85/12 0.53s} 26. Nd6 {+0.48/16 0.52s} Qc6 {+0.81/12 0.30s} 27. Bg3 {+0.57/16 0.77s} Bxa6 {+1.17/11 0.34s} 28. Qf2 {+0.21/21 2.2s} f6 {+1.20/11 0.33s} 29. Qf5 {+0.25/15 0.39s} Bc8 {+1.10/12 0.49s} 30. Nxc8 {+0.25/15 0.67s} Qxc8 {+0.90/12 0.42s} 31. Qf3 {-0.07/15 0.67s} Qd8 {+0.58/11 0.36s} 32. Rf1 {+0.22/17 1.2s} a5 {+0.84/11 0.46s} 33. Qg4 {+0.36/15 0.61s} Raa6 {+0.92/12 0.44s} 34. Rf5 {+0.12/14 0.61s} a4 {+0.99/10 0.57s} 35. Bh4 {0.00/15 0.60s} g5 {+1.26/11 0.41s} 36. Bg3 {-0.28/17 0.43s} a3 {+1.35/10 0.51s} 37. bxa3 {-0.28/15 0.65s} bxa3 {+1.79/11 0.40s} 38. Rff1 {-0.68/14 0.65s} Qe7 {+1.91/12 0.36s} 39. exf6 {-0.52/16 0.45s} Rxf6 {+2.13/12 0.31s} 40. Rfe1 {-0.52/15 0.86s} Qd8 {+2.13/10 0.42s} 41. c4 {-0.99/15 0.45s} a2 {+2.72/11 0.33s} 42. Re2 {-0.87/15 0.33s} Qb6 {+2.71/10 0.55s} 43. Qe4 {-1.20/15 0.51s} Rf7 {+2.74/10 0.55s} 44. Be5 {-1.30/16 0.51s} Qb1+ {+3.13/11 0.48s} 45. Re1 {-1.95/14 0.058s} Rb6 {+3.15/11 0.30s} 46. Bd6 {0.00/13 0.051s} Qxa1 {+6.68/13 0.37s} 47. Rxa1 {-8.85/25 2.7s} Rb1+ {+9.52/14 0.45s} 48. Qe1 {-12.97/27 2.3s} Rxe1+ {+9.45/15 0.55s} 49. Rxe1 {-14.03/25 1.1s} Rb7 {+9.63/15 0.49s} 50. Kf2 {-14.03/27 1.9s} Rb2+ {+9.65/14 0.53s} 51. Kg3 {-14.35/25 1.7s} Bxd6+ {+9.80/14 0.37s} 52. Kf3 {-14.66/26 0.29s} Rb1 {+10.18/14 0.41s} 53. Re8+ {-14.74/26 0.29s} Kf7 {+10.18/13 0.58s} 54. Ra8 {-15.19/23 0.29s} a1=Q {+10.57/14 0.43s} 55. Rxa1 {-20.91/28 0.85s} Rxa1 {+11.46/15 0.50s} 56. Kf2 {-20.91/26 0.27s} Ra3 {+12.11/13 0.36s} 57. h4 {-23.96/32 0.98s} Rxd3 {+13.99/13 0.31s} 58. Ke2 {-38.34/23 1.2s} Re3+ {+15.30/15 0.54s} 59. Kd2 {-M29/8 0.11s} gxh4 {+15.72/11 0.36s} 60. Kc2 {-27.04/12 0.20s} Bf4 {+22.47/12 0.35s} 61. g4 {-24.00/12 0.20s} hxg3 {+99.80/9 0.33s} 62. Kd2 {-M9/9 0.15s} g2 {+99.94/11 0.60s} 63. Kd1 {-M7/35 0.11s} g1=Q+ {+99.96/8 0.64s} 64. Kc2 {-M5/121 0.024s} Re2+ {+99.97/8 0.38s} 65. Kb3 {-M5/67 0.015s} Qb1+ {+99.98/8 0.65s} 66. Ka3 {-M3/121 0.002s} Qb4# {+99.99/8 0.65s, Black mates} 0-1 [/pgn]
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: A complete 2000 lines of code engine

Post by xr_a_y »

some recent progress @TC 40/1min 1024M hash (around CCRL40/4), here Minic dev version head to head with various engines :)

Code: Select all

   1 Winter                        167      54     143   72.4%   23.1%
   2 zurichess-neuchatel            61      50     143   58.7%   26.6%
   3 Topple                         42      45     142   56.0%   40.1%
   4 ruy-1.1.9                      -5      48     143   49.3%   28.7%
   5 asymptote_v0.6                 -7      48     144   49.0%   28.5%
   6 minic_0.85                    -10      31     143   48.6%   70.6%
   7 minic_0.82                    -32      37     143   45.5%   58.7%
   8 minic_0.76                    -34      41     143   45.1%   49.7%
   9 minic_0.65                    -97      44     144   36.5%   41.0%   
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: A complete 2000 lines of code engine

Post by xr_a_y »

Some Windows results, same TC and hash, native VS build

Code: Select all

Rank Name                          Elo     +/-   Games   Score   Draws
   0 Minic                          18      14    1775   52.6%   27.9%
   1 Winter_0.6_New_Windows         99      28     443   63.9%   27.5%
   2 Topple_0.7.1                   -2      27     444   49.8%   32.0%
   3 rofChade 1                    -28      28     444   45.9%   26.6%
   4 fruit_21                     -146      29     444   30.2%   25.7%

1775 of 4000 games finished.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: A complete 2000 lines of code engine

Post by xr_a_y »

Minic is finally getting >1000 at STS @10sec per position (single core, on quite old hardware) : 1051 :) still not very smart but that's better.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: A complete 2000 lines of code engine

Post by xr_a_y »

Minic 0.87 is released, around +30 versus previous.

Code: Select all

Score of minic_0.82 vs minic_0.87: 202 - 299 - 499 [0.452]
Elo difference: -33.8 +/- 15.2, LOS: 0.0 %, DrawRatio: 49.9 %
On my hardware around CCRL 40/4 TC with 1024Mo TT

Code: Select all

Rank Name                          Elo     +/-   Games   Score   Draws
   1 Winter                        195      21     929   75.5%   25.4%
   2 zurichess-neuchatel           148      19     928   70.1%   30.7%
   3 Topple                        113      19     928   65.7%   29.7%
   4 minic_0.87                    100      18     929   64.0%   34.0%
   5 minic_0.86                     91      18     929   62.9%   34.7%
   6 minic_dev                      90      18     928   62.7%   36.0%
   7 minic_0.80                     62      19     930   58.9%   32.4%
   8 asymptote_v0.6                 59      19     928   58.4%   28.4%
   9 minic_0.76                     42      18     929   56.0%   33.3%
  10 ruy-1.1.9                      27      19     929   53.8%   27.8%
  11 igel_1.8.3                    -13      19     930   48.1%   28.4%
  12 minic_0.65                    -57      19     930   41.9%   28.7%
  13 minic_0.47                    -67      20     930   40.5%   25.1%
  14 redqueen-1.1.98               -74      20     928   39.5%   23.5%
  15 minic_0.57                    -98      19     928   36.3%   27.5%
  16 igel_1.7                     -101      20     929   35.9%   26.2%
  17 GreKo                        -162      21     930   28.3%   20.2%
  18 Fridolin310                  -166      21     929   27.8%   21.9%
  19 asymptote-v0.4.2             -202      23     929   23.8%   18.5%
Max
Posts: 247
Joined: Tue Apr 13, 2010 10:41 am

Re: A complete 2000 lines of code engine

Post by Max »

Nice progress! :)

STS test suite shows it too.

Code: Select all

STS	engine
-------------------------
..
2624  Zurichess Neuchatel
2610  Fruit 3.21 Reloaded
2595  Minic 0.87
..
2487  Minic 0.82
..
2412  Minic 0.76
2407  DanaSah 6.50
..
Hope we're not just the biological boot loader for digital super intelligence. Unfortunately, that is increasingly probable - Elon Musk