PaulJeFi / reglisse-chess

A simple chess engine in Python & JavaScript
GNU General Public License v3.0
6 stars 0 forks source link

More support for UCI go commands? #1

Closed kurt1288 closed 2 years ago

kurt1288 commented 2 years ago

I was looking at running your engine in Cute Chess, but it seems like it doesn't support some of the go commands that are necessary for a time-controlled game.

What's needed:

wtime btime winc binc

A full command looks like go wtime 60000 winc 3000 btime 60000 binc 3000.

Support for this would allow your engine to play games with a time control and increment.

PaulJeFi commented 2 years ago

Hi, thank you for using Réglisse. I've stopped for a moment Réglisse-PY, I only work on Réglisse-JS theses days. I did not used multithreading, so the UCI stop command is not supported, and that made Réglisse unusable in most GUIs. But thanks you for your comment, theses four command are planned to be added in Réglisse-JS. I've already written the time management function, I just need to make it all working together. But currently, if you really want to use time, Réglisse-JS supports the movetime command.

Sorry for my bad English, Paul

PaulJeFi commented 2 years ago

go wtime 60000 winc 3000 btime 60000 binc 3000

I've finally commit the wtime and btime command, but do you have any idea to make time management with increment and not ponder ? Here is my time management function : https://github.com/PaulJeFi/reglisse-chess/blob/b2a7e8a6f54a76ac195d6d4e9bb0b9f2ec9c884f/src/JavaScript/reglisse.js#L2258-L2262

kurt1288 commented 2 years ago

I apologize that I'm not completely sure I understand what you're asking. I think you mean how to set it to use only a certain amount of time (based on wtime or btime and inc) to search rather than searching indefinitely? You have a this.time_to_search variable already, but I'm not sure you're actually setting that in the go function. You are setting a time variable in the go function, but it's a variable that's local to the UCI.on handler. You'll need to try setting the time_to_search variable.

PaulJeFi commented 2 years ago

I'm asking how to decide what amount of time to search for a move given time and inc. Obviously, we need to keep time for the rest of the game. I't easy just with time, but all my trials with inc make the time search explode. Here is a reference : https://www.chessprogramming.org/Time_Management

kurt1288 commented 2 years ago

Ah, sorry for the misunderstanding.

That "how" is the tricky part and it's entirely up to you. The absolute easiest method would just be to divide the remaining time (wtime or btime) by a constant factor, something like time_to_search = btime / 10. You can add the inc in there also however you want. Sometimes even just something like time_to_search = (btime + binc) / 10.

Now, 10 isn't necessarily the best number to chose to divide by. As that Time Management page on the chessprogramming wiki says: "Typically programs estimate the game will last further 25..40 moves, and divide the remaining time by this number". What I've done, and I've seen other engines do, is you sort of just make a very rough estimate of the number of moves left based on how many moves have already been played. Something like "if currentNumberOfMoves < X, then movesLeft = Y". That "Y" factor is what you divide the wtime/btime by, then add your increment, and you get the time to search. Something like time_to_search = (wtime / Y) + winc.

PaulJeFi commented 2 years ago

This issue should be resolved. Please say to me if it's working on Cutechess now.

PaulJeFi commented 2 years ago

This is an old issue. Reglisse-JS should now support UCI times commands.