What not to wear

Okay, this seems to work for the time being:

Covering relates a garment (called item) to a body-area (called test-area) when the area of the item body-includes the test-area. The verb to cover (it covers, they cover, it is covering, it is covered) implies the covering relation.

Definition: a garment-element is uppermost if it is uppermost on the person asked.

To decide if (item - a garment) is uppermost on (actor - a person):
	if the area of the item is not complex:
		if the item is not unwearable because of something opaque:
			decide yes;
		otherwise:
			decide no;
	otherwise:
		repeat with test-area running through body-area body-included by the area of the item:			
			if the actor is wearing an opaque garment (called the coverer) which covers the test-area and the layer-level of the coverer is greater than the layer-level of the item:
				next;
			otherwise:
				decide yes;
		decide no;

I was almost there, but I had some problems once I tried to introduce another NPC. It seems “the person asked” in the clothing conflict relationship doesn’t really work right when I used it while trying to list the items an NPC was wearing. So I needed a subtly different relationship called “garment covers”. The code below (maybe) fixes all the problems:

"What not to wear II" by Anonymous

Part 1 - Body areas

Body-area is a kind of value. The body-areas are feet, lower-body, legs, hips, upper-body, full-body, head, none.

[relates with areas include other areas]
Body-includes relates various body-area to various body-areas. The verb to body-include (it body-includes, they body-include, it body-included, it is body-including) implies the body-includes relation. The verb to be body-included by implies the reversed body-includes relation.

full-body body-includes hips, legs and upper-body. lower-body body-includes hips and legs.

[identity relationships]
feet body-includes feet. lower-body body-includes lower-body. legs body-includes legs. hips body-includes hips. upper-body body-includes upper-body. full-body body-includes full-body. head body-includes head.

Definition: A body-area is complex rather than not complex if it body-includes more than one body-area.

Part 2 - Garments

Chapter 1 - Defining base kinds

A garment-element is a kind of thing. A garment-element has a number called the layer-level. A garment-element has a body-area called the area.

[not actually needed - but you might add body-parts and then test if they are covered in a similar way to testing if a garment covers another garment]
A body-part is a kind of garment-element. A body-part has layer-level 0.

A garment is a kind of garment-element. A garment is wearable. A garment can be transparent. 

A pair of pants is a kind of garment. The plural of pair of pants is pairs of pants. The area of a pair of pants is lower-body. A pair of pants usually has layer-level 5.

A pair of underpants is a kind of garment. The plural of pair of underpants is pairs of underpants. The area of a pair of underpants is hips. A pair of underpants usually has layer-level 2.

A foundation garment is a kind of garment. The area of a foundation garment is upper-body. A foundation garment usually has layer-level 2.

A pair of socks is a kind of garment. The plural of pair of socks is pairs of socks. The area of a pair of socks is feet. A pair of socks usually has layer-level 2.

A pair of shoes is a kind of garment. The plural of pair of shoes is pairs of shoes. The area of a pair of shoes is feet. A pair of shoes usually has layer-level 5.

A jacket is a kind of garment. The area of a jacket is usually upper-body. A jacket usually has layer-level 10.

A hat is a kind of garment. The area of a hat is head. A hat usually has layer-level 5.

A dress is a kind of garment. The area of a dress is full-body. A dress usually has layer-level 5.

A skirt is a kind of garment. The area of a skirt is lower-body. A skirt usually has layer-level 5.

A tie is a kind of garment. The area of a tie is upper-body. A tie usually has layer-level 7. A tie is always transparent.

A shirt is a kind of garment.  The area of a shirt is upper-body. A shirt usually has layer-level 5.

Chapter 2 - Relationships

Covering relates a garment (called item) to a body-area (called test-area) when the area of the item body-includes the test-area. The verb to cover (it covers, they cover, it is covering, it is covered) implies the covering relation.

Definition: a garment-element (called item) is uppermost if the item is uppermost on a random person wearing the item.

To decide if (item - a garment) is uppermost on (actor - a person):
	if (actor is nothing):
		decide yes;
	if the area of the item is not complex:
		[if the item is not unwearable because of something opaque:]
		if the item is not overlaid by something opaque:
			decide yes;
		otherwise:
			decide no;
	otherwise:
		repeat with test-area running through body-area body-included by the area of the item:			
			if the actor is wearing an opaque garment (called the coverer) which covers the test-area and the layer-level of the coverer is greater than the layer-level of the item:
				next;
			otherwise:
				decide yes;
		decide no;

Garment covers relates a garment (called the top layer) to a garment (called the bottom layer) when the bottom layer is worn by a random person wearing the top layer and the top layer conflicts with the bottom layer.

The verb to be overlaid by implies the garment covers relation.

Clothing conflict relates a garment (called the top layer) to a garment (called the conflicting layer) when the conflicting layer is worn by the person asked and the top layer conflicts with the conflicting layer.

The verb to be unwearable because of implies the clothing conflict relation.

The verb to prevent wearing (he prevents wearing, they prevent wearing, he prevented wearing, he is preventing wearing) implies the reversed clothing conflict relation.

To decide if (top layer - a garment) conflicts with (conflicting layer - a garment):
	[simplest case - if the two garment are the same, they don't conflict]
	if the top layer is the conflicting layer:
		decide no;
	[simple case - if the top layer has a higher level, it doesn't conflict]
	if the layer-level of the top layer is greater than the layer-level of the conflicting layer:
		decide no;
	[some part of the top layer area = some part of the conflicting layer area]
	otherwise if a body-area body-included by the area of the conflicting layer is body-included by the area of the top layer:
		decide yes;
	otherwise:
		decide no;

Chapter 3 - Rules for handling garments

Section 1 - removing
	
Before an actor taking off something which is unwearable because of something which is worn by the actor:
	while the noun is unwearable because of something (called the impediment) which is worn by the actor:
		say "(first removing [the impediment])[command clarification break]"; 
		silently try actor taking off the impediment; 
		if the noun is unwearable because of the impediment, stop the action.
		
Check an actor taking off a garment: 
    if the noun is unwearable because of something (called the impediment) which is worn by the actor, say "[The impediment] is in the way." instead. 

Report taking off something: 
    say "You are now wearing [a list of uppermost things worn by the player]." instead. 
        
Section 2 - wearing
	
Before an actor wearing something unwearable because of a garment worn by the actor:
	while the actor wears a garment (called the impediment) which prevent wearing  the noun:
		say "(first removing [the impediment])[command clarification break]"; 
		silently try actor taking off the impediment; 
		if the actor is wearing the impediment, stop the action.
		 
Instead of taking inventory: 
	say "You're carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of uppermost garments worn by the player][end if]." 

Section 3 - The Scenario 


The Dressing Room is a room. 


some capris, some jeans, a corset, a plunge bra, a thong, boy-shorts, black satin D'Orsay pumps, brown leather boots, a camisole, a cocktail dress, a bolero, a cashmere shrug, a sheer wrap, and a linen tunic are in the dressing room.


The woolly socks are a pair of socks. 
The D'Orsay pumps and the brown leather boots are pairs of shoes. 
The thong and the boy-shorts are pairs of underpants. 
The capris and the jeans are pairs of pants. 
The tunic is a shirt. 
The camisole, the corset, and the plunge bra are foundation garments. 
The cocktail dress is a dress. 
The bolero, the cashmere shrug, and the sheer wrap are jackets. The shrug and the wrap are transparent. 

Jane Doe is a person in the dressing room. The description of Jane is "Jane is carrying [a list of things carried by Jane][if Jane wears something]. Jane is wearing [a list of uppermost garments worn by Jane][end if]."   

Persuasion rule for asking somebody to try doing something: 
	persuasion succeeds.

Test me with "take all / wear capris / wear jeans / i / wear thong / i / wear dress / wear corset / wear dress / i / wear wrap / i / wear boots / wear pumps / i". 

Test jane with "jane, take all / jane, wear thong / jane, wear dress / x jane / jane, wear bra / x jane / jane, wear dress / jane, wear bolero / x jane / jane, remove dress".

I don’t think there’s anything wrong with that. As Eric S. Reynolds describes it, you were “scratching a developer’s itch.” I’ve taken frequent breaks from working on my WIP to write extensions. I’ve found it a satisfying way to work out a problem that’s on my mind without it interfering with the player experience of the actual game.

This is very cool. I was wrong earlier about “the person asked”; it seems to be whoever is either being asked to do something ortrying an action, whether or not they are doing so as a result of being asked to do something. Have I got that right? Anyway, I added this:

Instead of singing when Jane wears the bolero:
	say "Jane says, 'I can't resist a musical pun.'";
	repeat with item running through things worn by Jane:
		if item is not the bolero:
			try Jane taking off item.

and Jane takes off the bolero if she is wearing something under it, as she ought. (I think this tells us what sort of game needs this kind of modeling – roguelike-likes with various sorts of overlapping armor, of course.)

How speedy is this code? I may have to borrow it — what should I include as your byline?

Knock yourself out. It seems to be a lot speedier than the original by removing all the many-to-many relationships that caused the original to choke. I can’t guarantee it won’t break at some point, but so far, so good.

Thanks. I’ll probably call it “Efficient Layered Clothing” in my files, unless you can suggest a better descriptor. I may even expand it to include more narrowly defined body regions (Expanded ELC?) for a project that calls for it. (I have this idea of spotting a tattoo on someone’s scapula, but only while she is wearing a certain outfit. Or a scar … a watch … you get the idea.)

I believe I’ll also create “male/female supermodel” as a sub-category of “man/woman.” Man or woman would suitable for random NPCs who never change attire; there’s no need to even create garnent objects for them, or associate them with body parts. Their clothing can be included in the description. There are, after all, only a few characters we probably need in such detail as to interact with their underwear or examine their elbows. :slight_smile:

You must be using a modified form of “What Not To Wear” part 1. Part II doesn’t play nice with the one from the documentation.

It replaces the one from the documentation instead of adding on to it. (Think of it as version 2 instead of part 2.)

Got it working. It was the cut ‘n’ paste, it didn’t preserve the proper tabulations.

Best way to avoid that is to hit the quote button and copy it from the edit box, which preserves tabs.