A pattern for describing common body plans

This probably isn’t too revolutionary but I hadn’t thought of it before so I figured I’d share it. I realized that certain hierarchical parenting patterns can show up, for example if you are giving humanoids body parts. A lot of the descriptions will be repeated: for example, if you look at someone’s body in addition to describing their body as a whole you’d probably want to describe their head, limbs, etc.

What I came up with outputs a tree traversal of nested detail for uniform body plans:

> examine myself
You have an oval face. You have long blonde hair tied up in a bun. You have a
wide cranium. You have a svelte figure. You have a good personality.

It’s not very flexible and the prose is very robotic, things that I’d like to address, but for now here is example code:

(animate $Obj)
        *(humanoid $Obj)

%% Humanoid
%% -Body
%% --Head
%% ---Face
%% ---Hair
(descr (humanoid $Person))
        *($Body is #partof $Person)
        (body $Body)
        (descr $Body)
        (The $Person) (has $Person) (detail $Person).
(descr (body $Body))
        ($Body is #partof $Person)
        *($Head is #partof $Body)
        (head $Head)
        (descr $Head)
        (The $Person) (has $Person) (detail $Body).
(descr (head $Head))
        ($Head is #partof $Body)
        ($Body is #partof $Person)
        *($Face is #partof $Head)
        (face $Face)
        (descr $Face)
        *($Hair is #partof $Head)
        (hair $Hair)
        (descr $Hair)
        (The $Person) (has $Person) (detail $Head).
(descr (face $Face))
        ($Face is #partof $Head)
        ($Head is #partof $Body)
        ($Body is #partof $Person)
        (The $Person) (has $Person) (detail $Face).
(descr (hair $Hair))
        ($Hair is #partof $Head)
        ($Head is #partof $Body)
        ($Body is #partof $Person)
        (The $Person) (has $Person) (detail $Hair).
#me
(current player *)
(humanoid *)
(detail *)
        a good personality
#myBody
(body *)
(* is #partof #me)
(detail *)
        a svelte figure
#myHead
(head *)
(* is #partof #myBody)
(detail *)
        a wide cranium
#myFace
(face *)
(* is #partof #myHead)
(detail *)
        an oval face
#myHair
(hair *)
(* is #partof #myHead)
(detail *)
        long blonde hair tied up in a bun

Thoughts on how to improve the approach, or other approaches that might be simpler, are of course welcome!

2 Likes

well, the “robotic approach” mirrors what I have done (not in a constructive prose) in a wild messing around:

X myself
“bow: checked. Quiver: checked. Arrows: checked. Now it’s time for a good hunting”

And, in general, the “robotic prose” can be useful in not few circumstances, let’s say a detective looking at mugshots… (of course, I have saved your snippet as "potentially useful routine :wink: )

Best regards from Italy,
dott. Piergiorgio.

It’s a matter of taste if the following is good style, but if you have many objects with the same general structure, you could make an access predicate for specifying how the pieces fit together:

@(humanoid $Person $Body $Head $Face $Hair)
    (humanoid $Person)
    (body $Body)
    (head $Head)
    (face $Face)
    (hair $Hair)
    ($Body is #partof $Person)
    ($Head is #partof $Body)
    ($Face is #partof $Head)
    ($Hair is #partof $Head)

And then:

(humanoid #me #myBody #myHead #myFace #myHair)

(detail #myFace)
    an oval face

...
1 Like

Didn’t think of using an access predicate like that (or honestly understand how they worked). Neat!

I made things a bit more flexible, now a fixed body plan isn’t required, clothes and held items can be described, and you have some control on a per-object basis as to what gets described. First, the payoff:

> examine self
You are a daring knight. Your body is a part of yourself. Your body is stout.
You are holding your sword. Your blade is keen. You are wearing your armor.
Your armor is shining. Under your armor are your clothes. Your clothes are
rather scratchy.

Here is the test code:

#you
(current player *)
(animate *)
(proper *)
(describe #partof *)
(describe #heldby *)
(describe #wornby *)
(description *)
        You are a daring knight.

#yourBody
(name *)
        your body
(* is #partof #you)
(proper *)
(description *)
        Your body is stout.

#yourSword
(name *)
        your sword
(* is #heldby #you)
(item *)
(proper *)
(description *)
        Your blade is keen.

#yourArmor
(name *)
        your armor
(* is #wornby #you)
(wearable *)
(proper *)
(describe #under *)
(description *)
        Your armor is shining.

#yourClothes
(name *)
        your clothes
(* is #under #yourArmor)
(wearable *)
(proper *)
(plural *)
(description *)
        Your clothes are rather scratchy.

And here is the code that makes it work:

(descr $Obj)
        (description $Obj)
        (if) (describe #partof $Obj) (then)
                (collect $C)
                        *($C is #partof $Obj)
                (into $PartOfList)
                (describe part of $Obj $PartOfList)
        (endif)
        (if) (describe #heldby $Obj) (then)
                (collect $C)
                        *($C is #heldby $Obj)
                (into $HeldByList)
                (describe held by $Obj $HeldByList)
        (endif)
        (if) (describe #wornby $Obj) (then)
                (collect $C)
                        *($C is #wornby $Obj)
                (into $WornByList)
                (describe worn by $Obj $WornByList)
        (endif)
        (if) (describe #under $Obj) (then)
                (collect $C)
                        *($C is #under $Obj)
                (into $UnderList)
                (describe under $Obj $UnderList)
        (endif)

(describe part of $ [])
(describe part of $Obj [$Head|$Tail])
        (A $Head) is a part of (the $Obj).
        (descr $Head)
        (describe part of $Obj $Tail)

(describe held by $ [])
(describe held by $Obj [$Head|$Tail])
        (The $Obj) (is $Obj) holding (a $Head).
        (descr $Head)
        (describe held by $Obj $Tail)

(describe worn by $ [])
(describe worn by $Obj [$Head|$Tail])
        (The $Obj) (is $Obj) wearing (a $Head).
        (descr $Head)
        (describe worn by $Obj $Tail)

(describe under $ [])
(describe under $Obj [$Head|$Tail])
        Under (the $Obj) (is $Head) (a $Head).
        (descr $Head)
        (describe under $Obj $Tail)

(description $)

Still pretty mechanical, but I think an improvement.

1 Like