Lazy promotions

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
leanchess
Posts: 181
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: Lazy promotions

Post by leanchess »

mvanthoor wrote: Tue Apr 14, 2020 10:07 am Lazy promotions aren't even possible with the current rules of chess. If you delay your promotion and then put the piece down on the next move, you're doing a piece drop. It exists in shogi for example (but I don't know if you can do it with promotions; I don't play shogi). You're changing the game.
I didn't propose changing the rules, just the search algorithm.

I'm afraid you're mixing up between two unrelated shogi concepts. There are non-promotions, and then there are piece drops, although both have limitations w.r.t. "stale" squares, e.g. you cannot drop a pawn onto the last rank, and you must promote one once it gets there.

Why would you split the search in four? You just add each promotion to your move list:
Yes, and then proceed to search those four branches. My idea was to postpone splitting the search until depth-2.
User avatar
leanchess
Posts: 181
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: Lazy promotions

Post by leanchess »

My perft now works as follows.

1. The perft state contains a shift variable initialised to 0.
2. Whenever a pawn is promoted, shift increases by 2 (with the pawn entering a state of superposition).
3. Whenever a superimposed piece is moved, shift decreases by 2 (with the piece becoming singular).
4. shift is applied to the leaf count at every depth, including 0.

I hope to publish the code as soon as I weed out the bugs (my perft(7) is now 119,060,320).
Terje
Posts: 347
Joined: Tue Nov 19, 2019 4:34 am
Location: https://github.com/TerjeKir/weiss
Full name: Terje Kirstihagen

Re: Lazy promotions

Post by Terje »

leanchess wrote: Wed Apr 15, 2020 5:50 pm My perft now works as follows.

1. The perft state contains a shift variable initialised to 0.
2. Whenever a pawn is promoted, shift increases by 2 (with the pawn entering a state of superposition).
3. Whenever a superimposed piece is moved, shift decreases by 2 (with the piece becoming singular).
4. shift is applied to the leaf count at every depth, including 0.

I hope to publish the code as soon as I weed out the bugs (my perft(7) is now 119,060,320).
What happens when a king in check by some subset of the possible promotions is trying to move, or a king not in check tries to move into a square attacked by some subset?
User avatar
Ras
Posts: 2698
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Lazy promotions

Post by Ras »

leanchess wrote: Wed Apr 15, 2020 5:50 pm3. Whenever a superimposed piece is moved
I still doubt you'll get a correct perft whenever the super-imposed piece gives check or even just limits the available king squares in the opponent's next turn, i.e. before the piece has moved.

Also, you won't notice the problem in perft 7 from the initial position because that's not deep enough to have a promotion. In 7 alternating plies, a white pawn can only get to rank 7. Rank 8 requires perft 9, and the following black king moves even perft 10. The easy way out is to choose a position where promotion isn't that far ahead.
Terje wrote: Wed Apr 15, 2020 6:09 pmWhat happens when a king in check by some subset of the possible promotions is trying to move, or a king not in check tries to move into a square attacked by some subset?
So far, that problem has been hand-waved away, but perft in a suitable position will tell the truth.
Rasmus Althoff
https://www.ct800.net
User avatar
leanchess
Posts: 181
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: Lazy promotions

Post by leanchess »

Terje wrote: Wed Apr 15, 2020 6:09 pmWhat happens when a king in check by some subset of the possible promotions is trying to move, or a king not in check tries to move into a square attacked by some subset?
Ras wrote: Wed Apr 15, 2020 6:16 pm I still doubt you'll get a correct perft whenever the super-imposed piece gives check or even just limits the available king squares in the opponent's next turn, i.e. before the piece has moved.
My implementation detects either king captures or depth 0 checks. The former don't apply to superposition, while the latter account for all possible states.

Also, you won't notice the problem in perft 7 from the initial position because that's not deep enough to have a promotion. In 7 alternating plies, a white pawn can only get to rank 7. Rank 8 requires perft 9, and the following black king moves even perft 10. The easy way out is to choose a position where promotion isn't that far ahead.
I'm well aware of that. It just seems pointless to test against advanced positions before SP is 100% correct. I'd really appreciate any suggestions w.r.t those missing leaves.
Terje
Posts: 347
Joined: Tue Nov 19, 2019 4:34 am
Location: https://github.com/TerjeKir/weiss
Full name: Terje Kirstihagen

Re: Lazy promotions

Post by Terje »

leanchess wrote: Wed Apr 15, 2020 6:41 pm
Terje wrote: Wed Apr 15, 2020 6:09 pmWhat happens when a king in check by some subset of the possible promotions is trying to move, or a king not in check tries to move into a square attacked by some subset?
Ras wrote: Wed Apr 15, 2020 6:16 pm I still doubt you'll get a correct perft whenever the super-imposed piece gives check or even just limits the available king squares in the opponent's next turn, i.e. before the piece has moved.
My implementation detects either king captures or depth 0 checks. The former don't apply to superposition, while the latter account for all possible states.

Also, you won't notice the problem in perft 7 from the initial position because that's not deep enough to have a promotion. In 7 alternating plies, a white pawn can only get to rank 7. Rank 8 requires perft 9, and the following black king moves even perft 10. The easy way out is to choose a position where promotion isn't that far ahead.
I'm well aware of that. It just seems pointless to test against advanced positions before SP is 100% correct. I'd really appreciate any suggestions w.r.t those missing leaves.
What's the highest depth that is correct?
User avatar
leanchess
Posts: 181
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: Lazy promotions

Post by leanchess »

Terje wrote: Wed Apr 15, 2020 6:49 pm What's the highest depth that is correct?

Code: Select all

perft( 5) =     4865609
Dann Corbit
Posts: 12778
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Lazy promotions

Post by Dann Corbit »

Can you categorize the move types?
Castle moves, capture moves, e.p. capture moves, promotion moves, etc?
I guess that it is a special case move that is causing difficulties.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
leanchess
Posts: 181
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: Lazy promotions

Post by leanchess »

Castling isn't there yet.

I thought about checkmate by castling, but that shouldn't occur until a later ply.
Dann Corbit
Posts: 12778
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Lazy promotions

Post by Dann Corbit »

This thread:
http://talkchess.com/forum3/viewtopic.p ... n+castling

has some special positions designed to test different facets of move generation
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.