definition of a node

Discussion of chess software programming and technical issues.

Moderator: Ras

AndrewShort

definition of a node

Post by AndrewShort »

I know there was a long thread on this a while back, but I cannot find it...

I simply would like to know what the _conventional_ way is to count nodes searched. I know this isn't really that important, but for the purposes of comparing apples to apples, I would like to count nodes searched conventionally.

My engine counts calls to MakeMove() when called from AlphaBeta() and Quies(). It ignores calls to MakeNullMove()

As my engine uses a pseudo-legal move generator, the count is made even if the move is determined to be illegal (King was left/placed in check). Or is it conventional to only count legal nodes? It's trivial for me to change the count to legal nodes only...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: definition of a node

Post by bob »

AndrewShort wrote:I know there was a long thread on this a while back, but I cannot find it...

I simply would like to know what the _conventional_ way is to count nodes searched. I know this isn't really that important, but for the purposes of comparing apples to apples, I would like to count nodes searched conventionally.

My engine counts calls to MakeMove() when called from AlphaBeta() and Quies(). It ignores calls to MakeNullMove()

As my engine uses a pseudo-legal move generator, the count is made even if the move is determined to be illegal (King was left/placed in check). Or is it conventional to only count legal nodes? It's trivial for me to change the count to legal nodes only...
The simplest approach is to increment nodes_searched at the top of search, and at the top of quiesce, or whatever you call your functions. That is accurate enough unless you find yourself making/unmaking moves inside the search for other reasons...
BubbaTough
Posts: 1154
Joined: Fri Jun 23, 2006 5:18 am

Re: definition of a node

Post by BubbaTough »

bob wrote:
AndrewShort wrote:I know there was a long thread on this a while back, but I cannot find it...

I simply would like to know what the _conventional_ way is to count nodes searched. I know this isn't really that important, but for the purposes of comparing apples to apples, I would like to count nodes searched conventionally.

My engine counts calls to MakeMove() when called from AlphaBeta() and Quies(). It ignores calls to MakeNullMove()

As my engine uses a pseudo-legal move generator, the count is made even if the move is determined to be illegal (King was left/placed in check). Or is it conventional to only count legal nodes? It's trivial for me to change the count to legal nodes only...
The simplest approach is to increment nodes_searched at the top of search, and at the top of quiesce, or whatever you call your functions. That is accurate enough unless you find yourself making/unmaking moves inside the search for other reasons...
I do what Bob said. Initially I only did it at the top of search, and wondered why I was so much slower than all others. Once I added Quiesc() I spend up significantly :).

-Sam
AndrewShort

Re: definition of a node

Post by AndrewShort »

bob wrote:
AndrewShort wrote:I know there was a long thread on this a while back, but I cannot find it...

I simply would like to know what the _conventional_ way is to count nodes searched. I know this isn't really that important, but for the purposes of comparing apples to apples, I would like to count nodes searched conventionally.

My engine counts calls to MakeMove() when called from AlphaBeta() and Quies(). It ignores calls to MakeNullMove()

As my engine uses a pseudo-legal move generator, the count is made even if the move is determined to be illegal (King was left/placed in check). Or is it conventional to only count legal nodes? It's trivial for me to change the count to legal nodes only...
The simplest approach is to increment nodes_searched at the top of search, and at the top of quiesce, or whatever you call your functions. That is accurate enough unless you find yourself making/unmaking moves inside the search for other reasons...
Really? The very top of AlphaBeta() and Quies() - that means counting the node whether it will be a hash it or not, and whether or not it's a horizon node. TSCP counts nodes only if depth is not 0....
Edmund
Posts: 670
Joined: Mon Dec 03, 2007 3:01 pm
Location: Barcelona, Spain

Re: definition of a node

Post by Edmund »

if you count before the if (depth == 0)
you would count leaf nodes twice. Once in AlphaBeta and the second time in QS
AndrewShort

Re: definition of a node

Post by AndrewShort »

Codeman wrote:if you count before the if (depth == 0)
you would count leaf nodes twice. Once in AlphaBeta and the second time in QS
that's right, which is why I find it hard to believe people count nodes at the very top of search. It means double counting....
User avatar
Zach Wegner
Posts: 1922
Joined: Thu Mar 09, 2006 12:51 am
Location: Earth

Re: definition of a node

Post by Zach Wegner »

AndrewShort wrote:
Codeman wrote:if you count before the if (depth == 0)
you would count leaf nodes twice. Once in AlphaBeta and the second time in QS
that's right, which is why I find it hard to believe people count nodes at the very top of search. It means double counting....
Not all people call search in the same way. ;)

I, and Bob too IIRC, use:

Code: Select all

for(all moves)
{
   make()
   if (depth <= 0)
     qsearch();
   else
     search();
   unmake();
}
Except in my case it's a lot more complicated because it's not recursive.
BubbaTough
Posts: 1154
Joined: Fri Jun 23, 2006 5:18 am

Re: definition of a node

Post by BubbaTough »

AndrewShort wrote:
Codeman wrote:if you count before the if (depth == 0)
you would count leaf nodes twice. Once in AlphaBeta and the second time in QS
that's right, which is why I find it hard to believe people count nodes at the very top of search. It means double counting....
You better believe it buddy. I double count :oops:. Its not completely clear what a better way of doing it is (with no overhead) but if someone posts one I guess I will conform. I just want to do what others do so I can compare, node counts for their own sake are not that interesting to me.

-Sam
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: definition of a node

Post by bob »

AndrewShort wrote:
bob wrote:
AndrewShort wrote:I know there was a long thread on this a while back, but I cannot find it...

I simply would like to know what the _conventional_ way is to count nodes searched. I know this isn't really that important, but for the purposes of comparing apples to apples, I would like to count nodes searched conventionally.

My engine counts calls to MakeMove() when called from AlphaBeta() and Quies(). It ignores calls to MakeNullMove()

As my engine uses a pseudo-legal move generator, the count is made even if the move is determined to be illegal (King was left/placed in check). Or is it conventional to only count legal nodes? It's trivial for me to change the count to legal nodes only...
The simplest approach is to increment nodes_searched at the top of search, and at the top of quiesce, or whatever you call your functions. That is accurate enough unless you find yourself making/unmaking moves inside the search for other reasons...
Really? The very top of AlphaBeta() and Quies() - that means counting the node whether it will be a hash it or not, and whether or not it's a horizon node. TSCP counts nodes only if depth is not 0....
Think about it this way. At the previous ply you generated moves. Then you picked one, made it, and then you call search/quiesce recursively. That is the _definition_ of a new node. A node is a position. An arc from a node is equivalent to a move. Each time you make a move, you are producing a new position/node, and incurring the overhead needed to update your data structures.

If TSCP is counting nodes in that way, it is doing it wrong. A node is a node whether it is an interior node (remaining depth > 1), a frontier node (remaining depth == 1, the last place where you have any choice about playing captures or non-captures and can not stand pat) or a leaf node (remaining depth = 0 where you can search captures or stand pat.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: definition of a node

Post by bob »

AndrewShort wrote:
Codeman wrote:if you count before the if (depth == 0)
you would count leaf nodes twice. Once in AlphaBeta and the second time in QS
that's right, which is why I find it hard to believe people count nodes at the very top of search. It means double counting....
How do you figure that? I count at the top of search, where I enter once for each move made at previous level in tree. I then call quiesce after making a move, which is a new position. So I don't see how you can possibly call that "double counting"...