How to identify which move should be made in Green Hackenbush involving general, possibly-cyclic graphs?

48 Views Asked by At

In Green Hackenbush, if the goal is merely to find Sprague-Grundy values, the approach is to transform the arbitrary graphs into trees using the fusion principle, then transform the trees into Nim heaps using the colon principle. However, solving the associated Nim game only prescribes which Green Hackenbush graph should be hacked and the Sprague-Grundy value it should end up with, not which edge of that graph should be hacked to produce that Sprague-Grundy value.

This algorithm actually prescribes which edge to hack on the assumption that it belongs to a tree. I want to generalize this algorithm to arbitrary graphs, resulting in a complete, human-viable strategy for Green Hackenbush.

A very nice property of the linked algorithm is that it leaves trees in tree form and only converts them to Nim heaps implicitly. Neither transformations from arbitrary graphs to trees nor transformations from trees to Nim heaps are invertible, so this is a desirable feature of an algorithm because it eliminates any need to store "metadata" to reconstruct earlier versions of graphs. It also allows the player the option to apply the algorithm to all graphs in the game (if they're trees) and combine the steps of identifying which tree to hack and which edge on that tree to hack, which seems to be pretty fast.

Is there a Green Hackenbush algorithm which has a similar flavor to this, but also handles general, possibly-cyclic graphs? If not, then what is the easiest way to handle cycles as an additional layer on top of the tree algorithm?