1: To make underbeds privately-named, you can add the sentence "An underbed is usually privately-named."
2: In a game where I only had to worry about a single item underneath a bed, I handled it like this:
Instead of looking under the bed the first time:
say "You poke your flashlight under the bed and wave it around. Something catches the light: a key![paragraph break]Probably pretty obvious, but to pick up the key you'll want to type in 'pick up key' or 'take key'.";
now the brass key is in the location;
This doesn't simulate the underside of a bed as a separate place, though. If I were making a game where there were a lot of beds that needed looking under, and where the difference between being under the bed and just lying on the floor was important, I might handle it like this:
A bed is a kind of supporter. An underbed is a kind of container. An underbed is part of every bed.
Being under relates various things to one bed. The verb to be under means the being under relation.
The wooden bed is a bed in room 1408.
The ball is under the wooden bed.
Instead of looking under a bed:
let underside be a random underbed that is part of the noun;
repeat with article running through things under the noun:
now article is in underside;
now article is not under the noun;
try searching underside.
Instead of searching an underbed:
say "Under the bed you see [a list of things contained by the noun]."
I've created a new relation, "being under." When I say "the ball is under the wooden bed," I'm not really putting the ball under the bed; I'm "marking it" so that when I look under that bed, the ball will appear there. (The "now article is not under the noun" part is misleading: I have to delete that relationship, otherwise, if I move the ball, it'll zip back underneath the bed the next time I look there.)
3: I think the thing in the "otherwise if" line is working as intended. The "(called underbed)" in the if statement only propagates that definition within its own jurisdiction. When you get to "otherwise if...", that definition no longer applies.
There's some confusion due to the fact that your temporary name "underbed" is the same as the kind name "underbed". When the game tries to print "[list of things in underbed]" after it's forgotten your temporary definition, it produces "wooden bed's underbed."
I thought this must be the list of things in the category of "underbed," that is, the list of underbeds in the game. But I was wrong! I added a "gross bed" and a "holy bed" to the game, and when I looked under the wooden bed (with the "otherwise" line reading only "otherwise:"), I got:
"Under the wooden bed you see: wooden bed's underbed, gross bed, gross bed's underbed, holy bed and holy bed's underbed."
So I have no idea what's going on there. But here are my tips:
Use temporary names that are distinct from property names. This makes it a lot easier when you're diagnosing bugs, not to mention just reading your own code!
Declare those temporary variables each on their own line (instead of on an "if"/"otherwise" line) if you can, and as early in the rule as possible. I had to correct myself when writing my "instead of looking under a bed" rule: I put "let underside be a random underbed that is part of the noun" inside of the "repeat" section, and then I realized I'd also need it later on.