So here is the problem I have been working on: You are given a random nxn grid with weights in each box of the grid and you are also given a set of pegs p<=n. Your goal is to place the pegs on the grid such that the sum of weights on the grid where the pegs are placed is maximized. The constraint is that the peg positions have to follow the non-attacking Queen placements too.
My initial attempt was to start with the max score grid box and follow the n queen placement. However, this doesn't work as it misses the max value in the end.
I have been trying to solve this with A* but have been struggling to find a heuristic.