Gerrymandering is a fancy word for redrawing the voting districts in your favor.
In “area control” board games (games where you win a region by having the most representation there, and you win the game by winning most regions) the tension is usually to not overcommit where you are already winning and to recognize where you’re definitively gonna lose and don’t commit anything there. By conserving your resources in those two ways you can win as many regions as possible.
Through gerrymandering, political elections can be won this way. You create many regions where you’re either juuuust winning (but unambiguously winning) by also creating a few regions where you get totally clobbered, making your opponents wastefully overconcentrated in those regions.
Now, political representation isn’t meant to be a game, let alone one that can be cheated this way, so gerrymandering is rightly seen as a problem.
It makes me want to change the system entirely so that representation isn’t as geographic. A lot of issues in modern politics are based on other types of divides. So that’s the promised titular solution: just don’t have the game work this way. Now, exactly how to set it up instead so that representation isn’t based on these manipulative group sizes is another issue entirely. But here in Sweden we don’t have gerrymandering. If I vote green that vote is gonna be good for green no matter where I live.
That’s also because we have proportional representation but even in a one-winner-takes-all system there’s not really a reason why in this day and age not to aggregate vote results in a more fine-grained way.
So if the question is “how do we draw the districts in a fair way” maybe the better answer is to zoom out and change the system to one that’s not as sensitive to that.