Heuristic function for game phase is asymetric
ethomas2 opened this issue · 2 comments
I've been looking at the heuristic for deciding when a game is in the opening/midgame/endgame
It looks like the way the heuristic works is that it "scores" all 2x2 grids on the board and takes the sum of all the scores. A score is higher if there are many white and black pieces on the grid, or if the grid is mostly white and on the black side of the board or mostly black and on the white side of the board.
I would've expected this function to be symmetric, meaning if I take some 2x2 grid and switch all the colors and mirror it accross the y axis the score should not change.
That would mean
score(x, y, ypos) == score(y, x, 8 - ypos)
for all x y pairs
But that is not true. For example score(1, 2, y) for y <- 1 to 7
is 3, 4, 5, 6, 7, 8, 9
but score(2, 1, y) for y <- 7 to 1
is 5, 6, 7, 8, 9, 10, 11
. What this means in practice is for 2x2 grids containing 2 of one color and one of the other, the algorithm cares more about more white pieces on the black side of the board than black pieces on the white side of the board.
Maybe i'm misunderstanding something about the algorithm. If i'm right and this is a bug, i'd be happy to submit a pull request.
I don't have the courage to dive back into that code (which I didn't write myself in the first place) so I'll trust your assessment and hope for a pull request!
Closing, because the function doesn't have to be symmetric. But tweaks are welcome.