Stop using gradient descent or hill climbing………start with ant colony or simulated annealing….. that way you won’t get stuck at the local extrema…..

Next time you start working on a program…..first start by writing the class , function names and the initial comments with arguments and return type….
That can serve as both replacement for tech spec……..and a clarity for design…….