Random Movement of NPC in a Region

I’ve got an NPC wandering to random rooms within a region, but the problem is that the room she’s starting from is also within the region; so on occassion, the game reports that’s she’s wandered out of the room but she is in fact still in the room. I tried setting up a “different” relation by using:

Difference relates a thing (called X) to a thing (called Y) when X is not Y. The verb to be different from means the difference relation.

…and then saying:

now your mom is in a random room in Around the House which is different from the location of the player.

This compiles alright, but when she tries to wander away, it causes the moving into nothing error.

[** Programming error: tried to “move” your mom to nothing **]

I imagine that Inform 7 is trying to move mom to a room that is different from the room that it’s trying to move her to (hence nothing).

There’s got to be a way to make this happen, but I can’t figure out what it is. I searched through the forum threads but couldn’t find anything specific enough to help me. Any help would be greatly appreciated!

I didn’t use a region, but here’s the mechanism. I think you would just add “in [whatever region]” when necessary.

[code]Living Room is a room. “The Kitchen is north of here.”

Kitchen is north of living room. “The Living Room is south of here, and the Study is east of here.”

Study is east of kitchen. “The only way out is the kitchen to the west.”

Bedroom is west of kitchen. “From here, you can go east to the Kitchen, or north to the patio.”

Patio is north of Bedroom. “The only way back in the house is south.”

Mom is in Living Room. “[one of]Your mom is angry. ‘I’m going to be working around here and I’d better not see your face!’[or]Mom is here dusting and trying to forget what you’ve done.[stopping]”

Definition: a room is vacant if it does not contain the player.

Destination is a room that varies.

Every turn:
Now destination is a random vacant room;
if the location of Mom is the location of the player:
say “Mom huffs off towards the [destination], unable to look at you any further.”;
say “You hear Mom clattering around in the [destination].”;
now mom is in destination;[/code]

If you want the player to be able to find her more easily, you could instead only move her when the player is in the same location:

Every turn: if the location of mom is the location of the player: now destination is a random vacant room; say "Mom huffs off toward the [destination], unable to look at you any further."; now mom is in destination; otherwise: say "You hear Mom clattering around in the [destination].";

It seems to have worked! Thanks you so much!