Sapeli 1.0 - New chess engine

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

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
Roland Chastain
Posts: 203
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Re: Sapeli 1.0 - New chess engine

Post by Roland Chastain » Sun May 26, 2019 12:45 pm

I compiled v1.15 and ran "suite 6" without crash. Now I will try a tournament and tell you what happens.

User avatar
Roland Chastain
Posts: 203
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Re: Sapeli 1.0 - New chess engine

Post by Roland Chastain » Sun May 26, 2019 4:39 pm

Here is a command that makes Sapeli crash:

Code: Select all

setoption name UCI_Chess960 value true
position fen rbnnqkbr/pppppppp/8/8/8/8/PPPPPPPP/RBNNQKBR w HAha - 0 1 moves e2e3 c7c5 d2d3 b8e5 f2f4 e5f6 g1f2 c8d6 e3e4 d8e6 e4e5 e6f4 e5f6 e7f6 f2c5 e8e1 f1e1 f4g2 e1f2 a8e8 c5d6 e8e7 f2g2 h7h5 h1e1 g8h7 e1e7 h7f5 e7e5 f8g8 e5f5 h8h6 g2f1 b7b6 d6b8 a7a5 b8c7 d7d5 c7b6 h6g6 f5d5 f6f5 b6a5 g6f6 a5c3 f6e6 d5f5 h5h4 f5h5 e6h6 h5h6 g7h6 c3f6 h4h3 d1f2 g8f8 f2h3 f8e8 f6g7 h6h5 h3f4 h5h4 c1b3 e8e7 f1g1 f7f6 b3d4 e7f7 d4f5 h4h3 a2a3 f7e8 b1a2 e8d7 a2d5 d7d8 f4h3 d8d7 g7f6 d7c7 h3f4 c7d7 a1e1 d7c7 e1e8 c7d7
go wtime 36976 btime 79588 movestogo 37
Sapeli's output:

Code: Select all

info depth 0 nodes 130 time 0 nps 0 score cp 2749 pv e8b8
info depth 1 nodes 314 time 1 nps 314000 score cp 2734 pv e8b8
info depth 2 nodes 6354 time 13 nps 488769 score cp 2743 pv e8b8
info depth 3 nodes 15264 time 23 nps 663652 score cp 2746 pv e8b8
info depth 4 nodes 62089 time 76 nps 816960 score cp 2749 pv e8b8
info depth 5 nodes 67589 time 10 nps 6758900 score cp 2799 pv e8b8
info depth 6 nodes 68075 time 2 nps 34037500 score cp 2849 pv e8b8
info depth 7 nodes 68621 time 2 nps 34310500 score cp 2899 pv e8b8
info depth 8 nodes 69227 time 2 nps 34613500 score cp 2949 pv e8b8
info depth 9 nodes 69893 time 2 nps 34946500 score cp 2999 pv e8b8
info depth 10 nodes 70619 time 2 nps 35309500 score cp 3049 pv e8b8
info depth 11 nodes 71405 time 2 nps 35702500 score cp 3099 pv e8b8
info depth 12 nodes 72251 time 2 nps 36125500 score cp 3149 pv e8b8
info depth 13 nodes 73157 time 2 nps 36578500 score cp 3199 pv e8b8
info depth 14 nodes 74123 time 3 nps 24707666 score cp 3249 pv e8b8
info depth 15 nodes 75149 time 2 nps 37574500 score cp 3299 pv e8b8
info depth 16 nodes 76235 time 3 nps 25411666 score cp 3349 pv e8b8
info depth 17 nodes 77381 time 3 nps 25793666 score cp 3399 pv e8b8
info depth 18 nodes 78587 time 3 nps 26195666 score cp 3449 pv e8b8
info depth 19 nodes 79853 time 4 nps 19963250 score cp 3499 pv e8b8
info depth 20 nodes 81179 time 3 nps 27059666 score cp 3549 pv e8b8
info depth 21 nodes 82561 time 3 nps 27520333 score cp 3599 pv e8b8
info depth 22 nodes 84001 time 4 nps 21000250 score cp 3649 pv e8b8
info depth 23 nodes 85499 time 4 nps 21374750 score cp 3699 pv e8b8
info depth 24 nodes 87055 time 4 nps 21763750 score cp 3749 pv e8b8
info depth 25 nodes 88669 time 5 nps 17733800 score cp 3799 pv e8b8
info depth 26 nodes 90341 time 5 nps 18068200 score cp 3849 pv e8b8
info depth 27 nodes 92071 time 5 nps 18414200 score cp 3899 pv e8b8
info depth 28 nodes 93859 time 5 nps 18771800 score cp 3949 pv e8b8
info depth 29 nodes 95705 time 5 nps 19141000 score cp 3999 pv e8b8
info depth 30 nodes 97609 time 6 nps 16268166 score cp 4049 pv e8b8
info depth 31 nodes 99569 time 5 nps 19913800 score cp 4099 pv e8b8
info depth 32 nodes 101586 time 5 nps 20317200 score cp 4149 pv e8b8
info depth 33 nodes 103660 time 6 nps 17276666 score cp 4199 pv e8b8
info depth 34 nodes 105791 time 6 nps 17631833 score cp 4249 pv e8b8
info depth 35 nodes 107963 time 6 nps 17993833 score cp 4299 pv e8b8
info depth 36 nodes 110184 time 6 nps 18364000 score cp 4349 pv e8b8
info depth 37 nodes 112452 time 6 nps 18742000 score cp 4399 pv e8b8
info depth 38 nodes 114768 time 6 nps 19128000 score cp 4449 pv e8b8
info depth 39 nodes 117128 time 6 nps 19521333 score cp 4499 pv e8b8
info depth 40 nodes 119534 time 6 nps 19922333 score cp 4549 pv e8b8
info depth 41 nodes 121984 time 6 nps 20330666 score cp 4599 pv e8b8
info depth 42 nodes 124479 time 7 nps 17782714 score cp 4649 pv e8b8
      1 [] Sapeli 820 cygwin_exception::open_stackdumpfile: Dumping stack trace to Sapeli.exe.stackdump
It's v1.15, compiled by myself (without -DNDEBUG option, as you suggested). :wink:

JohnWoe
Posts: 92
Joined: Sat Mar 02, 2013 10:31 pm

Re: Sapeli 1.0 - New chess engine

Post by JohnWoe » Sun May 26, 2019 6:02 pm

Thanks for the feedback!

I couldn't reproduce that bug on my Linux machine. All I get this:

Code: Select all

setoption name UCI_Chess960 value true
position fen rbnnqkbr/pppppppp/8/8/8/8/PPPPPPPP/RBNNQKBR w HAha - 0 1 moves e2e3 c7c5 d2d3 b8e5 f2f4 e5f6 g1f2 c8d6 e3e4 d8e6 e4e5 e6f4 e5f6 e7f6 f2c5 e8e1 f1e1 f4g2 e1f2 a8e8 c5d6 e8e7 f2g2 h7h5 h1e1 g8h7 e1e7 h7f5 e7e5 f8g8 e5f5 h8h6 g2f1 b7b6 d6b8 a7a5 b8c7 d7d5 c7b6 h6g6 f5d5 f6f5 b6a5 g6f6 a5c3 f6e6 d5f5 h5h4 f5h5 e6h6 h5h6 g7h6 c3f6 h4h3 d1f2 g8f8 f2h3 f8e8 f6g7 h6h5 h3f4 h5h4 c1b3 e8e7 f1g1 f7f6 b3d4 e7f7 d4f5 h4h3 a2a3 f7e8 b1a2 e8d7 a2d5 d7d8 f4h3 d8d7 g7f6 d7c7 h3f4 c7d7 a1e1 d7c7 e1e8 c7d7
go wtime 36976 btime 79588 movestogo 37
info depth 0 nodes 130 time 0 nps 0 score cp 2746 pv e8b8
info depth 1 nodes 314 time 0 nps 0 score cp 2731 pv e8b8
info depth 2 nodes 6322 time 0 nps 0 score cp 2740 pv e8b8
info depth 3 nodes 15228 time 2 nps 7614000 score cp 2743 pv e8b8
info depth 4 nodes 62048 time 7 nps 8864000 score cp 2746 pv e8b8
info depth 5 nodes 67527 time 1 nps 67527000 score cp 2796 pv e8b8
info depth 6 nodes 68013 time 0 nps 0 score cp 2846 pv e8b8
info depth 7 nodes 68559 time 1 nps 68559000 score cp 2896 pv e8b8
info depth 8 nodes 69165 time 1 nps 69165000 score cp 2946 pv e8b8
info depth 9 nodes 69831 time 0 nps 0 score cp 2996 pv e8b8
info depth 10 nodes 70557 time 1 nps 70557000 score cp 3046 pv e8b8
info depth 11 nodes 71343 time 1 nps 71343000 score cp 3096 pv e8b8
info depth 12 nodes 72189 time 0 nps 0 score cp 3146 pv e8b8
info depth 13 nodes 73095 time 0 nps 0 score cp 3196 pv e8b8
info depth 14 nodes 74061 time 1 nps 74061000 score cp 3246 pv e8b8
info depth 15 nodes 75087 time 1 nps 75087000 score cp 3296 pv e8b8
info depth 16 nodes 76173 time 2 nps 38086500 score cp 3346 pv e8b8
info depth 17 nodes 77319 time 1 nps 77319000 score cp 3396 pv e8b8
info depth 18 nodes 78525 time 1 nps 78525000 score cp 3446 pv e8b8
info depth 19 nodes 79791 time 1 nps 79791000 score cp 3496 pv e8b8
info depth 20 nodes 81117 time 2 nps 40558500 score cp 3546 pv e8b8
info depth 21 nodes 82499 time 1 nps 82499000 score cp 3596 pv e8b8
info depth 22 nodes 83939 time 2 nps 41969500 score cp 3646 pv e8b8
info depth 23 nodes 85437 time 1 nps 85437000 score cp 3696 pv e8b8
info depth 24 nodes 86993 time 2 nps 43496500 score cp 3746 pv e8b8
info depth 25 nodes 88607 time 2 nps 44303500 score cp 3796 pv e8b8
info depth 26 nodes 90279 time 2 nps 45139500 score cp 3846 pv e8b8
info depth 27 nodes 92009 time 1 nps 92009000 score cp 3896 pv e8b8
info depth 28 nodes 93797 time 2 nps 46898500 score cp 3946 pv e8b8
info depth 29 nodes 95643 time 2 nps 47821500 score cp 3996 pv e8b8
info depth 30 nodes 97547 time 3 nps 32515666 score cp 4046 pv e8b8
info depth 31 nodes 99507 time 2 nps 49753500 score cp 4096 pv e8b8
info depth 32 nodes 101524 time 2 nps 50762000 score cp 4146 pv e8b8
info depth 33 nodes 103598 time 2 nps 51799000 score cp 4196 pv e8b8
info depth 34 nodes 105729 time 3 nps 35243000 score cp 4246 pv e8b8
info depth 35 nodes 107901 time 2 nps 53950500 score cp 4296 pv e8b8
info depth 36 nodes 110122 time 3 nps 36707333 score cp 4346 pv e8b8
info depth 37 nodes 112390 time 3 nps 37463333 score cp 4396 pv e8b8
info depth 38 nodes 114706 time 3 nps 38235333 score cp 4446 pv e8b8
info depth 39 nodes 117066 time 2 nps 58533000 score cp 4496 pv e8b8
info depth 40 nodes 119472 time 2 nps 59736000 score cp 4546 pv e8b8
info depth 41 nodes 121922 time 3 nps 40640666 score cp 4596 pv e8b8
info depth 42 nodes 124417 time 3 nps 41472333 score cp 4646 pv e8b8
info depth 43 nodes 126957 time 3 nps 42319000 score cp 4696 pv e8b8
info depth 44 nodes 129542 time 3 nps 43180666 score cp 4746 pv e8b8
info depth 45 nodes 132172 time 4 nps 33043000 score cp 4796 pv e8b8
info depth 46 nodes 134847 time 3 nps 44949000 score cp 4846 pv e8b8
info depth 47 nodes 137567 time 4 nps 34391750 score cp 4896 pv e8b8
info depth 48 nodes 140332 time 4 nps 35083000 score cp 4946 pv e8b8
info depth 49 nodes 143142 time 3 nps 47714000 score cp 4996 pv e8b8
info depth 50 nodes 145997 time 4 nps 36499250 score cp 5046 pv e8b8
info depth 51 nodes 145997 time 99 nps 1474717 score cp 5046 pv e8b8
bestmove e8b8
exit
But I think where the problem might be. It is this stack frame variables getting clobbered between longjmps. I made a reference to BRD. Now I copy the whole thing. I used to think about it some time ago. I knew it would bite me in the ass at some point. :lol:

Found this with -Wextra
Sapeli now compiles 0 errors 0 warnings.

Code: Select all

-Wall -pedantic -Wextra
Sapeli 1.16 contains the fix:
https://github.com/SamuraiDangyo/Sapeli/tree/1.16

Quick test.

Code: Select all

Score of Sapeli 1.16 vs Fairy-Max 5.0b: 862 - 62 - 76  [0.900] 1000
Elo difference: 381.70 +/- 32.10
If it still crashes I need to check those tables really carefully.

User avatar
Roland Chastain
Posts: 203
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Re: Sapeli 1.0 - New chess engine

Post by Roland Chastain » Sun May 26, 2019 7:17 pm

Sorry, but it still crashes at the same place with the same command. :?

Regards.

Roland

JohnWoe
Posts: 92
Joined: Sat Mar 02, 2013 10:31 pm

Re: Sapeli 1.0 - New chess engine

Post by JohnWoe » Mon May 27, 2019 6:46 am

Thanks for the feedback!

In short there was no bug! Although fixing that longjmp clobbering was needed. That was a bug. Now, absolutely no warnings whatsoever.

I provided a fix: https://github.com/SamuraiDangyo/Sapeli/tree/1.16
Not a release yet.

Quick test:

Code: Select all

Score of Sapeli 1.16 vs Fairy-Max 5.0b: 881 - 50 - 69  [0.915] 1000
Elo difference: 413.92 +/- 34.42
Finished match
I was able to find this "bug". The bug is the stack size. My Linux box has 8192KB limit.

This is the bug:
https://github.com/SamuraiDangyo/Sapeli ... ck_limit.c

Code: Select all

/**
*
* How `segmention fault´ happens in Sapeli. Stack limit reached.
*
**/

#include <stdio.h>
#include <stdlib.h>
 
 
//
// aaa: depth 254 -> Segmentation fault (core dumped)
//
void aaa(int depth)
{
	char s[32768] = "";
	printf("aaa: depth %i\n", depth);
	aaa(depth + 1);
}

//
// bbb: depth 1015 -> Segmentation fault (core dumped)
//
void bbb(int depth)
{
	char s[32768 / 4] = "";
	printf("bbb: depth %i\n", depth);
	bbb(depth + 1);
}

int main(int argc, char **argv)
{
	//aaa(0);
	bbb(0);
	return EXIT_SUCCESS;
}
As you can see the stack size limit is reached. Then it starts overlapping in memory and segfault happens. There's no bug.

Sapeli has pretty heavy "move generation". Sapeli actually doesn't generate moves at all. Sapeli generates full boards.

That's much simpler method than make-unmake or copy-make. But it makes "move generation" much heavier.

As a side effect of that. Stack size limit is reached pretty easily.

User avatar
Roland Chastain
Posts: 203
Joined: Sat Jun 08, 2013 8:07 am
Location: France
Full name: Roland Chastain
Contact:

Re: Sapeli 1.0 - New chess engine

Post by Roland Chastain » Mon May 27, 2019 6:33 pm

JohnWoe wrote:
Mon May 27, 2019 6:46 am
Thanks for the feedback!
You're welcome. Congratulations, it works now. :wink:

JohnWoe
Posts: 92
Joined: Sat Mar 02, 2013 10:31 pm

Re: Sapeli 1.0 - New chess engine

Post by JohnWoe » Tue May 28, 2019 10:04 pm

I released a new version Sapeli 1.16
Source code: https://github.com/SamuraiDangyo/Sapeli/tree/1.16-final
Release: https://github.com/SamuraiDangyo/Sapeli ... s/tag/1.16

This is a bug fix version. Thanks for Roland Chastain reporting this nasty stack size limit bug. At some point I increased maxdepth limit. Eventho Sapeli won't reach high depths anyway. If it's not broken don't fix it!

Tried to build Sapeli with g++. No chance!
clang actually builds Sapeli, but the binary is super slow.
gcc is doing great job.

Although some improvements have been done in eval. Plus profilebuild option added. Profiled build is 500knps faster. Quite the difference!

make build

Code: Select all

./sapeli bench
~~~ Bench() ~~~
info depth 0 nodes 40 time 0 nps 0 score cp 51 pv e2e3
info depth 1 nodes 264 time 1 nps 264000 score cp 0 pv e2e3
info depth 2 nodes 3130 time 5 nps 626000 score cp 39 pv d2d4
info depth 3 nodes 7057 time 9 nps 784111 score cp 3 pv d2d4
info depth 4 nodes 25964 time 41 nps 633268 score cp 16 pv d2d4
info depth 5 nodes 164269 time 198 nps 829641 score cp 3 pv e2e4
info depth 6 nodes 308229 time 145 nps 2125717 score cp 14 pv e2e4
info depth 7 nodes 1455822 time 664 nps 2192503 score cp 14 pv e2e4
info depth 8 nodes 8499688 time 3532 nps 2406480 score cp 41 pv g1f3
info depth 9 nodes 21295570 time 6786 nps 3138162 score cp 11 pv e2e3
info depth 10 nodes 57053236 time 22783 nps 2504202 score cp 28 pv e2e3
info depth 11 nodes 105540480 time 34164 nps 3089230 score cp 28 pv e2e3
nodes 105540480 mnps 1.759 time 60.001
make profilebuild

Code: Select all

./sapeli_1_16_linux_64bit -bench
~~~ Bench() ~~~
info depth 0 nodes 40 time 0 nps 0 score cp 51 pv e2e3
info depth 1 nodes 264 time 0 nps 0 score cp 0 pv e2e3
info depth 2 nodes 3130 time 6 nps 521666 score cp 39 pv d2d4
info depth 3 nodes 7055 time 8 nps 881875 score cp 3 pv d2d4
info depth 4 nodes 25936 time 41 nps 632585 score cp 16 pv d2d4
info depth 5 nodes 148365 time 173 nps 857601 score cp 4 pv e2e4
info depth 6 nodes 302694 time 148 nps 2045229 score cp 14 pv e2e4
info depth 7 nodes 1459248 time 604 nps 2415973 score cp 14 pv e2e4
info depth 8 nodes 8506422 time 3167 nps 2685955 score cp 40 pv g1f3
info depth 9 nodes 21554993 time 5962 nps 3615396 score cp 11 pv e2e3
info depth 10 nodes 56645256 time 15002 nps 3775846 score cp 28 pv e2e3
info depth 11 nodes 134230756 time 25111 nps 5345496 score cp 28 pv e2e3
nodes 134230756 mnps 2.237 time 60.001
Roland Chastain wrote:
Mon May 27, 2019 6:33 pm
JohnWoe wrote:
Mon May 27, 2019 6:46 am
Thanks for the feedback!
You're welcome. Congratulations, it works now. :wink:
Thanks! It was quite tough bug to find out.

tpoppins
Posts: 919
Joined: Tue Nov 24, 2015 8:11 pm
Location: upstate

Re: Sapeli 1.0 - New chess engine

Post by tpoppins » Wed May 29, 2019 3:05 am

Windoze bins for v1.16 posted in the New engine releases 2019 thread.

Toni, would you take a look at Dann Corbit's modifications that enabled building under MSYS2/MinGW for v1.02? I'm not particularly fond of Cygwin and its intentional inability to generate truly static builds.
Tirsa Poppins
CCRL

Modern Times
Posts: 2387
Joined: Thu Jun 07, 2012 9:02 pm

Re: Sapeli 1.0 - New chess engine

Post by Modern Times » Wed May 29, 2019 4:09 am

Roughly how much stronger do you estimate 1.16 to be vs 1.02 ?
.

Opinions expressed here are my own, and not necessarily those of the CCRL Group.

JohnWoe
Posts: 92
Joined: Sat Mar 02, 2013 10:31 pm

Re: Sapeli 1.0 - New chess engine

Post by JohnWoe » Wed May 29, 2019 10:52 am

Modern Times wrote:
Wed May 29, 2019 4:09 am
Roughly how much stronger do you estimate 1.16 to be vs 1.02 ?
I don't think 1.16 is stronger. I think Sapeli 1.02 is the strongest Sapeli version yet. But 1.16 is the most stable version yet. Although 1.02 is very stable. But -Wextra gave some warnings which has been cleaned out in 1.16.

This recent development has been just fixing potential bugs, cleaning up the code base and documenting. Ok I have written a tuner for Sapeli.


I think the problem is Sapeli 1.02 is ticking much faster. 1.02 is searching 2.7 mnps while 1.16 is searching only 1.7 mnps. That makes a huge difference. But I think Sapeli 1.16 has much better evaluation right now.

Somehow Sapeli has even lost ( +11 mnps ) mgen speed eventho I haven't touched that code it pretty much at all. Maybe this new binary is somehow not good. I need to test more.

I need to speed up Sapeli 1.17 to at least 1.02 version level and the strength will come back.

This is Sapeli 1.02 vs Sapeli 1.16.

+ 40moves / 1 second
+ 40moves / 100 milliseconds
+ -bench
+ -suite 5

Code: Select all

tc=40/1
Score of Sapeli 1.16 vs Sapeli 1.02: 31 - 60 - 9  [0.355] 100
Elo difference: -103.73 +/- 68.57
Finished match

tc=40/.1
Score of Sapeli 1.16 vs Sapeli 1.02: 91 - 126 - 25  [0.428] 242
Elo difference: -50.60 +/- 42.00
Finished match

Sapeli 1.02
-bench
nodes 159304027 mnps 2.655 time 60.000
-suite 5
nodes 875605409 mnps 31.420 time 27.868

Sapeli 1.16
-bench
nodes 105540480 mnps 1.759 time 60.001
-suite 5
nodes 875605409 mnps 20.080 time 43.606

Post Reply