OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by OliverBr »

Dear community,

over a decade ago I made the last changes to my chess engine OliThink (http://brausch.org/home/chess).
Now I am announcing OliThink 5.4.0 http://brausch.org/home/chess/OliThink540.src.zip.
It has 2 important changes:

-"Analyze Mode"
-A code change that improved it over 100 ELO and it's only a few lines.


Technical background:
It's about the evaluation of "no mating material = draw". Prior to 5.4.0 this was the evaluation in evalc():

Code: Select all

> 	if (*sf <= 3 && !(pieceb[PAWN] & colorb[c])) mn = -200; //No mating material
(*sf containing a number for the non-pawn-pieces (N=2, B=3, R=5, Q=9) and (pieceb[PAWN] & colorb[c]) == 0 means the are no pawns for the resp. side.
mn contains the position evaluation of mobility. The idea being to reduce any material advantage to a more "drawish" score.

Actually this was quite imprecise. Moreover it doesn't respect more complex positions like "KNN vs k", which are draw, so I changed this.
It's known, that the following combinations are theoretical draws:
KN vs k (2 vs 0)
KB vs k (3 vs 0)
KNN vs k (4 vs 0)
KR vs kx (5 vs s > 0) (except rare positions, which can be detected tactically)

To present this logic, I defined this function with s and t counting pieces (N=2, B=3, R=5, Q=9):

Code: Select all

< #define NOMATEMAT(s, t, c) ((s <= 4 || (s == 5 && t > 0)) && (pieceb[PAWN] & colorb[c]) == 0)
Then I used it in the method eval() where white and black piece evaluations are combined:

Code: Select all

< 	if ((w > 0 && NOMATEMAT(sf1, sf0, 1)) || (w < 0 && NOMATEMAT(sf0, sf1, 0)))
< 		w = kmobil[kingpos[1]] - kmobil[kingpos[0]];
So, if either
1) w > 0, not having enough material, reduced w to about 0*.
2) w < 0, opponent not having enough material, increase w to about 0*.

*It's no good idea to use exact 0, because the king will jump completely randomly over the board, which could lead to a lucky mate in "RNK vs rk", which actually happened.


The most surprising part is the fact that this change of 3 lines improved the strength dramastically.
This was not to expected as most matches won't end in the position with no mating material, but of course a lot of principal variations do.

-Oliver
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by Dann Corbit »

It is a happy day when a new Olithink arrives.
Now we wait for lazy SMP.
;-)
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by OliverBr »

Dann Corbit wrote: Tue Jun 16, 2020 6:24 pm It is a happy day when a new Olithink arrives.
Now we wait for lazy SMP.
;-)
Hi Dann,
Lazy SMP is far away, when still bugs exists like playing Kf1 here on ply15. All those zeros are nonsense, too, because black won't do the repetition.

[d]8/8/8/5k2/5p2/4q3/4K3/4R2R w - - 14 135

Code: Select all

 ./olithink540 
force
setboard 8/8/8/5k2/5p2/4q3/4K3/4R2R w - - 14 135
analyze
 1    -9      0         3  e2d1 
 2   -11      0       107  e2d1 e3c3 
 3    -9      0      1005  e2f1 e3d3 f1f2 d3g3 f2f1 
 4   -28      0      3501  e2d1 e3d3 d1c1 d3c3 c1b1 f4f3 
 5    -7      0      9111  e2d1 e3d3 d1c1 d3c3 c1b1 c3b3 b1a1 f4f3 
 6   -27      0     20514  e2d1 e3d3 d1c1 f4f3 h1h5 f5g4 h5h2 d3c3 c1d1 
 7     0      1     58780  e2f1 e3f3 f1g1 f3g3 g1f1 g3d3 f1f2 d3g3 f2f1 
 8     0      1     80750  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
 9     0      3    154499  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
10     0      5    256085  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
11     0     10    452480  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
12     0     42   1933782  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
13     0     64   2999141  e2f1 e3d3 f1f2 d3g3 f2f1 g3f3 f1g1 f3g3 g1f1 
14   -90    478  25154780  e2d1 e3d3 d1c1 f4f3 h1f1 f5g6 f1g1 g6f7 g1f1 f7f6 e1d1 d3e3 c1b1 e3b6 b1c2 f3f2 d1e1 f6g5 
15     0   1162  59682377  e2f1 e3d3 f1f2 d3g3 f2f1 f4f3 h1g1 g3h2 g1g7 h2h1 g7g1 h1h2 
16   -97   3570 195944937  e2d1 e3d3 d1c1 f4f3 h1f1 f5f4 c1b2 d3d2 b2b3 f3f2 e1c1 d2d3 b3b4 d3e2 b4a5 e2d2 a5a6 d2d3 a6a7 d3d7 a7a8 d7d8 a8a7 
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
Pio
Posts: 334
Joined: Sat Feb 25, 2012 10:42 pm
Location: Stockholm

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by Pio »

OliverBr wrote: Tue Jun 16, 2020 11:29 pm
Dann Corbit wrote: Tue Jun 16, 2020 6:24 pm It is a happy day when a new Olithink arrives.
Now we wait for lazy SMP.
;-)
Hi Dann,
Lazy SMP is far away, when still bugs exists like playing Kf1 here on ply15. All those zeros are nonsense, too, because black won't do the repetition.

[d]8/8/8/5k2/5p2/4q3/4K3/4R2R w - - 14 135

Code: Select all

 ./olithink540 
force
setboard 8/8/8/5k2/5p2/4q3/4K3/4R2R w - - 14 135
analyze
 1    -9      0         3  e2d1 
 2   -11      0       107  e2d1 e3c3 
 3    -9      0      1005  e2f1 e3d3 f1f2 d3g3 f2f1 
 4   -28      0      3501  e2d1 e3d3 d1c1 d3c3 c1b1 f4f3 
 5    -7      0      9111  e2d1 e3d3 d1c1 d3c3 c1b1 c3b3 b1a1 f4f3 
 6   -27      0     20514  e2d1 e3d3 d1c1 f4f3 h1h5 f5g4 h5h2 d3c3 c1d1 
 7     0      1     58780  e2f1 e3f3 f1g1 f3g3 g1f1 g3d3 f1f2 d3g3 f2f1 
 8     0      1     80750  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
 9     0      3    154499  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
10     0      5    256085  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
11     0     10    452480  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
12     0     42   1933782  e2f1 e3f3 f1g1 f3g3 g1f1 g3f3 
13     0     64   2999141  e2f1 e3d3 f1f2 d3g3 f2f1 g3f3 f1g1 f3g3 g1f1 
14   -90    478  25154780  e2d1 e3d3 d1c1 f4f3 h1f1 f5g6 f1g1 g6f7 g1f1 f7f6 e1d1 d3e3 c1b1 e3b6 b1c2 f3f2 d1e1 f6g5 
15     0   1162  59682377  e2f1 e3d3 f1f2 d3g3 f2f1 f4f3 h1g1 g3h2 g1g7 h2h1 g7g1 h1h2 
16   -97   3570 195944937  e2d1 e3d3 d1c1 f4f3 h1f1 f5f4 c1b2 d3d2 b2b3 f3f2 e1c1 d2d3 b3b4 d3e2 b4a5 e2d2 a5a6 d2d3 a6a7 d3d7 a7a8 d7d8 a8a7 
Hi Oliver!

What I am guessing is happening between depth 14 and 15 is that your engine finds a repetition in the e2d1 line which might not be so strange in this position because of all the checking opportunities. The problem seems to be that it will change its mind to prefer the e2f1-line with the same score. After it has changed its mind (which I think is a bug since it should only prefer a better move) I guess the second problem is that it will look on the e2f1-line a lot shorter maybe because of some PV extension but I am just guessing

/Pio
OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by OliverBr »

OliThink 5.4.1 is now available at http://brausch.org/home/chess!
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
Gabor Szots
Posts: 1362
Joined: Sat Jul 21, 2018 7:43 am
Location: Szentendre, Hungary
Full name: Gabor Szots

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by Gabor Szots »

Hi Oliver,

I have just been made aware of your post but a test gauntlet with 5.4.0 is already running anyway. I am happy you are back with OliThink.
Gabor Szots
CCRL testing group
OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by OliverBr »

Hi Gabor,
OliThink is evaluating, as we speak. Version 5.4.2 has been published.
Here is an example (31. Rc4!!)

[pgn][Event "Computer Chess Game"]
[Site "Olivers-MacBook-2.local"]
[Date "2020.06.20"]
[Round "11"]
[White "OliThink 5.4.2"]
[Black "Fruit 2.1"]
[Result "1-0"]
[TimeControl "40/60"]
[Annotator "10. -0.48 9... -0.18"]

1. d4 Nf6 2. Bg5 g6 3. Bxf6 exf6 4. h4 f5 5. h5 Bg7 6. e3 d6 7. Bc4 Nd7 8.
Ne2 Nb6 9. Qd3 a5 10. h6 Bf8 11. d5 Bd7 12. Bb5 Be7 13. Bxd7+ Qxd7 14. Qd4
O-O-O 15. Nbc3 Kb8 16. a4 Rde8 17. Nb5 Bg5 18. O-O-O Rhg8 19. b3 Re4 20.
Qd2 f4 21. Nxf4 Bxf4 22. exf4 Qf5 23. Qc3 Qxf4+ 24. Kb1 Re7 25. Qxa5 Nc8
26. f3 Rge8 27. Rd4 Qg3 28. Re4 Qxg2 29. Rhe1 Qg5 30. Ka2 Qf6 31. Rc4 Rg8
32. Rxe7 Qxe7 33. Rxc7 Qd8 34. c4 g5 35. c5 dxc5 36. d6 Qxd6 37. Rxc8+ Kxc8
38. Nxd6+ Kd7 39. Nxb7 Kc6 40. Qb5+ Kc7 41. Nxc5 Rd8 42. Qb7+ Kd6 43. Qb6+
Ke5 44. Qxd8 Kf4 45. Qf6+ Ke3 46. Qxg5+ Kf2 47. Qf5 f6 48. Ne4+ Ke2 49.
Qxf6 Ke3 50. Qc3+ Ke2 51. f4 Kf1 *[/pgn]
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by OliverBr »

@Gabor,
I recommend to use 5.4.2 in the tournament, because this is actually the best OliThink ever. Not only in the result, but also in "how".

[pgn]
[Event "Computer Chess Game"]
[Site "Olivers-MacBook-2.local"]
[Date "2020.06.20"]
[Round "25"]
[White "OliThink 5.4.2"]
[Black "Fruit 2.1"]
[Result "1-0"]
[TimeControl "40/60"]
[Annotator "8. +0.37 8... -0.93"]

1. e4 e6 2. Nf3 b6 3. d4 Bb7 4. Nc3 d6 5. Bd3 Nd7 6. O-O g6 7. Bg5 Ne7 8.
Qe2 Bg7 9. Ba6 Bxa6 10. Qxa6 O-O 11. Qc4 c5 12. Rad1 cxd4 13. Nxd4 Rc8 14.
Qe2 h6 15. Bc1 d5 16. exd5 Nxd5 17. Ncb5 Ne5 18. f4 Nc4 19. Nxa7 Rc5 20.
Nb3 Rc7 21. Nb5 Rc8 22. N3d4 Qd7 23. Kh1 Bxd4 24. Nxd4 Rfd8 25. h3 Qa7 26.
a3 Kh7 27. g4 Qa8 28. Kh2 Rd7 29. Rf3 Qa7 30. h4 Rdd8 31. h5 gxh5 32. g5
Qc7 33. Kg1 h4 34. Qe4+ Kg8 35. f5 e5 36. gxh6 exd4 37. Qg4+ Kf8 38. f6
Nxf6 39. Qg7+ Ke8 40. Bg5 Ne3 41. Rxe3+ Kd7 42. Qxf6 Qd6 43. Rxd4 Kc6 44.
Qf3+ Kb5 45. Rb3+ Ka5 46. Bd2+ Rc3 47. Bxc3+
*

[/pgn]
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by Dann Corbit »

Absolutely incredible that such a tiny program can beat Fruit in the ring.
The only comparable is pocket Hercules:
https://en.wikipedia.org/wiki/Naim_S%C3 ... no%C4%9Flu
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: OliThink 5.4.0 has been published with an big leap in strength for only 3 lines of code

Post by OliverBr »

To be fair, Fruit still wins most of the games, especially with larger time control.

PS: Thank you for the pocket Hercules link :o
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink