In the realm of video game bingo, it is common to use magic squares to generate cards. If you have $25$ difficulty buckets for goals, then if you lay out those buckets onto a magic square, any bingo will be approximately the same difficulty.
I had a related, but distinct problem to solve. I have eight buckets of goals, where each goal is equivalent in difficulty, but only if only one goal is used from each bucket (per potential bingo). Therefore, I need to lay out, on a $5\times 5$ grid, the numbers $[1..8]$ such that no row, column, or diagonal contains a duplicate number.
Maintaining a somewhat even distribution of goals from the eight buckets is ideal, but not required. The solution I ended going with, at least temporarily, was to use a hardcoded quasimagic square and randomly transpose and/or reflect it.
I did spend an evening trying to figure out if there's a procedural way to generate or enumerate all possible boards, though. That's the question I pose here: how can a quasimagic square of this definition be generated? Bonus: how does (or doesn't) the problem change as you increase or decrease the number of buckets?
Here's the example quasimagic square I'm using:
$$ \begin{matrix} 1 & 3 & 5 & 7 & 8 \\ 2 & 4 & 3 & 6 & 5 \\ 4 & 5 & 2 & 3 & 7 \\ 6 & 7 & 4 & 8 & 1 \\ 3 & 2 & 8 & 1 & 6 \end{matrix} $$