Open tissatussa opened 3 months ago
UPDATE while letting v0.6.5 play another game i see what's wrong with the eval "0.00 issue" : during the calculations no output is given, ALL output is displayed only AFTER the move is done, and the last eval isn't updated :
Amazing, @tissatussa. I appreciate your feedback, and I'm glad you've taken the time to play with my engine.
Yes, I've been meaning to update the readme to reflect the change regarding OpenBench and the addition of TranspositionTable. Also fix the ctest issue you mentioned in #4 and the binary locations and build targets.
I have spent quite some time on the time management logic for the engine, and I'm happy to hear you noticed it's changed.
The engine is indeed not very strong as of currently, and the depth is quite shallow, I would estimate it to be around 1300elo, hopefully with some clever evaluation changes and now that I've set up open bench locally I can work towards making it stronger.
I'm also going to look into that issue where the calculations aren't shown. I added these issues #7 & #6 to track these issues.
Also thank you for the well formated readme.md!
...I have spent quite some time on the time management logic for the engine...
i can imagine that .. did you use a second thread to accomplish this ? I follow the coding improvements of many engines (on GitHub by their notifications) and i read this is a good method : when "time's up" it should be possible to interrupt the calculation process and return the last found best move .. the strength of the engine depends a lot on its time efficiency when playing a game, maybe even try to determine (yes, but how?) if a position is "worth" calculating for a longer time, and moving instantly when only one move is possible .. compared to eg. KingSlayer its reached depth isn't high, this is also a main factor for being strong - i guess "smart pruning" is key here, skipping certain variations, all part of your HCE logic.
did you ever consider implementing MultiPV ? This feature is not only nice for the user when analysing a position, but also for the developer : see at which moment / depth the engine "starts realising" a certain move is best .. however, i have no clue how to change the code accordingly to make the evaluation better, because in chess many types of positions exist.
another remark : the engine does not have any UCI options, like Hash (for the TT) - which Mb amount do you use ? Can i change it in the code ? Maybe also the number of threads could be set (but i don't know the inner working of your engine). Such settings may easily improve the strength of the engine ..
here's my first serious game against v0.6.5, 15m10s. material in chess isn't the main thing, but your Elephant blew myself away ..
at the end the engine had 3m20s left on the clock, decent!
[Event "human vs engine"]
[Site "Holland @ https://lichess.org/BJsyOPKH "]
[Date "2024.06.01"]
[Round "1"]
[White "ElephantGambit v0.6.5"]
[Black "Roelof Berkepeis"]
[Result "1-0"]
[ECO "A04"]
[Opening "Reti Opening"]
[PlyCount "69"]
[Termination "adjudication"]
[TimeControl "900+10"]
1. Nf3 {0.00/8 48s} b6 {26s} 2. c4 {0.00/7 46s} Nc6 {80s} 3. Qc2 {0.00/7 45s}
e5 {13s} 4. Nxe5 {0.00/7 43s} Nb4 {103s} 5. Qf5 {0.00/7 42s} Nh6 {44s}
6. Qe4 {0.00/7 41s} Be7 {18s} 7. Qxa8 {0.00/7 39s} Nc2+ {54s}
8. Kd1 {0.00/8 38s} Nxa1 {4.0s} 9. b3 {0.00/7 37s} Bf6 {27s}
10. Bb2 {0.00/7 36s} O-O {32s} 11. Bxa1 {0.00/7 35s} Qe7 {26s}
12. Bc3 {0.00/6 34s} Bxe5 {6926s} 13. h3 {0.00/6 33s} Qf6 {137s}
14. Qxa7 {0.00/7 32s} d5 {21s} 15. cxd5 {0.00/6 31s} Bf5 {18s}
16. Bxe5 {0.00/7 30s} Qxe5 {3.6s} 17. Nc3 {0.00/8 29s} Bg6 {8.9s}
18. g4 {0.00/7 28s} f5 {4.0s} 19. f3 {0.00/6 28s} fxg4 {274s}
20. hxg4 {0.00/7 27s} Nf7 {10s} 21. Qb7 {0.00/6 26s} Qe7 {26s}
22. Qc6 {0.00/6 26s} Qa3 {232s} 23. Nb5 {0.00/6 25s} Qxa2 {34s}
24. e4 {0.00/8 24s} Qxb3+ {171s} 25. Ke2 {0.00/8 24s} Ng5 {28s}
26. Nd4 {0.00/7 23s} Qb2 {73s} 27. Qc3 {0.00/7 23s} Qa2 {23s}
28. Ke3 {0.00/6 22s} Re8 {161s} 29. d6 {0.00/6 22s} Bxe4 {15s}
30. d7 {0.00/7 21s} Qa8 {134s} 31. dxe8=Q+ {0.00/7 21s} Qxe8 {2.5s}
32. Kf4 {0.00/7 20s} Qf7+ {103s} 33. Nf5 {0.00/8 20s} Bxf3 {83s}
34. Bc4 {0.00/8 19s} Bd5 {40s}
35. Bxd5 {+18.01/8 14s, White wins by adjudication: user decision} 1-0
I won the second encounter, playing White. This time i did a 'positional' game, slowly improving, 'restrict & push' while creating options. Elephant should place its pieces more harmoniously - i'm a clubplayer for many years, but only able to beat weaker engines :-)
https://github.com/looak/elephant/assets/1109281/7f1af410-8f2d-4e0b-bed8-0a1bd288a2e6
[Event "human vs engine"]
[Site "Holland @ https://www.bitchute.com/video/OaK5qAeNQn4f/ "]
[Date "2024.06.01"]
[Round "2"]
[White "Roelof Berkepeis"]
[Black "ElephantGambit v0.6.5"]
[Result "1-0"]
[ECO "A05"]
[Opening "Reti Opening"]
[PlyCount "83"]
[TimeControl "900+10"]
1. Nf3 Nf6 {0.00/8 48s} 2. e3 {61s} Ne4 {0.00/7 46s} 3. d3 {73s}
Nf6 {0.00/8 45s} 4. c3 {67s} d5 {0.00/7 43s} 5. Nbd2 {74s} Qd7 {0.00/6 42s}
6. b4 {93s} Qc6 {0.00/7 41s} 7. Bb2 {214s} Bg4 {0.00/6 39s} 8. Be2 {17s}
Qd6 {0.00/7 38s} 9. Rb1 {77s} a5 {0.00/6 37s} 10. b5 {40s} a4 {0.00/6 36s}
11. c4 {13s} Nbd7 {0.00/6 35s} 12. d4 {36s} a3 {0.00/6 34s} 13. Bc3 {52s}
Bxf3 {0.00/6 33s} 14. Nxf3 {16s} Ne4 {0.00/6 32s} 15. Bb4 {14s} Qg6 {0.00/6 31s}
16. O-O {83s} e6 {0.00/6 30s} 17. Bxf8 {731s} Rxf8 {0.00/6 29s} 18. Qb3 {81s}
Qg4 {0.00/6 28s} 19. Bd3 {88s} g6 {0.00/6 28s} 20. Rfc1 {25s} Nef6 {0.00/6 27s}
21. Qb4 {136s} dxc4 {0.00/5 26s} 22. Qxc4 {58s} Nd5 {0.00/6 26s} 23. Be2 {45s}
Ra5 {0.00/5 25s} 24. Qd3 {76s} Ra4 {0.00/5 24s} 25. Bd1 {41s} Ra8 {0.00/6 24s}
26. Rb3 {36s} Qf5 {0.00/7 23s} 27. Qe2 {73s} Ra7 {0.00/5 23s} 28. Nd2 {63s}
Qg5 {0.00/5 22s} 29. Ne4 {53s} Qh4 {0.00/6 22s} 30. Nc5 {151s} Nxc5 {0.00/6 21s}
31. dxc5 {46s} b6 {0.00/6 21s} 32. Rc4 {94s} Qf6 {0.00/7 20s} 33. g3 {60s}
bxc5 {0.00/6 20s} 34. e4 {29s} Nb6 {0.00/7 19s} 35. Rxc5 {42s} Qa1 {0.00/6 19s}
36. Kg2 {5.3s} Na4 {0.00/6 19s} 37. Rc6 {37s} Nb2 {0.00/7 18s} 38. Bc2 {6.3s}
Qxa2 {0.00/7 18s} 39. Qe3 {25s} Ra5 {0.00/7 18s} 40. Qc5 {85s} h6 {0.00/7 17s}
41. Rxc7 {14s} Na4 {+6.46/5 1.4s} 42. Qe7# {4.6s, White mates} 1-0
Additional amazing feedback, appreciate it! I did recently expose Threads and Hash uci parameters though the thread one doesn't do anything, but it's a requirement for openbench. Currently everything is done on one thread, even time managment is done on the same thread. This is for sure something that I should and will improve upon.
The engine does so called alpha beta pruning which is essentially what you describe, avoids calculating unecessary positions and weak moves. It depends heavily on the evaluation though, which currently is very naive and is something I will improve upon.
I host the engine on lichess from time to time https://lichess.org/@/elephantgambitengine get some assessments on how strong it is, currently at 1450 in bullet and 1350 at rapid, do you have an official rating or a rating on chess.com or lichess.org?
..do you have an official rating or a rating on chess.com or lichess.org?
see https://lichess.org/@/tissatussa i never play on chess.com, i like LiChess very much. i play only 15m10s nowadays : always trying to create a 'full game' but Rapid ..
your answers are clear thank you. yes, threads are important, we learn a lot :-) i'm not into C++ though, nor C .. did you find that KingSlayer .c file ? Must be amazing code. i do mainly Python but i know C from my school back-in-the-days :-)
lately i even fixed the Meneldor engine : https://github.com/bicyclespokesperson/meneldor_chess_engine/issues/4 with ChatGPT - my first ever programming challenge with this AI ! Now Meneldor runs fine in CuteChess .. i felt something simple was wrong, a small bug, and i found the concerning code part, added many log lines and i fixed that code just by deducing and asking the AI well defined questions .. that hack took me about 6 hours .. AI seems ideal for such tasks, i even wonder if we could fix old 32-bit code this way, but i didn't start such project yet :-)
Many ancient engines are C
btw. i never used openbench.
I have yet to take a look at KingSlayer; it intrigues me; I love the chess engine history, and I love computer science history in general, actually.
I do personally also utilize these generative AI tools lately, both in my hobby projects and at work. I think they are a superb addition to the toolset, anything that makes me more productive is a good thing, right?
I wouldn't expect you to use OpenBench, it's purely a tool to measure incremental evaluation performance changes of chess engines. I think I finally got it to work properly, i.e. it compiles. It's been a pain. makefiles and make lists are the bane of my existence; I really dislike having to deal with them and how it all works. Makes me appreciate Visual Studio where all that's solved for me.
Thank you for your additional suggestions; I haven't had much time this weekend to work on the engine until now; development is slow. Appreciate your enthusiasm and correspondence.
...I have yet to take a look at KingSlayer; it intrigues me...
i found that code, not on his website but somewhere else .. the file was just called 'simple.c', which intrigued ME .. the (.7z) package revealed this is actually KingSlayer v1.0.0 from 2015, i (re)ZIPped it for you : KingSlayer_100.zip .. it also contains a Windows asset but i didn't test that because i only do Linux.
the README info is nice, i want to share it here :
King Slayer
a Chess engine by H.G.Muller
King Slayer is intended to be an inspiration for beginning Chess-engine
programmers, and illustrates the basic techniques of tree searching as
applied to Chess. Its source code is extensively commented to explain
the workings of the code.
King Slayer is based on a 16x8 'mailbox' board, i.e. a separate memory
location is used to describe the content of each board square. Only the
first 8 files of the board array are used. This so-called 0x88 design
makes the difference between square numbers unique, so that this
difference can be used to determine if pieces are aligned for capture,
what their distance measured in King steps is, etc.
King Slayer represents moves as 32-bit integers, of which only the
lowest 3 bytes are used. These 3 bytes contain the from- and to-square
of the move, and either a third square (the 'e.p. square') or a piece
'upgrade'. Square numbers in the 0x88 system leave two bits of a byte
unused, and these bits in the e.p-square byte are used as flags to
indicate whether this byte does hold an actual e.p. square (from which
the occupant should disappear as a side effect of the move), or a
number to be added to the piece code after the mobe (to effect promotion).
Normal moves are considered promotions with an upgrade 0. Each move can
thus either be a promotion or have a second capture victim, making it
easy for this engine to handle Chess variants that involve double
captures.
King Slayer does contain 'light' versions of the most common evaluation
terms: piece-square tables interpolated between opening and end-game
values, piece mobility, Pawn structure, sped up by a Pawn hash table,
some patterns for trapped pieces, King safety through Pawn-shield
quality and King seige (squares next to King under enemy attack),
score reduction when mate potential is jeopardized or absent,
and recognition of some well-known draw positions in the late end-game
(e.g. the opposition rule in KPK).
King Slayer's search does incorporate techniques such as internal
iterative deepening, quiescence search, check extension, null-move
pruning, late-move reductions. And of course a transposition table.
Have fun,
H.G. Muller
Sept 30, 2015
until now i didn't create an own engine, only a rewrite of BMCP ( https://github.com/maksimKorzh/bmcp ) and TSCP ( http://www.tckerrigan.com/Chess/TSCP/ ) into Python (which i know) and later into the Nim language, which strongly resembles Python but Nim code can be compiled and thus should give a fast program, crucial for chess engines. Those conversions succeeded but these engines only have a very basic HCE and reach max depth 5 - not realistic, but i learned a lot and it was fun. This way i discovered running a Python script by PyPy is just as fast !? I didn't yet plan to rewrite 'simple.c' ..
...Makes me appreciate Visual Studio where all that's solved for me...
on Linux we have 'Visual Studio Code' but i can't work with it, for it uses 'msbuild' but that program gives errors on my OS which i can't solve .. nevermind, i don't want to be involved into M$ too much, anyhow :-)
...I haven't had much time this weekend to work on the engine until now; development is slow...
that's alright, take your time and stay in contact.
about the time management : i just stumbled upon a remark at https://github.com/xu-shawn/Serendipity/pull/74 :
Old time management was not tested at a proper time control. This patch replaces the soft time limit algorithm with one from Alexandria.
Serendipity is in Java, Alexandria in C++ ! HTH
I'm working on v0.7.0 - hopefully tomorrow or this weekend! :) Should be quite an improvement:
Elo | 236.83 +- 88.34 (95%)
SPRT | 2.0+0.01s Threads=1 Hash=64MB
LLR | 0.81 (-2.94, 2.94) [0.00, 5.00]
Games | N: 108 W: 84 L: 20 D: 4
Penta | [1, 1, 17, 3, 32]
Found quite a significant bug in the transposition table where I would overwrite any beta cutoffs with either a alpha or exact, caused a lot of broken moves. Feels really good to have figured that one out.
Additional improvements are mainly to the move ordering and some added evaluation logic.
Also made some more changes to the time management and I think I
Thank you for your continued support and comments.
nice progress !
yesterday i stumbled upon this Issue about using (2) threads : https://github.com/Orbital-Web/Raphael/issues/1
i also found some old-but-basic info about (C) search techniques here : http://www.eglebbk.dds.nl/program/chess-search.html it's from the author (a Dutch guy, like me) of "Sjaak" (~2150) and "Jazz" (~2550), he also wrote articles about "Design decisions" and "Evaluation", see his "Programming details" menu.
HTH
congrats for creating v0.7.0 ! however, it plays a poor game, i have no clue ..
today i was working with ChatGPT (=very nice help for coding!) to repair some old chess engine code of "Zorgus" v1.2.0, see http://olivier.delannoy.free.fr/chess-zorgus/ .. i found that engine in a Linux package of the famous "JA" (Jim Ablett, see https://www.chessprogramming.org/Jim_Ablett ) but it still needed some work to compile .. i succeeded and learned a lot, and then i tested it against your engine .. Zorgus rating must be 2200+ and (indeed) it won against your v0.6.5 and also v0.7.0 .. here are those games :
v0.6.5 makes a terrible mistake at start : it lost the Queen for no reason - that game had a fixed starting position :
ElephantGambit v0.6.5 -vs- Zorgus v1.2.0 [ replay the game here ]
v0.7.0 didn't see an obvious mate :
ElephantGambit v0.7.0 -vs- Zorgus v1.2.0 [ replay the game here ]
it's nice you implemented threads ! those games were played with time 7m3s, 128 Mb Hash and 2 threads. Zorgus had NO opening book (although JA states in his README the book is needed to avoid illegal moves?!) but it played well .. here are the ZIPped pgn's, including their links to LiChess for replay : elephantgambit-2-games-vs-zorgus.zip
no worries .. just let it sink in have a nice weekend !
https://github.com/looak/elephant/assets/1109281/7e31a138-4444-4889-82dd-edb41e9ada59
Today i used ChatGPT to know more about compiling C / C++ code. This AI was a great help, i saved the page : ChatGPT-about-compiling-C-C++-code.zip It might interest you.
I changed the animated diagrams above .. they're now smaller and the animation is slower .. i created them with https://www.apronus.com/chess/diagram/animated/ (although changing the animation speed is a bit tricky, not clear).
@tissatussa - check out this game I played against a human on Chess.com, I'm so proud. ;D
[Event "Live Chess"]
[Site "Chess.com"]
[Date "2024.06.22"]
[Round "-"]
[White "loodinek"]
[Black "tomthedestroyer420"]
[Result "1-0"]
[CurrentPosition "1k3b1r/p2N1ppp/2Qr4/3P4/4PBn1/8/PP3PPP/4K2R b K -"]
[Timezone "UTC"]
[ECO "D10"]
[ECOUrl "https://www.chess.com/openings/Slav-Defense-3.e3"]
[UTCDate "2024.06.22"]
[UTCTime "00:24:10"]
[WhiteElo "939"]
[BlackElo "911"]
[TimeControl "600"]
[Termination "loodinek won by checkmate"]
[StartTime "00:24:10"]
[EndDate "2024.06.22"]
[EndTime "00:33:27"]
[Link "https://www.chess.com/game/live/107878033234"]
[WhiteUrl "https://images.chesscomfiles.com/uploads/v1/user/1604367.1e4c5e67.50x50o.dc153ed6a3ca.jpeg"]
[WhiteCountry "132"]
[WhiteTitle ""]
[BlackUrl "https://images.chesscomfiles.com/uploads/v1/user/102876822.690b6618.50x50o.369d639109ac.jpeg"]
[BlackCountry "3"]
[BlackTitle ""]
1. d4 d5 2. c4 c6 3. e3 c5 $6 4. cxd5 cxd4 $6 5. Qxd4 Nf6 6. Nc3 Qa5 7. Bd2 b5 $2 8.
Bxb5+ $6 (8. Nxb5) 8... Bd7 9. Bxd7+ Nbxd7 10. Nf3 O-O-O 11. Rc1 Nc5 $6 12. e4 Ng4
13. Nb5 $3 Qxb5 $6 14. Rxc5+ $1 Qxc5 15. Qxc5+ Kb7 16. Qc6+ Kb8 17. Bf4+ e5 18. Nxe5
(18. Bxe5+) (18. dxe6+ Rd6 19. Bxd6+ Bxd6 20. Qxd6+ Kb7 21. exf7) 18... Rd6 $2 19.
Nd7# 1-0
Short update on the engine, I haven't worked on it for about a week. My motivation comes and goes, and lately I've been just enjoying the weather with summer finally arriving. :)
..My motivation comes and goes..
that's normal, enjoy life !
about your win : it's always nice when ideas come true ..
congrat with your newest v0.6.5 ! i compiled it successfully on Linux, without any error or warning, and it runs fine in CuteChess.
but i have some remarks (also see my recent #4 ) :
the section "Goals & todo" in the README states "OpenBench - https://github.com/AndyGrant/OpenBench" but your note of this v0.6.5 states "First release to support open bench".
the same README section also mentions "transposition table" but during compile i see :
should the README be updated ?
how strong is v0.6.5 ? i read you want "to enter in some computer chess engine competitions", which is a good idea ! i guess its rating is still (far) below 2000. I let the engine play a 7m+3s game against KingSlayer v1.0.0 () and it lost clearly - see game below. KingSlayer has no official rating but i estimate its rating 2000. This is a very simple engine from 2015, written in C by the famous H.G. Muller (see https://www.chessprogramming.org/Harm_Geert_Muller ). It only consists of a single code file ! ) having "evaluate Trapped Pieces" and "evaluate King Seige" enabled (besides its default options) - with this option combination KingSlayer seems to be playing best, according to my tests.
in the game we see Elephant moving a kNight twice in the opening, which is a bad habbit : this kNight is hunted instantly and must retreat a few moves later, thus losing precious time.
the evaluation is "0.00" for many moves, which is strange to me .. v0.6.1 didn't have this 'behaviour' - however time management seems much better now.
last thing : the README is a bit malformed in my reader app (i use Okular on Linux). This is mainly caused by lack of empty lines before and after triple backtick chars. I guess this is a bug in Okular .. many README.md files i encounter have this same 'issue' .. also the "div align" construct fails to display properly. I attached a (ZIPped) corrected version of this info file here :
README.zip
[ i'm on Xubuntu 22.04 ]