Perft with semi-legal move generator

Discussion of chess software programming and technical issues.

Moderator: Ras

trojanfoe

Perft with semi-legal move generator

Post by trojanfoe »

I am trying to verify the move generator I have recently coded and perft seems to be a good method, however am I right in thinking that the perft node count you can expect referenced (for example here: http://mediocrechess.blogspot.com/2007/ ... cores.html) is for move generators that only generate 100% legal moves.

The problem is that my move generator doesn't consider checks during generation, only castling rights and en-passant captures. I can't imagine I'm alone in this.

Are there perft figures for such a move generator available anywhere I can use to verify my generator?

Also why is it called 'perft'? What's the origin of this term?

Thanks in advance,
Andy
Greg McGlynn

Re: Perft with semi-legal move generator

Post by Greg McGlynn »

I do the same thing as you. Inside the perft function (and in the regular search) when I am about to make a move I check to see if it is an illegal castle. If not I make the move and then check to see if the side that just moved is illegally in check. If so I unmake the move and act like it never happened. Otherwise the move is not an illegal castle or a move into check, so it's legal. Perhaps there are better or more efficient ways of doing this.

And I think I read that perft stands for "performance test."
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Perft with semi-legal move generator

Post by sje »

trojanfoe wrote:The problem is that my move generator doesn't consider checks during generation, only castling rights and en-passant captures. I can't imagine I'm alone in this.

Are there perft figures for such a move generator available anywhere I can use to verify my generator?
I call it "movepath enumeration".

Not everyone agrees on the exact definition of pseudolegal move, so you are unlikely to find any reliable comparative statistics.

Once you have a proper legal move filter (you need one anyway), you won't have to be concerned with pseudolegal move counts.
User avatar
pedrox
Posts: 1056
Joined: Fri Mar 10, 2006 6:07 am
Location: Basque Country (Spain)

Re: Perft with semi-legal move generator

Post by pedrox »

I see a difference between winboard engines and uci engines.

Most engines uci have more information update, indicates number of moves left to consider at this depth, total number of moves to consider in this position and current move.

To this seems necessary to take legal moves filter, but I imagine that this is only necessary to do so in the root.
Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: Perft with semi-legal move generator

Post by Gerd Isenberg »

trojanfoe wrote: Are there perft figures for such a move generator available anywhere I can use to verify my generator?

Also why is it called 'perft'? What's the origin of this term?

Thanks in advance,
Andy
http://chessprogramming.wikispaces.com/Perft
trojanfoe

Re: Perft with semi-legal move generator

Post by trojanfoe »

Many thanks guys - so it looks like I'm going to have to filter out the illegal moves. Actually the only illegal moves I don't already filter are exposed checks, as I keep an attack mask for each side with each position and can easily check for moving into check or castling through check.

I was planning to look for exposed check when generating the next ply (during the search) and then retroactively mark the parent node as illegal - I suppose for Perft checking I could just do one additional check.

Cheers,
Andy
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Perft with semi-legal move generator

Post by sje »

If your program can keep track of which pieces are pinned, then it's not all that difficult to write a move generator that produces only legal moves.
trojanfoe

Re: Perft with semi-legal move generator

Post by trojanfoe »

Hmmm... as I generate the attack mask which making the move in the position I should already be filtering for exposed check. Looks like I have a bug then. Good - something to hunt for :)


Cheers,
Andy