How to setup a "move fake waiting time" in Lc0 ?

175 views
Skip to first unread message

Andrea Gatti

unread,
Sep 30, 2022, 2:28:10 PM9/30/22
to LCZero
Hi everyone,

new to this group and a new user of Lc0 on  my Android apps.

I'm assuming the question I have, has already come up, but despite I used the forum's search function, I could not find a reply to it, so here it is:

On my Android device, if I set the number of nodes to be searched to 1 (one), to make Lc0 use only the Neural Network and basically avoid doing any search, I find that Lc0 moves instantly. This instant move happens despite setting long time controls.

I would like therefore to setup lc0 in a way that a sort of "move fake wait time" is setup. The thing to obtain, is that Lc0 does not move immediately, but take a reasonable time to execute the move, according to the time control, or anyway not instantly.

How to do that?

Many thanks for the help!

regards

Andrea

brian.p.r...@gmail.com

unread,
Oct 2, 2022, 2:50:02 AM10/2/22
to LCZero
You cannot have it both ways: it is either how many nodes or how much time to use.
This is less a function of Leela and more how engines traditionally work with GUIs.

Also, note this pinned post in the #general channel:
borg09/22/2022
For just one node per move is probably OK to just use go nodes 1 but if you want to do exact number of nodes then you need something like --threads=1 --task-workers=0 --minibatch-size=1 --max-prefetch=0 --smart-pruning-factor=0 --nncache=0 - it will be slow but get the number of nodes you asked for.

Finally, there might be some additional tweaks on Android.

Andrea Gatti

unread,
Oct 2, 2022, 4:20:11 PM10/2/22
to LCZero
Hi, thank-you for taking the time to respond. Unfortunately the suggested setup does not work as intended: Lc0 still executes a search. I tried putting these into the lc0.config file:

--threads=1
--task-workers=0
--minibatch-size=1
--max-prefetch=0
--smart-pruning-factor=0
--nncache=0

but a search is started anyway, while I wanted to not execute a search (basically have nodes searched=1).

Regards Andrea.

Robert Clark

unread,
Oct 3, 2022, 3:06:43 AM10/3/22
to Andrea Gatti, LCZero
Let me discuss this in a different way, because I think you are trying to do something that does not match the way LC0 works. I need to point out that I don't understand everything about this, but I do have a clear sense why you can't just tell LC0 to keep evaluating the same node for an hour.  (And everyone please jump in and correct me if what I say here is wrong.)

At the heart of LC0 is a neural network that has been trained to 'understand' chess. This neural network takes as input a rather complicated description of the position being evaluated, and returns an evaluation of the position (the node in the move tree that is being evaluated), which I believe to be a value representing the 'goodness' of the position, and a list of all possible moves from the current node with an estimate of which move is most likely to be made.

So I *think* that when you say nodes=1 you are in effect saying, 'which move from this position is best without looking past a static evaluation of each new position'. In other words, don't look down a tree of future nodes, just evaluate this node and the moves from it. That evaluation is a fixed piece of computing (run the neural net) that runs very fast on good hardware, and it is the best that LC0 can do without examining the move tree into the future. So there is no way to say 'nodes 1' and have it take longer than it takes. The node is already being evaluated to the best of LC0s ability (and it plays pretty strong chess without using the tree. No way I could beat even a modest-sized net with nodes 1.)  The way play gets stronger with higher node counts is to build the tree and use the neural net to  evaluate nodes farther down the tree to refine the assessment of which move is best at the root node. (I'm omitting here any detailed description of how this is done.)

There is one way that, in principle, your objective could be pursued. That would be to use a larger neural net, which executes the evaluation more slowly, but with better accuracy. But it is not a winning strategy to make the neural net arbitrarily large, because the training costs become huge, and at a certain point, the gain from having the neural network bigger is not worth the drop in the number of nodes that can be evaluated. Each node would evaluate better, but more slowly, and the tree that could be examined for each move would be smaller. At some point the smaller tree would overcome the advantage of better evaluation of each node. I think there is some sweet spot for any given hardware configuration where the speed of node evaluation vs the quality of the evaluation produces the best result. And there are likely other factors.

So all of this is a little bit hand-wavy, but I hope it helps.

Robert

--
You received this message because you are subscribed to the Google Groups "LCZero" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lczero+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lczero/b0a14b86-6bdc-4261-9bca-fc638a5d17ean%40googlegroups.com.

Andrea Gatti

unread,
Oct 3, 2022, 4:16:21 AM10/3/22
to LCZero
Hi Robert, again many thanks for the time you're putting into this, and the efforts to try and help me.

I read with interest all that you wrote. I suspect you're (formally in a correct way!) trying to help me at a "higher level" than the (basic level) of my initial trivial question. Let me try to explain a bit better.

To clarify even better what I'm doing and what I'm trying to achieve: I'm using Lc0 with the so-called Maia networks (https://maiachess.com/). I'm therefore using the Maia ELO=1200 network to have lc0 play a much weaker chess than it could actually do, but with a pleasant (for me) human style.

Everything works, with the exception that Maia (let's call it Maia, even if the chess engine is lc0 0.28) moves instantly. You can set a long time control, but Maia moves instantly. Based on your explanations, I today understand why.

But I would like Maia does NOT play instantly, because it is frustrating, and does not emulate a human player behavior.

So after a number of config changes and trials, I wrote to the Maia people (those who have put together the Maia networks for lc0), who wrote me in an email, that on Lichess, where they created Maia bots, they had to implement a sort of "fake move time" to avoid that Maia moved instantly. They did so as a response to the Lichess community, who were claiming that Maia was playing innaturally, i.e. was playing instantly.

"This is good!" I said to myself, looks like Lichess users had my same issue, and based on what the Maia developers are saying, a way to artificially inflate the move time in lc0-Maia exists, because they implemented this into the Licess Maia bots.

I wrote to those Maia developers asking how to set this artifical move time on, and never got a reply to such question.

It may be a sensitive aspect, it may be a developement secret, it may be that they did not read my question - I don't know, I can only speculate.

After not getting an answer to my question - but being sure that it is technically possible, I raised the same question into this Google group, which all led to your kind and technically accurate replies to my question (of which, again, I thank-you).

I hope this clears a bit more the roots of my question, and what I'd like to achieve and why.

Thanks!

Andrea.

Fabrice Del

unread,
Oct 3, 2022, 4:32:08 AM10/3/22
to Andrea Gatti, LCZero
Hi, I realy thing that this is not à Lc0 problem but more a chess GUI feature. 
I don't know which GUI you are using but you should definetly investigate in this direction.
Regards

Andrea Gatti

unread,
Oct 3, 2022, 12:15:59 PM10/3/22
to LCZero
Hi there.

believe it or not, I probably have found a way to achieve what I needed. The trick seems to be setting the following parameter into the lc0 configuration file:

NodesPerSecondLimit=0.000000001

Setting it to a so low value, has the effect of forcing lc0 to really search slow, basically equal at nodes=1, and also it respects the move time.

Regards

AG 

Reply all
Reply to author
Forward
0 new messages