I don't know my random generation code is sh*t
I see.
Hm, perhaps some kind of „try again” would be an option? Like, generate some random obstacles and check, whether they are acceptable. If not, try again.
Could be a do-while-loop.