Yes, it's possible, but it would be nice to have a universal algorithm.
Well, that's unlikely, as different templates have different criteria. For example, if for XL+U-
the possibility of bypassing bugged passages is a small, pleasant freedom that diversifies the process (without it, it's not as interesting, in my opinion), but doesn't lead to anarchy (meaning randomness in the gameplay, not the "anarchy" template), then for other, smaller templates, where the gameplay is more linear, it can create a serious imbalance.
Added 23 minutes later
I perfectly understand that this optimization process is complex and not quick, but we don't need lightning-fast solutions to problems. The main thing is not to make things worse than they are.
ICQ 716748479