IlanIwumbwe / Ylva

UCI chess engine
2 stars 0 forks source link

create UCI #8

Closed tissatussa closed 2 months ago

tissatussa commented 3 months ago

the Ylva engine seems nice, i played some game with it after watching your README video .. it would be nice to run it in CuteChess or Arena, could you implement the UCI protocol ?

it isn't hard, UCI is a clear protocol. I'm not working on any serious chess engine yet, but i did some experiments with TSCP-like code, and i managed to add UCI. Then we can easily play and test, and also compare Ylva to other (simple) engines and judge any improvements.

IlanIwumbwe commented 3 months ago

I agree that UCI would allow easy comparison with other engines and judging improvements. This has been on my todo list, but I was hoping to get transposition tables done before implementing it, however, development has stagnated for the past 2 weeks due to time constraints.

I will have more time in the coming weeks, so I will make a start on this.

Thanks!

tissatussa commented 3 months ago

i gather all kinds of chess engines, but only Linux :-) also weaker ones .. as long as they're stable (don't crash, have a decent timemanagement, etc) they're fun to play with and let them play against other (unrated..) engines.

if you have questions or trouble with Linux, i can help by testing and suggestions.

IlanIwumbwe commented 3 months ago

Much appreciated!

tissatussa commented 3 months ago

https://github.com/IlanIwumbwe/Ylva/assets/1109281/81dd60d0-110b-400f-a677-cd6844b6a0fb

tissatussa commented 3 months ago

btw. i don't do C++ .. i can read it and sometimes adjust some code (esp. when it's typical Windows) but to me C++ is tricky : lots of things to know to create a good program .. many programmers switch to Rust or GO.

tissatussa commented 3 months ago

i saw your newest improvement(s) : start coding the UCI protocol! i also saw the little demo video ..

i don't want to interfere your coding ideas and process, but now you should think about a decent time management : chess programs like CuteChess (the best reference) use eg. :

go wtime 381538 btime 409349 winc 3000 binc 3000

or without bonus times, just :

go wtime 381538 btime 409349

[but i guess you already figured that out..]

to get realistic / optimal time management, the evaluation process of the engine must be interrupted when time's up .. i mean the amount of seconds to spend for a move .. you can use a simple formula to calculate how long that max time is .. i remember the author(s) of the 4KU engine mentioned such simple formula, which seems to work well (but i forgot).

IlanIwumbwe commented 3 months ago

Thanks.

This is being worked on. I can't promise when it will be done, at least to a point where it can connect to a GUI, but it is currently top priority for development.

tissatussa commented 3 months ago

..I can't promise when it will be done..

let it sink in, get a clear view of this functionality .. evaluation process may also depend on the amount of time at start .. i mean a one minute game can have different move "types" (avoid tricky tactics, make 'stable' moves) compared to a Rapid game (include more tactical variations, using Q-search) .. this is my idea - probably some engines use this method .. updating bestmove-until-now seems like some kind of MultiPV to me, but i have no clue ..

good luck !

tissatussa commented 3 months ago

Stare+Into+The+Lights+My+Pretties

IlanIwumbwe commented 3 months ago

good luck !

Thanks!

IlanIwumbwe commented 2 months ago

A subset of UCI protocol has now been added.

tissatussa commented 2 months ago

i compiled the newest source (in your ZIP) without errors or warnings, but it crashes .. gdb shows this :

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

> uci

id name YLVA v1
id author Ilan Iwumbwe
uciok

> ucinewgame
> position startpos
> go wtime 180000 btime 180000

Program received signal SIGSEGV, Segmentation fault.
0x0000555555580f43 in Engine::set_depth (d=16, this=0x0) at src/engine.h:36
36      src/engine.h: No such file or directory.

maybe it's something simple ?

[ i'm on Xubuntu 22.04 ]

IlanIwumbwe commented 2 months ago

Now fixed

tissatussa commented 2 months ago

nice! it just played a first game in CuteChess, 15m10s :

[Event "engine vs engine"]
[Site "Holland"]
[Date "2024.06.17"]
[Round "?"]
[White "YLVA v1 PR11"]
[Black "Shallow Red v0.3.1"]
[Result "0-1"]
[ECO "B00"]
[GameDuration "00:37:43"]
[Opening "King's pawn"]
[PlyCount "92"]
[TimeControl "900+10"]
[Variation "Nimzowitsch defense"]

1. e4 {/7 40s} Nc6 {20s} 2. Ne2 {/7 39s} Nf6 {20s} 3. Nbc3 {/7 38s} d5 {21s}
4. exd5 {/7 37s} Nxd5 {21s} 5. Nxd5 {/6 36s} Qxd5 {21s} 6. Nc3 {/6 36s}
Qe5+ {21s} 7. Ne2 {/7 35s} Nb4 {22s} 8. d3 {/6 34s} Be6 {22s} 9. a3 {/6 33s}
Nd5 {22s} 10. c4 {/6 32s} Nf6 {22s} 11. Bf4 {/6 32s} Qxb2 {23s}
12. Bxc7 {/6 31s} Bf5 {23s} 13. Ng1 {/6 30s} Qc3+ {23s} 14. Ke2 {/8 29s}
Bxd3+ {24s} 15. Qxd3 {/8 29s} Qxa1 {24s} 16. Nf3 {/6 28s} Qb2+ {24s}
17. Ke1 {/7 28s} e6 {25s} 18. Be5 {/6 27s} Qxa3 {25s} 19. Qxa3 {/7 26s}
Bxa3 {25s} 20. Bd3 {/7 26s} Ke7 {26s} 21. Bxf6+ {/7 25s} Kxf6 {26s}
22. Ke2 {/7 25s} Bc5 {27s} 23. Rb1 {/6 24s} b6 {27s} 24. Kf1 {/6 24s} g5 {27s}
25. h3 {/6 23s} h5 {28s} 26. Re1 {/6 23s} Rad8 {28s} 27. Nxg5 {/7 23s}
Rxd3 {29s} 28. Nxf7 {/7 22s} Kxf7 {30s} 29. Ke2 {/7 22s} Rc3 {30s}
30. Kf1 {/7 21s} Rxc4 {31s} 31. Kg1 {/7 21s} Rc2 {31s} 32. Kf1 {/7 21s}
Rxf2+ {32s} 33. Kg1 {/8 20s} a6 {33s} 34. Kh2 {/7 20s} Rg8 {34s}
35. Rg1 {/8 20s} h4 {35s} 36. Kh1 {/8 19s} Rf3 {36s} 37. gxf3 {/8 19s}
Bxg1 {33s} 38. f4 {/11 19s} Be3 {31s} 39. Kh2 {/10 18s} Bxf4+ {29s}
40. Kh1 {/10 18s} Bc1 {27s} 41. Kh2 {/10 18s} a5 {25s} 42. Kh1 {/11 18s}
a4 {1.6s} 43. Kh2 {/11 17s} a3 44. Kh1 {/11 17s} a2 45. Kh2 {/15 17s} a1=R
46. Kh1 {/12 17s} Bf4# {Black mates} 0-1