Hi,
what is the most efficient way to detect:
1 - unmoved pieces in the opening?
2 - moving the same piece twice in the opening
3 - moving a piece back to its immediately previous position
so that I can give some penalties in the evaluation function.
thx in advance
How to penalize unmoved pieces?
Moderator: Ras
-
- Posts: 363
- Joined: Thu Mar 16, 2006 7:39 pm
- Location: Portugal
- Full name: Alvaro Cardoso
-
- Posts: 1062
- Joined: Tue Apr 28, 2020 10:03 pm
- Full name: Daniel Infuehr
Re: How to penalize unmoved pieces?
You have a simple Bitboards of unmoved pieces.
Once it moves the bit is cleared.
Starting value of unmoved will be 0xFFFF00000000FFFF
So at ply 20 you can enumerate and weigh the bits in (white & pawns & unmoved) with the weights for undeveloped pieces.
Once it moves the bit is cleared.
Starting value of unmoved will be 0xFFFF00000000FFFF
So at ply 20 you can enumerate and weigh the bits in (white & pawns & unmoved) with the weights for undeveloped pieces.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Daniel Inführ - Software Developer
-
- Posts: 48
- Joined: Wed Sep 22, 2021 9:20 pm
- Full name: Jeremy Wright
Re: How to penalize unmoved pieces?
For penalizing unmoved pieces, or pieces that have "undeveloped", Piece-Square Tables are simple and effective: https://www.chessprogramming.org/Piece-Square_Tables
Number 2 is a bit trickier. I think that's out of scope for static evaluation directly. There are many ways one could approach it in search, although generally giving an engine an opinion on places it would like the piece to be (which PSTs also help with) help with this problem.
Number 2 is a bit trickier. I think that's out of scope for static evaluation directly. There are many ways one could approach it in search, although generally giving an engine an opinion on places it would like the piece to be (which PSTs also help with) help with this problem.
Mantissa: https://github.com/jtheardw/mantissa
-
- Posts: 1062
- Joined: Tue Apr 28, 2020 10:03 pm
- Full name: Daniel Infuehr
Re: How to penalize unmoved pieces?
I would not agree:
Moving a piece to it's original square might be good.
Moving it back immediately might also be very good or even forces your opponent into a bad position when you check him and move back.
Not moving a piece for the whole game is bad most of the time.
Moving a piece to it's original square might be good.
Moving it back immediately might also be very good or even forces your opponent into a bad position when you check him and move back.
Not moving a piece for the whole game is bad most of the time.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Daniel Inführ - Software Developer
-
- Posts: 48
- Joined: Wed Sep 22, 2021 9:20 pm
- Full name: Jeremy Wright
Re: How to penalize unmoved pieces?
Sure. That's why you wouldn't only have piece square tables, so other concerns can balance it out contextually. But PSTs are a solid starting point.
Mantissa: https://github.com/jtheardw/mantissa
-
- Posts: 28353
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: How to penalize unmoved pieces?
Moving a piece twice is only bad when there are still pieces around that have not moved at all. By designing the piece-square tables such that the first move pieces can make improves them more than any second move they can make would, you should not have any problems.
-
- Posts: 37
- Joined: Fri Aug 05, 2022 7:58 am
- Full name: Arturs Priede
Re: How to penalize unmoved pieces?
I am working on something like that myself now. My current approach is implementing piece-square-tables. For bishops and knights and kings I have minuscule penalties for the starting squares of the pieces. Encouraging them to move away from those. For kings I also have largest bonuses on castling destination squares. I have not tried the actual weights and how they influence play. I have no penalties for rooks and the queens for starting squares as those pieces shouldn't need extra encouragement to move in the early game.
To my understanding this is only relevant when playing the opening without a book and low depth so I am thinking to phase out the PST eval values with a game-stage weight so they don't skew late midgame / endgame play in some railed direction.
As for penalties for moving a piece twice or moving a piece back to a previously occupied square... Seems like a very artificial heuristic that is not of much use past a child's playing style where you naively move your queen all the time. My engine only recently reached adolescence where it no longer is a huge issue and it was solved with implementing quiescence search. Seems like it no longer likes to move pieces and end the search at depth where pieces are en prise. I so if the engine has any depth at all and sees that the piece will be moved back immediately after going somewhere then the engine probably has a good reason like provoking a permanently weakening pawn move to kick the piece back.
To my understanding this is only relevant when playing the opening without a book and low depth so I am thinking to phase out the PST eval values with a game-stage weight so they don't skew late midgame / endgame play in some railed direction.
As for penalties for moving a piece twice or moving a piece back to a previously occupied square... Seems like a very artificial heuristic that is not of much use past a child's playing style where you naively move your queen all the time. My engine only recently reached adolescence where it no longer is a huge issue and it was solved with implementing quiescence search. Seems like it no longer likes to move pieces and end the search at depth where pieces are en prise. I so if the engine has any depth at all and sees that the piece will be moved back immediately after going somewhere then the engine probably has a good reason like provoking a permanently weakening pawn move to kick the piece back.
-
- Posts: 5695
- Joined: Tue Feb 28, 2012 11:56 pm
Re: How to penalize unmoved pieces?
Regarding 1, unmoved pieces are in suboptimal positions and should be penalised on that ground.
Regarding 2 and 3, if you have a good evaluation function, it should not have to depend on how the position was reached. If a side wastes moves, that should result in a position that is worse than what it can achieve by putting its moves to good use.
The more logical place to deal with 2 and 3 (if at all) is in the search: move ordering and/or reductions/extensions.