Feb 15, 2007

[Bug] Wrong node count

In some complicated positions Mediocre seemed to drop its node count way below the average. I never really figured out why since the type of position should have nothing to do with the number of nodes visited per second. It could affect the number of plies, but that is another matter.

One position I had this problem with was this one:
2rq1rk1/p5bp/bp2pnp1/n1ppNp2/2PP4/PP1BPN2/1B3PPP/2RQ1RK1 b - - 3 14

It is a fairly complicated position with many captures going on. Mediocre searches it like this:








Ply Eval  Time  Nodes Line
1 -15 140 36 Bb7
2 -25 219 179 Bb7 Qc2
3 -15 875 678 Bb7 Qc2 Nc6
4 -15 1156 2040 Bb7 Qc2 Nc6 Rb1
5 -10 4906 9434 Bb7 Qc2 Nc6 cxd5 exd5
6 -15 11359 29397 Bb7 Qc2 Nc6 Nxc6 Bxc6 Ne5
7 -10 53578 152535 Bb7 cxd5 Qxd5 b4 Qa2 Qe2 Nb3
As you can see it takes quite some time to get to 7 plies depth. But the node count is only 152535. That kind of node count takes about a second in most positions, and not 53 seconds like here.

I could never really figure out why this was. Of course it has something to do with quiescent search since that is the only place the engine could spend that kind of time without getting farther in the search.

And then today I was looking through the source code of some other engines and found a missing line.

Mediocre only increases its node count at the beginning of every alphaBeta()-call. But even though quiescent search has a limited number of moves to choose from, every position it finds is also a node, so of course the number of nodes should be increased there as well.

So I made quiescent search nodes add to the total nodes searched as well and the result was this in the same position.
Ply Eval  Time   Nodes Line
1 -15 140 7484 Bb7
2 -25 218 19992 Bb7 Qc2
3 -15 687 97129 Bb7 Qc2 Nc6
4 -15 953 140802 Bb7 Qc2 Nc6 Rb1
5 -10 4234 674731 Bb7 Qc2 Nc6 cxd5 exd5
6 -15 10390 1675138 Bb7 Qc2 Nc6 Nxc6 Bxc6 Ne5
7 -10 50812 8200247 Bb7 cxd5 Qxd5 b4 Qa2 Qe2 Nb3
Exactly the same evaluation and line, and time used is about the same (this differs some from search to search of course). But the node count is fifty times as high.

Conclusion

This does not affect the search speed, or evaluation, or anything else. But it does give us a much better view of how much time Mediocre uses to go through a certain amount of nodes.

The pruning of Mediocre was appearing to be quite awesome, and the nodes per second terrible. With this change we can see that Mediocre is not so bad when it comes to pruning (but not -that- good :), and it is also not as slow calculating nodes as it would have appeared.

As said this is only a matter of presentation and has nothing to do with the search itself. However comparisons to other programs will become much easier now.

No comments: