TT Succesful hits

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: TT Succesful hits

Post by bob »

xsadar wrote:
bob wrote:
xsadar wrote:
wgarvin wrote:
bob wrote:I do it the more correct way and do _not_ set the EP target if no EP capture is possible. Why would you want to do that since in a position where white has a pawn on the e file, and black has no pawns on the D or F files, it doesn't matter whether white plays e2-e4 or e3-e4, the two positions are _identical_. I've always done this the correct way and only set the EP target if an EP capture is actually possible, which means the Zobrist key does not get modified on e2-e4 unless black actually has a pawn on d4 or f4...

I don't see why anyone would do it any other way.
Not only that, but (as was discussed in a different thread here a while ago) if you use the Zobrist keys for repetition detection, then a "phantom EP square" could make the repetition code think that a position was not a repeat when it actually was (or vice versa). In the interests of correctness, he should NOT put any EP square into the Zobrist key unless a pawn is in the correct place to capture it. It is the only sensible way to handle it.
To be completely correct, you would have to determine if the EP move leaves the mover in check. Personally, I think it's a waste of time to determine that while making the pawn advance move during a search. It won't hurt much if the engine thinks the second repetition is not a repetition if the pawn advance hasn't even been made on the board yet. However, once the move is made on the board, I agree that the zobrist key MUST be correct, which means that you not only need to make sure there is a pawn there to capture it, but also that capturing it would not put the mover in check.

Edit: Just for clarification, by 'made on the board', I mean the actual game board that the opponent sees.
The repetition detection is not important when you think about it. :) Once you push a pawn, a repetition is impossible with previous positions.
We're talking about repetition of a position following a two-square pawn push where en passant is not a legal move. Obviously it can't be a repetition of a previous position, but it can be repeated later. So once the pawn push has been played over the board, it's important to have the correct zobrist so we recognize if the position is repeated in the future. If the move was only played in the search, however, not having the phantom ep in the zobrist is not nearly as important, and probably not worth determining if ep is fully-legal (as opposed to only pseudo-legal) while we're making the two-square pawn move. We might as well just wait until we make the ep move (or at least generate it) to determine that.
On the other side of the EP or not-EP move, you're right. I was thinking about positions before, but starting the new sequence off with a bogus hash signature could cause a problem. My only error in Crafty is that I do not screen for legality.
diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: TT Succesful hits

Post by diep »

bob wrote:
xsadar wrote:
bob wrote:
xsadar wrote:
wgarvin wrote:
bob wrote:I do it the more correct way and do _not_ set the EP target if no EP capture is possible. Why would you want to do that since in a position where white has a pawn on the e file, and black has no pawns on the D or F files, it doesn't matter whether white plays e2-e4 or e3-e4, the two positions are _identical_. I've always done this the correct way and only set the EP target if an EP capture is actually possible, which means the Zobrist key does not get modified on e2-e4 unless black actually has a pawn on d4 or f4...

I don't see why anyone would do it any other way.
Not only that, but (as was discussed in a different thread here a while ago) if you use the Zobrist keys for repetition detection, then a "phantom EP square" could make the repetition code think that a position was not a repeat when it actually was (or vice versa). In the interests of correctness, he should NOT put any EP square into the Zobrist key unless a pawn is in the correct place to capture it. It is the only sensible way to handle it.
To be completely correct, you would have to determine if the EP move leaves the mover in check. Personally, I think it's a waste of time to determine that while making the pawn advance move during a search. It won't hurt much if the engine thinks the second repetition is not a repetition if the pawn advance hasn't even been made on the board yet. However, once the move is made on the board, I agree that the zobrist key MUST be correct, which means that you not only need to make sure there is a pawn there to capture it, but also that capturing it would not put the mover in check.

Edit: Just for clarification, by 'made on the board', I mean the actual game board that the opponent sees.
The repetition detection is not important when you think about it. :) Once you push a pawn, a repetition is impossible with previous positions.
We're talking about repetition of a position following a two-square pawn push where en passant is not a legal move. Obviously it can't be a repetition of a previous position, but it can be repeated later. So once the pawn push has been played over the board, it's important to have the correct zobrist so we recognize if the position is repeated in the future. If the move was only played in the search, however, not having the phantom ep in the zobrist is not nearly as important, and probably not worth determining if ep is fully-legal (as opposed to only pseudo-legal) while we're making the two-square pawn move. We might as well just wait until we make the ep move (or at least generate it) to determine that.
On the other side of the EP or not-EP move, you're right. I was thinking about positions before, but starting the new sequence off with a bogus hash signature could cause a problem. My only error in Crafty is that I do not screen for legality.
What you mean to say: "i go for speed in crafty, if you want to slowdown major league, be my guest".
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: TT Succesful hits

Post by bob »

diep wrote:
bob wrote:
xsadar wrote:
bob wrote:
xsadar wrote:
wgarvin wrote:
bob wrote:I do it the more correct way and do _not_ set the EP target if no EP capture is possible. Why would you want to do that since in a position where white has a pawn on the e file, and black has no pawns on the D or F files, it doesn't matter whether white plays e2-e4 or e3-e4, the two positions are _identical_. I've always done this the correct way and only set the EP target if an EP capture is actually possible, which means the Zobrist key does not get modified on e2-e4 unless black actually has a pawn on d4 or f4...

I don't see why anyone would do it any other way.
Not only that, but (as was discussed in a different thread here a while ago) if you use the Zobrist keys for repetition detection, then a "phantom EP square" could make the repetition code think that a position was not a repeat when it actually was (or vice versa). In the interests of correctness, he should NOT put any EP square into the Zobrist key unless a pawn is in the correct place to capture it. It is the only sensible way to handle it.
To be completely correct, you would have to determine if the EP move leaves the mover in check. Personally, I think it's a waste of time to determine that while making the pawn advance move during a search. It won't hurt much if the engine thinks the second repetition is not a repetition if the pawn advance hasn't even been made on the board yet. However, once the move is made on the board, I agree that the zobrist key MUST be correct, which means that you not only need to make sure there is a pawn there to capture it, but also that capturing it would not put the mover in check.

Edit: Just for clarification, by 'made on the board', I mean the actual game board that the opponent sees.
The repetition detection is not important when you think about it. :) Once you push a pawn, a repetition is impossible with previous positions.
We're talking about repetition of a position following a two-square pawn push where en passant is not a legal move. Obviously it can't be a repetition of a previous position, but it can be repeated later. So once the pawn push has been played over the board, it's important to have the correct zobrist so we recognize if the position is repeated in the future. If the move was only played in the search, however, not having the phantom ep in the zobrist is not nearly as important, and probably not worth determining if ep is fully-legal (as opposed to only pseudo-legal) while we're making the two-square pawn move. We might as well just wait until we make the ep move (or at least generate it) to determine that.
On the other side of the EP or not-EP move, you're right. I was thinking about positions before, but starting the new sequence off with a bogus hash signature could cause a problem. My only error in Crafty is that I do not screen for legality.
What you mean to say: "i go for speed in crafty, if you want to slowdown major league, be my guest".
Probably isn't that big a slow-down. All I need to ask is "is this pawn on a diagonal with the king? If so does it block a bishop/queen. Ditto for rank/file. It is only done on double pawn pushes which are rare enough. I have this code in GenerateChecks() already. I moved it to MakeMove() and didn't notice either any slower execution or for a half-dozen quick tests any difference in node counts. My general rule has been "if it doesn't help, it doesn't stay"...