I saw that some peoples does the action of move/undo of the last depth and some people just count the number of valid move of the last depth without doing them.
nodes/sec are day and night between the two
what is the proper/correct way?
about perft, what is the proper way of doing it?
Moderators: hgm, Rebel, chrisw
-
- Posts: 95
- Joined: Fri Nov 09, 2012 12:36 am
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: about perft, what is the proper way of doing it?
Do what you like? There is no official perft competition with official rules that you have to adhere to. Both will give the same counts when done correctly.spirch wrote:I saw that some peoples does the action of move/undo of the last depth and some people just count the number of valid move of the last depth without doing them.
nodes/sec are day and night between the two
what is the proper/correct way?
If you want to compare the speed of your move generation and make/unmake to a particular other program, then it's best to do it the way that other program does it.
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: about perft, what is the proper way of doing it?
As Ronald already stated, both ways are proper and correct. What most people do in "perft" is actually bulk counting, i.e. counting all legal moves of the last ply. For this to be more efficient than the straightforward make/unmake you need to implement a way to test move legality without making/unmaking all moves, otherwise there is no saving of course. The trick is that only few moves can be illegal when assuming the usual way of pseudo-legal move generation:spirch wrote:I saw that some peoples does the action of move/undo of the last depth and some people just count the number of valid move of the last depth without doing them.
nodes/sec are day and night between the two
what is the proper/correct way?
- check evasions,
- king moves (incl. castling),
- ep captures,
- moves of pinned pieces.
Only for these moves a make/unmake would be needed for legality testing (and depending on your program's intelligence even some of these can be tested quicker than by make/unmake, e.g. king moves by only testing attacks to the target square).
One advantage of a fast "perft" during development of your basic engine functionality (board, move generation, make/unmake etc.) is that you get your verification results more quickly so you are slightly more productive than with a slow perft.
In any case I propose that you let your program explicitly state the meaning of your results regarding speed, i.e. print both "nodes per second" and "leaves per second" in the output.
Sven
-
- Posts: 95
- Joined: Fri Nov 09, 2012 12:36 am
Re: about perft, what is the proper way of doing it?
I'm going to do that, explicitly state what my numbers mean.
thanks.
thanks.
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: about perft, what is the proper way of doing it?
There is a difference between ´nodes per second´ and ´moves per second´. I always thought the best comparison with an engine is when you do not make/unmake the last ply. Because in engines your tree also ends with generating moves, then concluding that you have no non-futile non-bad captures, so you won´t make any of them.