Sapeli 1.0 - New chess engine

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

Moderators: hgm, Rebel, chrisw

JohnWoe
Posts: 491
Joined: Sat Mar 02, 2013 11:31 pm

Re: Sapeli 1.0 - New chess engine

Post by JohnWoe »

I was watching Sapeli play fairymax on xboard. It couldn't convert KQkr 2 times.
Fixed that issue very simply.
Sapeli needed a bit more help in eval: https://github.com/SamuraiDangyo/Sapeli ... li.c#L2176
Results: https://lichess.org/e63W8n6Z

KNBk is not a problem: https://lichess.org/lhVnf1tD#0

But there was a bug in move generator in chess960 games.
Fixed and ran tons of chess960 games against Stockfish.
To make sure there's no bugs.
Seems to work fine now.
# tc=40/.1: Score of Sapeli 1.01 vs Stockfish 8 64: 981 - 19 - 0 [0.981] 1000
# tc=40/.15: Score of Sapeli 1.01 vs Stockfish 8 64: 936 - 64 - 0 [0.936] 1000
# tc=40/.3: Score of Sapeli 1.01 vs Stockfish 8 64: 54 - 46 - 0 [0.540] 100
# tc=40/.5: Score of Sapeli 1.01 vs Stockfish 8 64: 2 - 98 - 0 [0.020] 100
In longer games Stockfish is too tough. But Sapeli is a fast bean counter in super short games.

I tested some optimizations on Sapeli perft suite:
# none: nodes 875605409 mnps 9.217 time 95.002
# -O1: nodes 875605409 mnps 21.030 time 41.637
# -O2: nodes 875605409 mnps 22.524 time 38.875
# -O3: nodes 875605409 mnps 22.020 time 39.765
# -Ofast: nodes 875605409 mnps 21.838 time 40.095
# -Ofast -march=native:
# nodes 875605409 mnps 21.051 time 41.594

I made a release. Which contains only source code. It should now be stable.
https://github.com/SamuraiDangyo/Sapeli ... apeli-1.01
tpoppins
Posts: 919
Joined: Tue Nov 24, 2015 9:11 pm
Location: upstate

Re: Sapeli 1.0 - New chess engine

Post by tpoppins »

Sapeli 1.01 POPCNT and SSE3 builds

Mediafire: sapeli-101-tp.zip
Filedropper: sapeli-101-tp.zip

The POPCNT build should work on Nehalem+
The SSE3 one should work on P4+
Tirsa Poppins
CCRL
tpoppins
Posts: 919
Joined: Tue Nov 24, 2015 9:11 pm
Location: upstate

Re: Sapeli 1.0 - New chess engine

Post by tpoppins »

BTW, Sapeli currently has a bug: it always reports eval from White's point of view. Anyone planning to include it in a tournament should disable GUI win/loss adjudication, otherwise Sapeli will be awarded zeroes for won games when playing Black.
Tirsa Poppins
CCRL
brianr
Posts: 536
Joined: Thu Mar 09, 2006 3:01 pm

Re: Sapeli 1.0 - New chess engine

Post by brianr »

Some would say reporting the score from white's point of view is a feature, not a bug.

Of course, many GUIs can handle this as an engine-specific option, provided people are aware of it when setting up the engine.

PS I happen to not like the white POV approach myself because the vast majority of engines do not do so.
tpoppins
Posts: 919
Joined: Tue Nov 24, 2015 9:11 pm
Location: upstate

Re: Sapeli 1.0 - New chess engine

Post by tpoppins »

brianr wrote: Wed Apr 24, 2019 12:01 pm Some would say reporting the score from white's point of view is a feature, not a bug.
It is a bug if the engine is UCI. The UCI specs are clear on this:

Code: Select all

* score
		* cp <x>
			the score from the engine's point of view in centipawns.
brianr wrote: Wed Apr 24, 2019 12:01 pmOf course, many GUIs can handle this as an engine-specific option,
Many? I'm aware of only one that offers it for UCI engines -- ChessGUI. I don't know if its "Flip black scores" actually works with UCI engines, but it's there. Arena and Cute Chess offer corresponding options for WB engines only.
brianr wrote: Wed Apr 24, 2019 12:01 pmPS I happen to not like the white POV approach myself because the vast majority of engines do not do so.
It's the other way around with me, but after years of testing engines I'm used to their "egocentric" evals. Hard to go against 20+ years of tradition.
Tirsa Poppins
CCRL
JohnWoe
Posts: 491
Joined: Sat Mar 02, 2013 11:31 pm

Re: Sapeli 1.0 - New chess engine

Post by JohnWoe »

Thanks for testing Sapeli!

I added your builds to the list.

Yes Sapeli reports absolute scores not relative. When black is winning I find evaluation -5.78 easier to understand than +5.78.
I tried this flipping and flopping scores but it was confusing as hell. Then I wrote separate code for white and black. And it seems to work fine.

But I made a temporary fix in 1.02 branch.
https://github.com/SamuraiDangyo/Sapeli/tree/1.02
A simple fix: https://github.com/SamuraiDangyo/Sapeli ... li.c#L2247

You can now install Sapeli. make install. Compile with -DNDEBUG flag..

I'm gonna add KOTH variant in Sapeli. I already have code for it. Then I will push it in to master and make a release.

But 1.02 branch is the most stable. No strength is added. Only improving code.

Testing relative scores Sapeli 1.02
###

./sapeli -setpos 8/2q5/3k4/8/8/8/8/6KR b - - 0 1 -search 10000
info depth 0 nodes 50 time 0 nps 0 score cp 664 pv d6d5
info depth 1 nodes 213 time 0 nps 0 score cp 654 pv c7c1
info depth 2 nodes 1492 time 2 nps 746000 score cp 691 pv d6d5
info depth 3 nodes 3864 time 4 nps 966000 score cp 702 pv d6d5
info depth 4 nodes 15736 time 18 nps 874222 score cp 711 pv d6d5
info depth 5 nodes 48197 time 46 nps 1047760 score cp 703 pv d6d5
info depth 6 nodes 169967 time 123 nps 1381845 score cp 748 pv d6d5
info depth 7 nodes 680753 time 317 nps 2147485 score cp 719 pv d6e5
info depth 8 nodes 1779643 time 564 nps 3155395 score cp 758 pv d6e5
info depth 9 nodes 4902015 time 1153 nps 4251530 score cp 748 pv d6e5
info depth 10 nodes 13418545 time 2536 nps 5291224 score cp 749 pv d6e5
info depth 11 nodes 41809997 time 7201 nps 5806137 score cp 749 pv d6e5
info depth 12 nodes 57757778 time 10000 nps 5775777 score cp 749 pv d6e5


./sapeli -setpos 8/2q5/3k4/8/8/8/8/6KR w - - 0 1 -search 10000
info depth 0 nodes 27 time 0 nps 0 score cp -608 pv g1f1
info depth 1 nodes 358 time 1 nps 358000 score cp -637 pv h1h5
info depth 2 nodes 788 time 1 nps 788000 score cp -637 pv h1h5
info depth 3 nodes 3721 time 6 nps 620166 score cp -637 pv h1h5
info depth 4 nodes 17936 time 21 nps 854095 score cp -646 pv g1f1
info depth 5 nodes 42135 time 46 nps 915978 score cp -654 pv h1h5
info depth 6 nodes 141108 time 120 nps 1175900 score cp -677 pv h1h5
info depth 7 nodes 377422 time 231 nps 1633861 score cp -693 pv h1h5
info depth 8 nodes 854398 time 379 nps 2254348 score cp -685 pv h1h5
info depth 9 nodes 4249156 time 1131 nps 3756990 score cp -710 pv g1f1
info depth 10 nodes 8261037 time 1879 nps 4396507 score cp -702 pv g1f1
info depth 11 nodes 19479319 time 3906 nps 4987024 score cp -717 pv g1f1
info depth 12 nodes 55223238 time 10000 nps 5522323 score cp -717 pv g1f1
tpoppins
Posts: 919
Joined: Tue Nov 24, 2015 9:11 pm
Location: upstate

Re: Sapeli 1.0 - New chess engine

Post by tpoppins »

Great, thank you for the prompt action, Toni. The new code works a treat!

Here are POPCNT and SSE3 builds for v1.02, with a minor modification.

Mediafire: sapeli-102-tp.zip
Filedropper: sapeli-102-tp.zip

Since you were so nice about it I decided to meet you halfway and hacked in a new UCI option, "WhitePOV". When enabled (it's off by default) it restores v1.0-1.01 behavior of always displaying the absolute score, i.e. the score from White's point of view. If you like it, there's a .diff patch included in the ZIP (please feel free to consider that a pull request ;)).
Tirsa Poppins
CCRL
JohnWoe
Posts: 491
Joined: Sat Mar 02, 2013 11:31 pm

Re: Sapeli 1.0 - New chess engine

Post by JohnWoe »

Thanks for the feedback tpoppins!

I looked at your diff and added WhitePOV option. I needed to think about it for a while. I think I found the solution. Default is relative. -DABSOLUTE_SCORE flag makes score absolute always.

I released it as 1.02: https://github.com/SamuraiDangyo/Sapeli ... /tag/v1.02
I'm on the 1.03 branch, hopefully for a long time before the next merge.

I merged 1.02 -> master.
https://github.com/SamuraiDangyo/Sapeli

This 1.02 version contains:
+ King of the hill variant.
+ King of the hill w/ chess 960 castling variant.
+ WhitePOV UCI option.
+ AiLevel UCI option. 0 = random mover 100 = 100% Sapeli
+ Small fixes. No strength is added.

You can play KOTH 960 against Sapeli on xboard by choosing FRC and KOTH UCI option.

KOTH 960 Sapeli vs Sapeli:
https://lichess.org/WDL76tFD

This 10% ai level is almost random mover. Funny game.
Sapeli 10% AI vs Fairymax:
https://lichess.org/XbqDuaFq
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Sapeli 1.0 - New chess engine

Post by Dann Corbit »

A primitive compile using make

I had to change some of the macros to make it compile.
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.
tpoppins
Posts: 919
Joined: Tue Nov 24, 2015 9:11 pm
Location: upstate

Re: Sapeli 1.0 - New chess engine

Post by tpoppins »

@Dann: you compile crashes on this Westmere box with an "Exception code: 0xc000001d" error. I guess it needs a Haswell or later. But your code changes enabled me to compile under MSYS2/MinGW at last -- thank you!

@Toni: thank you for the update. For me the most important part was this:
JohnWoe wrote: Thu Apr 25, 2019 11:51 pmThis 1.02 version contains:
[...]
+ AiLevel UCI option. 0 = random mover 100 = 100% Sapeli
Random movers are essential for establishing the lowest limit of a rating list. The few random movers I'm aware of -- Brutus RND, POS, ACE, CPP1 and NEG (I haven't tested Alouette yet) -- all have serious shortcomings that make using them in tests a PITA. Brutus cannot run more than a single instance (a mutex issue that was fixed in later versions of the standard engine but never backported for some reason), the others either have the Winboard promotion bug or are prone to stalling and time losses.

Sapeli, OTOH, appears to be extremely solid, specs-compliant and full-featured. In 300+ games of the ongoing 40/40 test I'm running it hasn't had a single crash or loss on time. Its random mode should make it the new anchor of the bottom of our blitz list.

Sapeli 1.02 final sapeli-102-final-tp.zip
Compiles: POPCNT, SSE3 and 32-bit -- fern and Ruxy take note.
Tirsa Poppins
CCRL