ppipelin / radiance

UCI Chess Engine written in C++
https://lichess.org/@/RadianceEngine
GNU General Public License v3.0
1 stars 0 forks source link

compilation problems v3.2 on Linux #4

Closed tissatussa closed 1 month ago

tissatussa commented 1 month ago

i'm not into C++, but i can understand most of it .. i had trouble compiling the v3.2 source in Linux .. i found some code parts i could 'repair', but others not .. the code seems typically for Windows .. i don't use VS so i used your CMakeLists.txt and cmake to create a Makefile.

one of the first things i needed to do : change the filename 'SearchMaterialistNegamax.h' : it has a capital letter but in the source code this file is written with a small letter .. on Windows this doesn't matter, on Linux it does .. i advise you to only use small letters for all file names, this method is rather common (but not to many Windows users).

it seems your code uses c++23 i'm new to that, i had to set my compiler to g++-13 to avoid errors.

besides other errors which i tried to 'solve', here's a code part i can't understand : in 'board.h' you define 'class Piece;' and later in that file in 'class Board' you also use the variable name 'Piece', even on two lines : 'Piece operator{..}' and 'const Piece operator{..}' : the compiler gets confused and gives an error.

maybe after you adjust some code according to my remarks, most of my other errors will be gone ?

[ i'm on Xubuntu 22.04 ]

ppipelin commented 1 month ago

Hello, SearchMaterialistNegamax.h with an uppercase was a sloppy mistake, thanks for noticing.

As for compiling on linux I changed very few code and it worked (std::max being stricter and removing const enum).

I was able to compile using cmake this way :

export CXX=g++-12
export CC=gcc-12
cd build
cmake -DCMAKE_BUILD_TYPE=Release .. && make

I updated github actions to take linux into account as well.

As for the class Piece;, this is a forward declare which tells the compiler there will be a Piece object defined later in compilation. The only drawback of such method is that Piece's attributes and members are not available, but this allows to avoid compilation cycles.

Please close the issue if everything is resolved now.

tissatussa commented 1 month ago

compiling the newest main source went well ! and the engine just played its first 5m+3s game in CuteChess GUI .. it was a game without errors, i think the binary is OK .. but the program spoiled the win : it had +4.66 eval at move 28. Qe2 but lost :

[Event "engine vs engine"]
[Site "Holland @ https://lichess.org/Rz70F0Ga"]
[Date "2024.08.14"]
[Round "?"]
[White "Radiance v3.2"]
[Black "ElephantGambit v0.7.0"]
[Result "0-1"]
[ECO "B03"]
[GameDuration "00:11:34"]
[Opening "Alekhine's defense"]
[PlyCount "94"]
[TimeControl "300+3"]

1. e4 {+0.04/10 10s} Nf6 {-0.36/7 16s} 2. e5 {+0.72/11 9.9s} Nd5 {-0.29/7 15s}
3. d4 {+0.57/10 9.6s} Nc6 {-0.11/7 15s} 4. c4 {+1.32/9 9.4s} Nb6 {-0.25/7 14s}
5. c5 {+1.08/10 9.2s} Nd5 {-0.47/7 14s} 6. Bc4 {+1.04/10 9.0s}
Ndb4 {-0.75/7 13s} 7. a3 {+1.97/9 8.8s} b5 {-0.86/7 13s} 8. Be2 {+2.13/10 8.6s}
Nd5 {-1.07/7 12s} 9. Bxb5 {+2.35/11 8.4s} Bb7 {-1.30/7 12s}
10. Nf3 {+2.32/11 8.2s} e6 {-1.08/6 12s} 11. O-O {+2.18/10 8.1s}
d6 {-1.14/6 11s} 12. Qc2 {+2.55/9 7.9s} dxc5 {-1.53/7 11s}
13. dxc5 {+2.57/9 7.7s} Qe7 {-1.07/6 11s} 14. Nd4 {+2.82/9 7.6s}
Kd7 {-1.13/6 10s} 15. b4 {+3.17/7 7.4s} Qh4 {-1.34/6 10.0s}
16. Nf3 {+3.39/7 7.3s} Qg4 {-1.23/6 9.7s} 17. h3 {+3.24/8 7.1s}
Qh5 {-1.04/6 9.4s} 18. Qa4 {+3.27/7 7.0s} a6 {-0.82/6 9.1s}
19. Bd3 {+3.13/7 6.9s} a5 {-0.82/5 8.9s} 20. b5 {+3.43/10 6.7s}
Bxc5 {-1.75/6 8.6s} 21. bxc6+ {+3.92/10 6.6s} Bxc6 {-3.05/7 8.4s}
22. Qc4 {+3.84/8 6.5s} Bb6 {-2.00/6 8.2s} 23. Bg5 {+4.16/7 6.4s}
f6 {-1.77/6 8.0s} 24. exf6 {+4.97/9 6.3s} gxf6 {-1.67/6 7.7s}
25. Rc1 {+4.64/8 6.1s} Bb7 {-1.65/6 7.5s} 26. Bd2 {+4.18/8 6.0s}
Rhg8 {-1.77/5 7.4s} 27. Qe4 {+4.48/7 5.9s} f5 {-1.52/6 7.2s}
28. Qe2 {+4.66/8 5.8s} Qxh3 {-0.54/6 7.0s} 29. Ng5 {+4.01/8 5.7s}
Qh6 {-0.31/7 6.8s} 30. Re1 {+3.96/7 5.7s} Rae8 {-0.41/6 6.7s}
31. Nf3 {+2.89/8 5.6s} Qg7 {+1.09/7 6.5s} 32. Ne5+ {+1.09/9 5.5s}
Kc8 {+1.35/6 6.4s} 33. g4 {+0.71/9 5.4s} Bd4 {+1.65/6 6.2s}
34. Ra2 {+0.36/9 5.3s} Bxe5 {+1.65/6 6.1s} 35. Qxe5 {+0.26/10 5.2s}
Qxe5 {+1.74/6 6.0s} 36. Rxe5 {+0.95/11 5.2s} Rxg4+ {+0.46/7 5.8s}
37. Kh2 {+0.95/9 5.1s} Rh4+ {+1.81/6 5.7s} 38. Kg3 {+0.89/10 5.0s}
Rd4 {+1.81/7 5.6s} 39. Bb5 {+1.08/9 5.0s} Rg8+ {+2.19/7 5.5s}
40. Kh3 {-0.34/9 4.9s} Rg1 {+3.05/6 5.4s} 41. Rb2 {-0.42/8 4.8s}
Rdg4 {+3.80/7 5.3s} 42. Kh2 {-0.25/8 4.8s} Nf4 {+9.49/7 5.2s}
43. Bc6 {-319.90/12 4.7s} Bxc6 {+15.88/8 5.1s} 44. Rb8+ {-319.92/12 4.7s}
Kd7 {+16.45/8 0.63s} 45. Rd5+ {-319.94/14 4.6s} Bxd5 {/1 0s}
46. Rd8+ {-319.96/13 4.5s} Kxd8 {/1 0s} 47. Bxf4 {-319.98/13 4.5s}
Rh1# {/1 0s, Black mates} 0-1

lichess-graph-and-accurate-perc

i compiled exactly as you wrote : with the exports and the build/ folder. no errors occured, but i had many warnings - which seem easy to fix, and you should :-) see Radiance-compile-logs-linux.zip

i peeked into the newest code (with Meld, to see differences) and it seems you fixed the codes nicely : detect Linux and use if-else clauses, adjusted the CMakeLists.txt (i don't master this technique) and more. Btw. i'm not familiar with those those .yml files (github actions).

i will now play a game with v3.2 and post it here ! i guess we can close this Issue soon.

ppipelin commented 1 month ago

Yeah I guess my piece-square tables are good but transform winning positions into a win is a hard task for a computer.

In this case, a metric that emphasize keeping the king safe and attacking on weak king would prevent the 23. Bg5 which lead to losing. You can also play on lichess if you want.

ppipelin commented 1 month ago

Updated some of the warnings For the others :

tissatussa commented 1 month ago

..Updated some of the warnings..

nice how you explain these C++ techniques .. i'm more into Nim and Python, but i learned how to fix C(++) errors and warnings, learning a lot on the way, same for other languages .. for me it's fun to repair / adjust code, even typical Windows stuff .. didn't you ever bother to fix warnings, or didn't you get any ?

tissatussa commented 1 month ago

i just lost a 15m+10s game on LiChess by your link ..

when is this bot active ? i encounter a lot of bots being offline ..

ppipelin commented 1 month ago

Compilers have their own levels of warning, on windows with MSVC these did not appear. For example fixing this is useless. The code is self-explanatory for no mistake to be made. There is a warning because in the future, mistakes could arise for some long || && || || && sucession, but here the code is clear.

The bot should be active for a long time, I hope infinitely with some short downtimes. With the linux compilation I should be able to put it on a raspberry pi which would make it run indefinitely.

Edit : you can also play with the bot unrated matches. It supports infinite correspondence, and in this case takes 5sec to think.

tissatussa commented 1 month ago

Yeah I guess my piece-square tables are good but transform winning positions into a win is a hard task for a computer. In this case, a metric that emphasize keeping the king safe and attacking on weak king would prevent the 23. Bg5 which lead to losing.

you seem a good chess player, recognizing strategical & tactical moves, and C programmer as well ! When did you start with Radiance ? Any previous attempt to create a chess engine ? Did you use / write common eval techniques or also own ideas ? Once i discovered the TuroChamp engine, from 1940 or so by Alan Turing (&..) and some coders made a version of it, eg. nimTUROCHAMP .. its eval is based on a smart rule set and i guess it'd be rather easy to use it as (the main) eval formula !? : the existing search function can stay the same, or am i wrong here, putting it too simple ? Anyhow, the (6 or so) TuroChamp rules fascinate me.

ppipelin commented 1 month ago

I have been going back and forth with interface choices for a long time. Last option I settled with was display the board in a browser and communicating with a JS server from C++. Once it worked partially (without underpromotion) I decided to use UCI protocol and ready to use interface.

As for the real engine, I started this year in January and February and returned back to it at the end of July. First attempt in programming a chess engine. See the other evaluation files for previous method. Which should still be useable by editing the code.

existing search function can stay the same, or am i wrong here, putting it too simple

yes, modificating here works : https://github.com/ppipelin/radiance/blob/main/src/uci.cpp#L138-L141

(6 or so)

indeed, https://www.chessprogramming.org/Turochamp#Evaluation_Features

tissatussa commented 1 month ago

uci.cpp :

// SearchRandom search = SearchRandom(limits, &g_stop);
// SearchMaterialist search = SearchMaterialist(limits, &g_stop);
SearchMaterialistNegamax search = SearchMaterialistNegamax(limits, &g_stop);

// EvaluateShannon evaluate = EvaluateShannon();
// EvaluateShannonHeuristics evaluate = EvaluateShannonHeuristics();
// EvaluateTable evaluate = EvaluateTable();
EvaluateTableTuned evaluate = EvaluateTableTuned();

so, you mean i can uncomment a search function as well as an evaluate function, and create a new engine ? That would be cool, which one's TuroChamp then ? Then you could create UCI options for those functions to let the user set some playing style !?

ppipelin commented 1 month ago

create a new engine

An engine with a different evaluation function properly speaking, engine are usually the combination of search and evaluation. Note that random search does not take into account the evaluation.

Then you could create UCI options for those functions to let the user set some playing style

Yes

Evaluate Shannon is the closest to turochamp, not sure it will work right with uncommenting since the code changed lot since I tested it.

tissatussa commented 1 month ago

..not sure it will work right with uncommenting since the code changed lot since I tested it

that's a pitty, i would really like to see those working ! Were you just experimenting ? I know Shannon is also implemented by other coders - what about different search/eval combinations all giving their value and set their weight for a "combined eval value" according to some "position type" (to be determined) ? Do such HCE methods exist ?

ppipelin commented 1 month ago

It did work at one point, I'm just not sure it still does. Sure, mixing is possible, although, consistency of evaluation through the entire game is better (i.e. doing a good move in a winning position must lead to another winning position).

tissatussa commented 1 month ago

..my piece-square tables are good but transform winning positions into a win is a hard task for a computer..

yes, but it's a pitty .. e.g. v3.2 lost this recent game by making a few blunders :

[Event "engine vs engine"]
[Site "Holland @ https://lichess.org/QkKVCJwU "]
[Date "2024.08.15"]
[Round "?"]
[White "Kojiro v0.1"]
[Black "Radiance v3.2"]
[Result "1-0"]
[ECO "C22"]
[GameDuration "00:13:55"]
[Opening "Centre game"]
[PlyCount "117"]
[TimeControl "300+3"]

1. e4 {+0.22/12 7.9s} e5 {-0.42/10 10s} 2. d4 {+0.17/11 8.3s}
exd4 {-0.15/10 9.9s} 3. Qxd4 {+0.20/11 8.6s} Nc6 {+0.04/9 9.6s}
4. Qa4 {+0.20/10 8.9s} Nf6 {-0.02/8 9.4s} 5. c3 {+0.08/10 9.1s}
d5 {+0.46/9 9.2s} 6. exd5 {+0.05/11 9.3s} Qxd5 {+0.23/8 9.0s}
7. Be3 {-0.13/10 9.4s} Bc5 {+0.29/8 8.8s} 8. Bxc5 {-0.15/12 9.6s}
Qxc5 {+0.62/9 8.6s} 9. Nf3 {-0.34/10 9.7s} O-O {+0.64/10 8.4s}
10. Be2 {-0.78/11 9.8s} Bf5 {+0.64/10 8.2s} 11. O-O {-0.38/11 9.8s}
Rae8 {+0.64/8 8.1s} 12. b4 {-0.45/11 9.9s} Qb6 {+0.64/10 7.9s}
13. Qd1 {-0.33/11 9.9s} h6 {+0.63/9 7.7s} 14. b5 {-0.30/11 9.9s}
Ne5 {+0.66/10 7.6s} 15. Nxe5 {-0.51/11 9.9s} Rxe5 {+0.68/10 7.4s}
16. a4 {-0.62/11 9.9s} c6 {+0.76/9 7.3s} 17. Bc4 {-0.59/11 9.9s}
Qc7 {+0.79/8 7.1s} 18. bxc6 {-0.76/11 9.9s} Qxc6 {+1.74/9 7.0s}
19. Qb3 {-0.75/10 9.8s} Be4 {+1.92/8 6.9s} 20. Bb5 {-0.76/11 9.8s}
Qd6 {+1.91/9 6.7s} 21. Rd1 {-0.74/10 9.7s} Rd5 {+2.13/9 6.6s}
22. Rxd5 {-0.89/12 9.7s} Nxd5 {+2.06/10 6.5s} 23. Nd2 {-0.26/12 9.6s}
Bf5 {+1.55/8 6.4s} 24. Re1 {-0.10/11 9.5s} Nf4 {+1.67/11 6.3s}
25. Qb4 {-0.22/12 9.4s} Qb8 {+1.53/9 6.1s} 26. Ne4 {-0.14/11 9.3s}
Rd8 {+1.50/8 6.0s} 27. Bc4 {-0.13/10 9.2s} Nd3 {+1.65/8 5.9s}
28. Bxd3 {+0.99/13 9.1s} Rxd3 {+0.78/11 5.8s} 29. Nc5 {+0.70/13 9.1s}
a5 {+0.97/9 5.7s} 30. Qb5 {+2.25/14 9.0s} Rd8 {+0.46/10 5.7s}
31. Nxb7 {+2.00/15 8.8s} Bd3 {+0.26/10 5.6s} 32. Qxa5 {+2.42/15 8.7s}
Re8 {+0.30/12 5.5s} 33. Rxe8+ {+5.26/18 8.6s} Qxe8 {+0.30/10 5.4s}
34. Qd8 {+4.87/18 8.5s} Qxd8 {+0.41/14 5.3s} 35. Nxd8 {+4.81/18 8.4s}
Kf8 {+0.57/13 5.2s} 36. Nc6 {+4.90/18 8.3s} Be4 {+0.24/13 5.2s}
37. Nb4 {+5.12/18 8.2s} Ke7 {+0.34/10 5.1s} 38. f3 {+5.02/18 8.1s}
Bh7 {+0.32/11 5.0s} 39. a5 {+5.23/18 7.9s} Kd6 {-0.88/13 5.0s}
40. g4 {+4.93/16 7.8s} Kc5 {-0.32/12 4.9s} 41. a6 {+4.77/16 7.7s}
Kb6 {-0.55/12 4.8s} 42. Kf2 {+4.41/18 7.6s} h5 {-1.07/12 4.8s}
43. gxh5 {+5.99/19 7.5s} Bf5 {-0.34/11 4.7s} 44. Ke3 {+6.02/18 7.4s}
Be6 {-0.84/12 4.7s} 45. Kd4 {+5.80/19 7.3s} Bf5 {-0.82/11 4.6s}
46. c4 {+6.91/19 7.2s} Be6 {-1.51/12 4.5s} 47. c5+ {+10.06/18 7.0s}
Ka7 {-1.56/12 4.5s} 48. Ke5 {+9.31/20 6.9s} Bc4 {-1.31/13 4.4s}
49. c6 {+12.40/19 6.8s} Kb6 {-1.52/11 4.4s} 50. Nd5+ {+11.13/16 6.7s}
Bxd5 {-1.83/13 4.3s} 51. Kxd5 {+53.40/22 6.6s} f5 {-2.24/14 4.3s}
52. Kd6 {+57.76/22 6.5s} Kxa6 {-10.01/14 4.3s} 53. c7 {+56.23/21 6.4s}
Kb7 {-11.28/13 4.2s} 54. Kd7 {+M13/19 3.5s} Kb6 {-11.31/13 4.2s}
55. c8=Q {+57.29/19 3.1s} Kb5 {-11.31/11 4.1s} 56. Qc3 {+M9/19 3.0s}
Kb6 {-11.53/10 4.1s} 57. Qb4+ {+M5/20 3.0s} Ka7 {-319.96/11 4.1s}
58. Kc6 {+M3/19 3.0s} Ka6 {-319.98/12 4.0s} 59. Qa4# {+M1/21 3.0s, White mates}
1-0

Radiance-v3 2-blunders

tissatussa commented 1 month ago

Sure, mixing is possible..

yesterday i compiled all (8) combinations (2 search functions and 4 evaluation functions) and ran a Gauntlet tournament : v3.2 playing against all these siblings .. result : v3.2 just won all games ! So, i conclude your other search/eval functions still work, but their strength is less then the current v3.2

ppipelin commented 1 month ago

yes, but it's a pitty .. e.g. v3.2 lost this recent game by making a few blunders :

Yeah, even GM says that: chess is hard

About the search function variations, SearchMaterialist cannot benefit from iterative deepening because it is a regular minimax instead of an alpha-beta search. Hence, depth is fixed. I will add varying depth at the cost of speed for this search to take into account time constraint.

To have interesting varying engine, I'd say modifying evaluation is enough. For search, turning on/off transpositions or late-move reductions is also interesting.

ppipelin commented 1 month ago

Hello, just updated the UCI options such that you can select the evaluation or search function from the uci interface. Options are listed in the README.md.

Made a quick tournament for testing : image

Also, if the issues are resolved, please close this issue.

tissatussa commented 1 month ago

Nice ! I compiled it and it runs fine .. but which search & eval setting is default as the previous v3.2, without these UCI settings ?

ppipelin commented 1 month ago

Default is previous best combination, so abNegamax and PSQTuned

tissatussa commented 1 month ago

Issues are resolved, questions answered, i close this Issue.