Comments on https://lichess.org/@/jk_182/blog/quantifying-piece-activity/OPrLdoVq
Very nice, as always!
I do think that there is a mistake in averaging anything. Can the piece move there? Then it's an addition to activity. Nothing to average.
I guess the difficulty lies in determining if a square is actually free to move. So it has to be tightly coupled with square control.
Then there is the power of a piece. You can move a pawn in the center of the board, but it controls 2 squares. The "value" of having a center square to move to is very different from a queen's.
Moreover, I think that secondary activity is also important. If the piece has only one square to go, but from there it can go to the center and control the whole board, that's something that is valuable, but not quantified. Obviously, we use something like piece activity in the value function BEFORE we start recursing, so we never think of recursive piece activity calculation.
I would go for this:
- eliminate any averaging
- eliminate the arbitrary value of individual squares
- for each piece:
- get all the squares it can move to, freely or by capture
- eliminate the ones that are under enemy control (by lower values pieces, this is somewhat vague)
- the simple activity for the piece is the count of those squares
- for each square, calculate the simple activity of the piece if it were moved there
- the final activity for the piece is the sum of 1 + a percentage of the increase in activity for the piece if moving to each square.
- the total activity is the sum of the final activity for each piece
So if a queen only has one square to go, it has a simple activity of 1, but if by going there it gets an activity of 10, then it has an activity of 1+q*(10-1), where q is the percentage. Let's say q=0.1, then it will have an activity of 1.9.
If it has a simple activity of 10, but for each square it goes to it reaches a point where the simple activity drops to 1, then the final activity would be 10 * (1 + (1-10)q) = 100.1 = 1.
Maybe 0.1 is too much, anyway, you get the point.
Very nice, as always!
I do think that there is a mistake in averaging anything. Can the piece move there? Then it's an addition to activity. Nothing to average.
I guess the difficulty lies in determining if a square is actually free to move. So it has to be tightly coupled with square control.
Then there is the power of a piece. You can move a pawn in the center of the board, but it controls 2 squares. The "value" of having a center square to move to is very different from a queen's.
Moreover, I think that secondary activity is also important. If the piece has only one square to go, but from there it can go to the center and control the whole board, that's something that is valuable, but not quantified. Obviously, we use something like piece activity in the value function BEFORE we start recursing, so we never think of recursive piece activity calculation.
I would go for this:
- eliminate any averaging
- eliminate the arbitrary value of individual squares
- for each piece:
- get all the squares it can move to, freely or by capture
- eliminate the ones that are under enemy control (by lower values pieces, this is somewhat vague)
- the simple activity for the piece is the count of those squares
- for each square, calculate the simple activity of the piece if it were moved there
- the final activity for the piece is the sum of 1 + a percentage of the increase in activity for the piece if moving to each square.
- the total activity is the sum of the final activity for each piece
So if a queen only has one square to go, it has a simple activity of 1, but if by going there it gets an activity of 10, then it has an activity of 1+q*(10-1), where q is the percentage. Let's say q=0.1, then it will have an activity of 1.9.
If it has a simple activity of 10, but for each square it goes to it reaches a point where the simple activity drops to 1, then the final activity would be 10 * (1 + (1-10)*q) = 10*0.1 = 1.
Maybe 0.1 is too much, anyway, you get the point.
I like the idea but I think that the execution wasn't that great for example I would argue that in the first position white had much better piece activity even before the trades.
Controlling h8 for example is usually less important then for example f7.
Maybe using piece table that engine used for evaluating pieces activity would give a better extimation.
There is a lot of solutions to the trading problem, some simple and some complicated
I like the idea but I think that the execution wasn't that great for example I would argue that in the first position white had much better piece activity even before the trades.
Controlling h8 for example is usually less important then for example f7.
Maybe using piece table that engine used for evaluating pieces activity would give a better extimation.
There is a lot of solutions to the trading problem, some simple and some complicated
What do people think about adding an engine evaluation to the heuristic for piece activity? Intuitively, even if a knight has access to many squares it wouldn't be considered active if all those squares are also attacked by the opponent's pawns - that would be considered a trapped knight (as inactive as you can be).
Perhaps creating a metric that decides the available 'good' moves of a piece. For example, if all available moves for a knight are M, the metric could be something like sum(Evaluation(Mi) / Evaluation(Mbest)). Although this runs into a problem when a move blunders checkmate, as it dominates the score.
However, I do think some sort of engine evaluation on a position is necessary to evaluate piece activity. Having freedom to blunder shouldn't be considered active.
What do people think about adding an engine evaluation to the heuristic for piece activity? Intuitively, even if a knight has access to many squares it wouldn't be considered active if all those squares are also attacked by the opponent's pawns - that would be considered a trapped knight (as inactive as you can be).
Perhaps creating a metric that decides the available 'good' moves of a piece. For example, if all available moves for a knight are M, the metric could be something like sum(Evaluation(Mi) / Evaluation(Mbest)). Although this runs into a problem when a move blunders checkmate, as it dominates the score.
However, I do think some sort of engine evaluation on a position is necessary to evaluate piece activity. Having freedom to blunder shouldn't be considered active.
@WillSandi you can do a lot with computer engine evaluation, including waiting for it to finish and paying for the energy required to run it :)
Plus, you have it a bit backwards, because something like piece activity is usually used in the value function of estimating a position, which is then used by a chess engine to go through the move branches.
What we need are clear, consistent, deterministic algorithms that are as simple as possible. So efficiency over efficacy.
@WillSandi you can do a lot with computer engine evaluation, including waiting for it to finish and paying for the energy required to run it :)
Plus, you have it a bit backwards, because something like piece activity is usually used in the value function of estimating a position, which is then used by a chess engine to go through the move branches.
What we need are clear, consistent, deterministic algorithms that are as simple as possible. So efficiency over efficacy.
very Good view, but I myself think, that activity should be calculated not for one by one pieces, but for all their combinations toghter, that means, that we calculate not single piece , but weight of their attacking potatntional in combination.And beside of that , we need to give more weight to attack that supresses attack or defence of opponent pieces.And that isn't calculated by how many fields by pieces are attacked, but how many squares pieces are attacking with some purpose, including combination of attack by other pieces too, and give real weight for that, but not for simple attack
very Good view, but I myself think, that activity should be calculated not for one by one pieces, but for all their combinations toghter, that means, that we calculate not single piece , but weight of their attacking potatntional in combination.And beside of that , we need to give more weight to attack that supresses attack or defence of opponent pieces.And that isn't calculated by how many fields by pieces are attacked, but how many squares pieces are attacking with some purpose, including combination of attack by other pieces too, and give real weight for that, but not for simple attack
@TotalNoob69 yes, engine evaluations do take more time, but not nearly enough to consider 'paying for the energy required to run it.'
I do not have it backwards, I did not suggest we use such an engine. Indeed, we should use an engine that does not use some other heuristic for activity to create a new heuristic for activity. AlphaZero for example, had no domain knowledge (except the board, pieces, and rules).
"What we need are clear, consistent, deterministic algorithms that are as simple as possible. So efficiency over efficacy."
What we "need" is a good heuristic for piece activity. That was the point of the problem. It doesn't matter if it's fast if it's also bad.
If we are to create a way to measure activity, it needs to address this edge case - a trapped knight. Yes, you could check whether that square is attacked by the opponent, but what if that attacking piece is pinned?
Ultimately it comes down to not just "can this piece move to this square", but rather, "can this piece reasonably move to this square." And to determine the "reasonably" part of it, you need an engine evaluation.
@TotalNoob69 yes, engine evaluations do take more time, but not nearly enough to consider 'paying for the energy required to run it.'
I do not have it backwards, I did not suggest we use such an engine. Indeed, we should use an engine that does not use some other heuristic for activity to create a new heuristic for activity. AlphaZero for example, had no domain knowledge (except the board, pieces, and rules).
"What we need are clear, consistent, deterministic algorithms that are as simple as possible. So efficiency over efficacy."
What we "need" is a good heuristic for piece activity. That was the point of the problem. It doesn't matter if it's fast if it's also bad.
If we are to create a way to measure activity, it needs to address this edge case - a trapped knight. Yes, you could check whether that square is attacked by the opponent, but what if that attacking piece is pinned?
Ultimately it comes down to not just "can this piece move to this square", but rather, "can this piece reasonably move to this square." And to determine the "reasonably" part of it, you need an engine evaluation.
@WillSandi you are paying for any computation, one way or another. I wasn't implying any commercial application, just that such analyses take time and computing resources.
And I understand what you are saying, but in the end, where does it end? Aren't you talking about recreating a computer engine? All of these heuristics are linked to each other: activity to square control, square control to what happens 5 moves down the line, and so on.
As I see in the OP solution, one of the largest issues is the arbitrary value given to each square. I would try to calculate that value - in my proposal via the piece activity if the piece would move there - on the fly, so we don't depend on random constant maps.
@WillSandi you are paying for any computation, one way or another. I wasn't implying any commercial application, just that such analyses take time and computing resources.
And I understand what you are saying, but in the end, where does it end? Aren't you talking about recreating a computer engine? All of these heuristics are linked to each other: activity to square control, square control to what happens 5 moves down the line, and so on.
As I see in the OP solution, one of the largest issues is the arbitrary value given to each square. I would try to calculate that value - in my proposal via the piece activity if the piece would move there - on the fly, so we don't depend on random constant maps.
@TotalNoob69 yes you pay for computation, but it's negligible is my point - "not nearly enough to consider 'paying for the energy required to run it.'"
In the end, you end up with a more accurate heuristic to describe "how active is this piece", with insight into it's reasonable ability to move around the board, which is very different to "what is the likelihood of winning the game from this position". There is a link, but "in the end" it ends up with a different description.
I agree that arbitrary value given to each square is biased, but it would also be a mistake to assume the value of each square doesn't depend on the context of the game.
I do want to note, I think using the activity of the piece after it has moved to that square as insight into overall activity is an interesting idea, it's like the potential activity of the piece, which may be just activity abstractly. Interesting.
@TotalNoob69 yes you pay for computation, but it's negligible is my point - "not nearly enough to consider 'paying for the energy required to run it.'"
In the end, you end up with a more accurate heuristic to describe "how active is this piece", with insight into it's reasonable ability to move around the board, which is very different to "what is the likelihood of winning the game from this position". There is a link, but "in the end" it ends up with a different description.
I agree that arbitrary value given to each square is biased, but it would also be a mistake to assume the value of each square doesn't depend on the context of the game.
I do want to note, I think using the activity of the piece after it has moved to that square as insight into overall activity is an interesting idea, it's like the potential activity of the piece, which may be just activity abstractly. Interesting.
@TotalNoob69 said in #2:
Thanks for sharing your thoughts!
I didn't consider the secondary activity, as I wanted to just capture the current activity, to see how it develops over the course of a game. But your approach to "discounting" with q makes a lot of sense.
One question about your recursive approach: would you also do the recursive calculation for the secondary squares to get a tertiary activity?
I didn't want to simply add up the squares, as this makes knights always much less active than bishops or rooks. My goal was that the activity indicates how active a piece is compared to its maximal potential activity.
I also think that weighing squares differently is important. There are many closed positions where a rook has many moves on its own first rank, but it doesn't have any impact on the game as it's blocked by its own pawns. At the same time, there are situations where a piece doesn't have many moves, but it controls important squares around the enemy king to facilitate an attack.
@TotalNoob69 said in #2:
Thanks for sharing your thoughts!
I didn't consider the secondary activity, as I wanted to just capture the current activity, to see how it develops over the course of a game. But your approach to "discounting" with q makes a lot of sense.
One question about your recursive approach: would you also do the recursive calculation for the secondary squares to get a tertiary activity?
I didn't want to simply add up the squares, as this makes knights always much less active than bishops or rooks. My goal was that the activity indicates how active a piece is compared to its maximal potential activity.
I also think that weighing squares differently is important. There are many closed positions where a rook has many moves on its own first rank, but it doesn't have any impact on the game as it's blocked by its own pawns. At the same time, there are situations where a piece doesn't have many moves, but it controls important squares around the enemy king to facilitate an attack.

