Win-Win pruning

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

ethanara
Posts: 134
Joined: Mon May 16, 2011 6:58 pm
Location: Denmark

Win-Win pruning

Post by ethanara »

Hi
I just thought about this kind of pruning/time saving when there is a decreased amount of legal moves. Here it is (if no one has thought about this before and if this may improve search, i would like to call it win-win pruning) :

When there is only one legal move:
Do that move. There is no magic in this, but i think that some engines still search a bit, i dont see why they just do the only move and then search after its move.


When there is two possible moves
Here is what i think is new. When there is only two possible moves in root, search the first normally, and if it gets a bad value X, for example down a rook, then do the other move without searching. Also, if gets a very good value Y, then do this move without searching the other. The reason for this is because it doesnt matter if youre down a rook or a queen, or if you are winning witht rook instead of a queen.
If the value is acceptable (under X), then search the other move like normal.
I think it is best if X and Y increases when going further in the game, because being up a knight in the opening is like being up a rook in the endgame, and being up a knight in the endgame may be draw.


Sorry for my bad english, if you dont understand write to me, then i will try to make pseudo-code.
If this shows out to work, please let me know, if this isnt something that has been there before, i will try to implement it in Stockfish and see if it gets any ELO.

Regards
Ethan
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Win-Win pruning

Post by mcostalba »

ethanara wrote:I will try to implement it in Stockfish and see if it gets any ELO.
It won't.

First because it is a special case of a special case so the impact is less than minimal.

Second, I suggest to try to better understand how alpha beta search works, namely if one move is much better than the others, so that beta is set very high (relative to other moves), than all the remaining moves will be very quickly rejected anyhow and you don't need any magic trick for this to happen.

The only interesting thing that I see in your comment is that you are going to do a bit of practice with Stockfish sources...and this is a good thing ;-)
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Win-Win pruning

Post by lucasart »

you should start by uinderstanding how alpha-beta minmax actually works, before suggesting any "improvements". clearly what you suggest is stupid, and the only way you'll understand why is by coding it!
F. Bluemers
Posts: 868
Joined: Thu Mar 09, 2006 11:21 pm
Location: Nederland

Re: Win-Win pruning

Post by F. Bluemers »

ethanara wrote:Hi
I just thought about this kind of pruning/time saving when there is a decreased amount of legal moves. Here it is (if no one has thought about this before and if this may improve search, i would like to call it win-win pruning) :

When there is only one legal move:
Do that move. There is no magic in this, but i think that some engines still search a bit, i dont see why they just do the only move and then search after its move.


When there is two possible moves
Here is what i think is new. When there is only two possible moves in root, search the first normally, and if it gets a bad value X, for example down a rook, then do the other move without searching. Also, if gets a very good value Y, then do this move without searching the other. The reason for this is because it doesnt matter if youre down a rook or a queen, or if you are winning witht rook instead of a queen.
If the value is acceptable (under X), then search the other move like normal.
I think it is best if X and Y increases when going further in the game, because being up a knight in the opening is like being up a rook in the endgame, and being up a knight in the endgame may be draw.


Sorry for my bad english, if you dont understand write to me, then i will try to make pseudo-code.
If this shows out to work, please let me know, if this isnt something that has been there before, i will try to implement it in Stockfish and see if it gets any ELO.

Regards
Ethan
Hi Ethan, these are chopper techniques
They are already know and f.i. PION is using them.
The main virue is a bit more time on the clock.
For the second case I would go only blind for the second move if the first one would be loss to mate.
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Win-Win pruning

Post by tpetzke »

Hi Ethan,

I appreciate that you think about programming and ideas how to improve your program and your will to discuss them. Even if this idea does not work, like Marco told you, keep it up.

You still have plenty of time to think about alpha beta and quite a head start in your generation

Thomas...
ethanara
Posts: 134
Joined: Mon May 16, 2011 6:58 pm
Location: Denmark

Re: Win-Win pruning

Post by ethanara »

Thanks for backing me up :-)
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Win-Win pruning

Post by Evert »

ethanara wrote: When there is only one legal move:
Do that move. There is no magic in this, but i think that some engines still search a bit, i dont see why they just do the only move and then search after its move.
I do this in Jazz, mainly because it looks stupid for the engine to sink deep in thought for several seconds when there is only one move to play. I don't actually think it does anything for playing strength though. It may sound as though you're wasting a lot of time thinking about a variation you can't avoid anyway, but in practice that most likely means you'll have filled the hash table by the time you search the variation again on your next move (assuming you get a ponder hit, which you won't always). Besides, these positions are probably rare except in situations where the game is nearly decided.
When there is two possible moves
Here is what i think is new. When there is only two possible moves in root, search the first normally, and if it gets a bad value X, for example down a rook, then do the other move without searching. Also, if gets a very good value Y, then do this move without searching the other. The reason for this is because it doesnt matter if youre down a rook or a queen, or if you are winning witht rook instead of a queen.
If the value is acceptable (under X), then search the other move like normal.
I think it is best if X and Y increases when going further in the game, because being up a knight in the opening is like being up a rook in the endgame, and being up a knight in the endgame may be draw.
Not a new idea. A question is how you know that one move is clearly good or clearly bad, and the answer is that you know because you look at all of them. As others have already said, in practice you spend a negligible amount of time on late moves anyway (unless they fail high, in which case they're not bad).
A better idea is to recognise "easy" moves, where it's clear that one move outperforms all the other ones. Then you don't burn up all the time allocated to this move and play it more quickly, but the question is how you detect that. This is more about time-management than elo improvement, and I suspect that again it won't win you much. In Jazz, I used to have a bit of code that would abort the search if all but the best move found so far result in a mate-score: it can't possibly be worse. I removed it because it's ugly code, clumsy, error-prone and ultimately worthless in terms of playing strength.
Something else to ponder on: if you're not careful, this sort of selective search can hurt badly. If you would accept, say, any position where you're up a queen and simply cut all the other moves, then you will have a hard time winning KQK.