For many real-world problems, there exist non-deterministic heuristics which generate valid but possibly sub-optimal solutions. The program optimisation with dependency injection method, introduced here, allows such a heuristic to be placed under evolutionary control, allowing search for the optimum. Essentially, the heuristic is “fooled” into using a genome, supplied by a genetic algorithm, in place of the output of its random number generator. The method is demonstrated with generative heuristics in the domains of 3D design and communications network design. It is also used in novel approaches to genetic programming.