kanin9 / mufasa

UCI compatible bitboard chess engine written in C++
GNU General Public License v3.0
2 stars 0 forks source link

can't compile v0.1 : solved (but remarks) #1

Closed tissatussa closed 1 month ago

tissatussa commented 1 month ago

i found your engine at https://chessengines.blogspot.com/2024/07/new-chess-engine-mufasa-01.html and then i discovered your GitHub page. I downloaded the code of the newest v0.1 but i had errors and warnings when compiling. I solved those, here's how :

first, i had to add #include <climits> (a compiler message told me that) on top of bitboard.hpp to simply solve this error :

/home/roelof/Compiled/mufasa-main-v0.1-from-github/src/bitboard.hpp:22:19: error: ‘INT_MAX’ was not declared in this scope
   22 |    const int oo = INT_MAX / 2;
      |                   ^~~~~~~

then, i had an error in the function std::pair<int, Move> Bitboard::bestMove() in bitboard.cpp : the 2 parameters of the function min() are not same type, so i changed the code like this :

uint64_t allocatedTime = std::min(limits.alloc / 5, static_cast<uint64_t>(10000ULL));

in the same function i adjusted your PV line ..

std::cout << "info depth " << d << " time " << (now() - limits.start) << " cp " << score << " pv " << move << "\n";

..into this :

std::cout << "info depth " << d << " nodes " << nodes << " time " << (now() - limits.start) << " score cp " << score << " pv " << move << std::endl;

now i can let Mufasa v0.1 play a game in CuteChess GUI, but .. it makes a lot of dull moves (sorry) : it gives away pieces like crazy and so it will surely lose, even against most other simple engines .. i see it quickly reaches depth 6 / 7, i guess its pruning is much too hard .. and it doesn't properly use its time - there must be a flaw in your time management function(s).

last thing : at the uci command you should add the 2 basic UCI info strings name and author, like this engine does :

id name Mayhem 8.3
id author Toni Helminen
(...)

i hope my remarks may benefit you - i'm almost sure they will :-) it was fun to explore your code and i learned some things.

happy coding !

[ i'm on Xubuntu 22.04 ]

kanin9 commented 1 month ago

Hi, Roelof!

Thanks for giving meaningful feedback! The reason for the engine being dull is because I hardcoded the maximum depth of 7 in the go function in uci.cpp as the current cli does not support async i/o and the engine wastes much time not using the search results from previous depths.

I plan to roll out a new version with less strict depth limit, aspiration windows, TT, TT-move ordering and repetitions implemented in a few hours and as the cutechess-cli suggests it is WAY better than the previous release (it has not lost a single game.)

Also out of curiosity what engine did you test mine against?

tissatussa commented 1 month ago

Also out of curiosity what engine did you test mine against?

see games PGN below.

you say "hardcoded the maximum depth of 7" but it's better to have a good time management so stop the search when time's up ..

[Event "?"]
[Site "?"]
[Date "2024.07.28"]
[Round "?"]
[White "CaveChess (OSP & only White)"]
[Black "Mufasa v0.1"]
[Result "1-0"]
[ECO "A41"]
[GameDuration "00:03:28"]
[Opening "Queen's Pawn"]
[PlyCount "81"]
[TimeControl "300+3"]

1. d4 {0.80s} d6 {/7 5.2s} 2. e4 {0.95s} Nd7 {/7 10s} 3. Nf3 {1.4s}
Ndf6 {/7 4.0s} 4. Bd3 {1.3s} Bg4 {/7 7.2s} 5. h3 {1.7s} Bxf3 {/7 2.1s} 6. Qxf3
Qb8 {/7 10s} 7. Bf4 {4.5s} Qd8 {/7 10.0s} 8. e5 {3.0s} dxe5 {/7 2.0s}
9. dxe5 {1.6s} Nd5 {/7 8.9s} 10. Bc4 {2.5s} e6 {/7 2.8s} 11. Bxd5 {4.2s}
Qxd5 {/7 3.6s} 12. Qxd5 exd5 {/7 0.89s} 13. Nd2 {1.5s} Ne7 {/7 6.5s} 14. Ke2
Ng6 {/7 10s} 15. Bg3 {0.53s} Bb4 {/7 8.0s} 16. Nb3 {0.65s} Nh4 {/7 10s} 17. Bxh4
Be7 {/7 1.9s} 18. Bxe7 Kxe7 {/7 0.98s} 19. Ke3 {1.8s} Rhe8 {/7 5.4s}
20. Kd4 {0.90s} Red8 {/7 1.5s} 21. Rhe1 {0.70s} Rab8 {/7 1.8s} 22. Nd2 {1.9s}
Ke6 {/7 2.1s} 23. Nf3 {1.1s} Rd7 {/7 4.4s} 24. Kd3 {1.5s} Kf5 {/7 5.0s}
25. Nd4+ {1.3s} Kg5 {/7 1.5s} 26. Rad1 {1.0s} Kg6 {/7 10.0s} 27. Re3 {1.4s}
Rg8 {/7 10s} 28. Rg3+ {0.68s} Kh5 {/7 2.2s} 29. h4 {0.69s} g5 {/7 8.0s}
30. hxg5 {0.54s} Rxg5 {/7 2.8s} 31. Rh1+ Kg6 {/7 0.050s} 32. Rxg5+
Kxg5 {/7 0.37s} 33. Rxh7 Kg6 {/7 0.92s} 34. Rh3 Re7 {/7 0.50s} 35. Rg3+
Kh7 {/7 0.33s} 36. f4 Rd7 {/7 0.86s} 37. f5 Kh6 {/7 0.63s} 38. f6 Kh5 {/7 0.93s}
39. Rg7 Rd6 {/7 1.2s} 40. Nf5 Ra6 {/7 0.52s} 41. g4# {White mates} 1-0

[Event "?"]
[Site "?"]
[Date "2024.07.28"]
[Round "?"]
[White "Catto v0.12.0 [6,5]"]
[Black "Mufasa v0.1"]
[Result "1-0"]
[ECO "A41"]
[GameDuration "00:05:57"]
[Opening "Queen's Pawn"]
[PlyCount "57"]
[TimeControl "300+3"]

1. d4 {+0.36/5 10s} d6 {/7 5.9s} 2. e4 {+0.30/4 9.9s} Nd7 {/7 10.0s}
3. Nc3 {+0.86/4 9.6s} Ndf6 {/7 6.6s} 4. Bf4 {+1.22/3 9.4s} Bd7 {/7 10s}
5. Nf3 {+1.19/3 9.2s} Rc8 {/7 10.0s} 6. Bc4 {+1.27/3 9.0s} Rb8 {/7 10.0s}
7. O-O {+2.03/3 8.8s} Rc8 {/7 10.0s} 8. Ng5 {+2.01/3 8.6s} Ba4 {/7 10s}
9. Bxf7+ {+8.03/5 8.4s} Kd7 {/7 3.1s} 10. Nxa4 {+8.03/4 8.2s} Qe8 {/7 10s}
11. Bxe8+ {+13.03/4 8.1s} Kd8 {/7 10.0s} 12. Bf7 {+17.13/4 7.9s} Ng4 {/7 10.0s}
13. Ne6+ {+21.43/5 7.7s} Kd7 {/7 0.46s} 14. Qxg4 {0.00/5 7.6s} Kc6 {/7 2.4s}
15. d5+ {+22.09/4 7.4s} Kb5 {/7 1.1s} 16. Nd4+ {+22.17/4 7.3s} Kxa4 {/7 1.4s}
17. Qxc8 {+22.54/4 7.1s} Nf6 {/7 3.2s} 18. Ne6 {+22.73/3 7.0s} Nxd5 {/7 9.2s}
19. exd5 {+25.27/4 6.9s} Rg8 {/7 4.3s} 20. Bxg8 {0.00/5 6.7s} a6 {/7 2.4s}
21. Qxf8 {+32.69/5 6.6s} g5 {/7 1.6s} 22. Bxg5 {+33.60/5 6.5s} h6 {/7 1.4s}
23. Qxh6 {+34.52/5 6.4s} c6 {/7 0.47s} 24. dxc6 {+34.91/5 6.3s} b5 {/7 0.89s}
25. Bxe7 {+36.65/5 6.2s} Ka5 {/7 1.5s} 26. c7 {+45.77/5 6.0s} b4 {/7 0.59s}
27. c8=Q {+47.09/5 5.9s} b3 {/7 0.44s} 28. axb3+ {+489.97/4 5.8s}
Kb4 {/7 0.018s} 29. Qc4# {+489.99/5 5.7s, White mates} 1-0

[Event "?"]
[Site "?"]
[Date "2024.07.28"]
[Round "?"]
[White "AdaChess v4.0"]
[Black "Mufasa v0.1"]
[Result "1-0"]
[ECO "A00"]
[GameDuration "00:04:50"]
[Opening "Dunst (Sleipner, Heinrichsen) Opening"]
[PlyCount "47"]
[TimeControl "300+3"]

1. Nc3 {+0.15/1 8.0s} d6 {0.00/7 2.1s} 2. e4 {+0.41/1 7.6s} Be6 {+0.35/7 5.0s}
3. Nf3 {+0.67/1 7.4s} Nd7 {+0.18/7 3.9s} 4. Ng5 {+1.27/1 7.3s} Nc5 {+M177/7 10s}
5. d4 {+1.41/1 7.2s} Nd7 {+M177/7 10s} 6. d5 {+3.89/1 7.1s} Ngf6 {-1.67/7 3.6s}
7. dxe6 {+5.77/1 7.0s} fxe6 {-2.61/7 4.7s} 8. Nxe6 {+5.85/1 6.9s}
Qc8 {+M177/7 10.0s} 9. Nb5 {+5.64/1 6.8s} Rb8 {+M177/7 10.0s}
10. Nxa7 {+11.15/1 6.7s} Nc5 {-8.73/7 2.3s} 11. Bb5+ {+11.07/1 6.6s}
c6 {-8.52/7 2.2s} 12. Nxc8 {+11.52/1 6.5s} Nxe6 {-8.86/7 0.56s}
13. Bc4 {+11.43/1 6.4s} Nc5 {-9.25/7 1.6s} 14. Nb6 {+11.44/1 6.4s}
Ncxe4 {-9.49/7 4.5s} 15. O-O {+11.14/1 6.3s} Kd8 {-9.42/7 6.5s}
16. Be6 {+11.41/1 6.2s} Nc5 {-8.95/7 3.1s} 17. Re1 {+11.27/1 6.1s}
Kc7 {-8.74/7 6.1s} 18. Nc4 {+11.36/1 6.0s} Nxe6 {-9.23/7 6.4s}
19. Rxe6 {+11.43/1 6.0s} Rg8 {+M177/7 10.0s} 20. Qf3 {+11.68/1 5.9s}
Rc8 {+M177/7 10s} 21. Bd2 {+11.92/1 5.8s} Rb8 {+M177/7 10.0s}
22. Ba5+ {+13.78/1 5.7s} b6 {-12.26/7 6.2s} 23. Bxb6+ {+13.43/1 5.7s}
Kc8 {+M177/7 10.0s} 24. Qxc6# {+327.66/254 0.12s, White mates} 1-0