Context: I have a mosaic program which uses a first directed width search algorithm. It is "led" by what I call "pairwise scoring". There are N polyforms (pieces) used in tiling. I have an NxN table with a score at each location. While tiling, I try to maximize the sums of pairs of unused pieces. At the start, I add up all the scores, find the average score, and subtract the average of all the scores so that they are zero. As I tile, I can find the new total just by adjusting the current total for the node by deleting the scores belonging to the last piece placed.

I generate the table NxN & # 39; even score & # 39; in mosaic of a small shape with about 6 to 10 pieces, for each mosaic found, I look at the border cells of each room & # 39; a & # 39; in the mosaic, and wherever it touches the part & # 39; b & # 39;, I increment (a, b) and (b, a). And wherever it touches the edge of the shape, I increase (a, a).

It works fairly well, but I suspect I could further optimize the “ final game '' & # 39; by encouraging a tendency to end with one of the “ local maxima '', being the group (s) of coins that “ mark the best as '' together & # 39; & # 39; .

In order to know if my algorithm finds such maxima, I must first find them myself so that I know when the node scores miss these maxima.

So my question is, how can I efficiently find the highest score sets from 1 to M on N pieces, where M goes up to around 30 and N up to 1000 or more?

There is some redundancy available in the table, I am currently repeating (a, b) in (b, a). I could use (a, b) for the score of the pair when a <b and (b, a) for something else. I already use (a, a) to keep track of the number of times a piece hits an edge square in a tessellation of smaller shape. I can adjust the importance of this edge score using a simple "edge score factor".

It would be nice to have an algorithm fast enough to track these local maxima as they change due to the parts used, without affecting the tiling speed too much. Then I would know fairly quickly that I had "gone wrong", that is to say that even if I had a good high knot score, I had used a set of pieces that would reduce my best possible end game, and I could use it to direct the BFS in addition to the single knot score.

Or is it the case that the node score already gives me that?