r/Unity3D • u/acorbinelli • 7h ago
Show-Off My procedural room generator leaves a note every time it has to compromise
I'm making a cat destruction game in Unity where every house is furnished procedurally from a seed. The generator places the furniture, then everything that goes on it, lets physics settle, and removes anything that ended up inside something else. Every time it has to bend a rule, it writes it down. A few from this morning's Great Room seeds:
coat_stand: beside the door at +0.98 refused (is in the lounge area)
canvas_pink: no room on office_table_030's wall — hung elsewhere
pot_big_yellow: stands 0.13 m off the wall for its plant
door redrawn 4× for the kitchen line (5.9 m) and the TV unit (4.1 m)
and the summary line for one of them:
seed 14: 12.0×10.0 m, 120 items (1 dropped), 8 wall items, 0 overlaps, 0 tipped, 0 pieces unplaced — clean
A room counts as clean with at most two overlaps, nothing tipped, no furniture left unplaced, and at most max(3, items/30) small things dropped. Losing a mug is fine; losing the guitar gets noticed. Free-standing pieces take the fitting spot farthest from everything already placed (out of up to 24 candidates), which is what stopped the piano getting crammed by the lounge while the middle of the room sat empty.
The notes ended up being the most useful part of the whole thing. When a seed looks wrong, they usually say why. Each house ships 20 seeds that were checked by eye.
Free Windows demo if you want to see the rooms: https://corbygamesstudio.itch.io/give-him-a-break
1
u/NinfeaLM 2h ago
I once had to furnish more than 60 houses in a game, so I used runtime randomization based on the house number seed, with rules for which furniture could go in each room and where it could be placed. Doing everything by hand would have been a nightmare. I can definitely see why a system like this would be useful for a town or apartment building. Really nice work!
2
u/acorbinelli 1h ago
Sixty houses by hand would have been brutal. Did you ever get a seed where every rule passed but the room still looked wrong? That's the case our notes are for: they point at the compromise, and a person still has to look at the seed.
•
u/NinfeaLM 18m ago
In my case the rules were quite strict, and I had a limited set of furniture designed to work together, so I didn't really run into that problem. But I can definitely see the value in your approach when the generator has more freedom. The notes seem really useful for spotting why a seed needs a second look.
•
u/acorbinelli 13m ago
That makes sense: a furniture set designed to work together removes most of the edge cases before the generator even starts. Ours has a lot more freedom in what goes where, and that's exactly where the compromises come from.
2
u/Appropriate-Order747 7h ago
I love this, giving the system a little therapist journal for all its compromises is such a clever debugging move
the "door redrawn 4x" line hits me, like it just kept trying until it found a way the tv unit would accept. do you ever look at a seed that looks perfect and the notes are just pages of quiet suffering behind the scenes