decomp-permuter
decomp-permuter copied to clipboard
Attempt to prune unnecessary mutations from new results
The permuter should try to remove silly mutations that didn't help when it discovers a better score. We can accomplish this by taking the seed that produced the result and omitting various mutations performed, keeping any result that maintains the same asm as the original improvement.
More concretely, I think we should record each state's path as a list of random seeds, and make it so that each time the randomizer is invoked, it gets passed an RNG based on a new random randomness seed, which gets recorded as part of the path. Then you can get rid of silly mutations by dropping seeds from the list and checking that asm hash remains the same. It's not perfect: in particular, removing earlier randomization passes can throw later ones off if they do random.choice(some_list_of_statements) and the earlier randomization pass added/removed a statement. But I would expect it to work in like 70% of cases which is better than nothing.
If we would want to expand it to work in more cases as a follow-up, I can imagine making an RNG wrapper class that records what the RNG did last time, and tries to do something as similar as possible if you run it again even in cases where exact lists of random.choice statements vary.