Counting nodes

Discussion of computer chess matches and engine tournaments.

Moderator: Ras

User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Counting nodes

Post by algerbrex »

I’ve noticed in some engines, nodes are counted at the top of the alphabeta search, and also at the top of the quiescence search. Of course this means that when depth <= 0, a node is counted “twice,” once at the top of the alphabeta search, and then when the search detects depth <= 0, also at the top of the quiescence search.

Now, I can see both sides and don’t have a strong preference. Not “double counting” makes sense because you’re not actually doing any work in the main search when depth <= 0, but OTOH, you’re still visiting the node at least once in the main search, whether you actually do any work in it or not.

As I said, I have no strong preference, but which do other engine authors prefer?
User avatar
lithander
Posts: 915
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Counting nodes

Post by lithander »

Double counting seems wrong to me. I also don't count a node when I found a TT hit for it.

The cheapest way to increase the node-counter in Leorik is when we can return from evaluating a node early in quiescence search due to standing pat. (Return beta if side to move is not in check and the static evaluation is already above beta)

...also this is in the wrong Sub-forum, right? ;)
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: Counting nodes

Post by algerbrex »

lithander wrote: Mon Jul 18, 2022 12:23 am ...also this is in the wrong Sub-forum, right? ;)
Oops :oops: hopefully one of the mods can move it.
User avatar
RubiChess
Posts: 647
Joined: Fri Mar 30, 2018 7:20 am
Full name: Andreas Matthies

Re: Counting nodes

Post by RubiChess »

At some point I switched from increment nodes in search but not in qsearch to increment nodes when a move is played.
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: Counting nodes

Post by algerbrex »

RubiChess wrote: Mon Jul 18, 2022 6:56 am At some point I switched from increment nodes in search but not in qsearch to increment nodes when a move is played.
That's also fair, I've seen that approach used as well, and it makes sense to me. You create a new node and visit a new position when a move is made - assuming the move has been confirmed to legal and isn't pruned away.
abulmo2
Posts: 481
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Counting nodes

Post by abulmo2 »

RubiChess wrote: Mon Jul 18, 2022 6:56 am At some point I switched from increment nodes in search but not in qsearch to increment nodes when a move is played.
In alphabeta derivates where a re-search is done again like PVS/negascout you may miss some nodes that way.
Richard Delorme
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Counting nodes

Post by Mike Sherwin »

To be pristine only nodes visited in the actual upper most level of the alpha/beta search should be counted. For example if at every Search() I.D. is used as in 1 to depth - 1 to order the moves for the final depth none of the 1 to depth - 1 nodes should be counted. They are not part of the upper most level tree. Same for I.D. of depth - 2 if no hash move was found. In RomiChess I use a shallow search to order the moves and those nodes are counted but they should not have been. The question should be how many "official" nodes were visited in the search to reach the depth that was reached. IMNSHO.