Complete obstacle/key placement algorithm.