2019-05-17 On generating lists of items in Hex Describe

I’ve been looking at Hex Describe again. These days I’ve been collaborating with ktrey parker on Diaspora and all of this input has pushed me to work harder on how Hex Describe generates lists of unique items from a larger list.

I needed lists of unique items for spell lists. Let’s take Agrimach, for example. The spells of the first circle are aura of fear, locate corpse and read magic. If I now want to create a second level student of Agrimach, I want to provide them with two of the three spells, but no duplicates. The naive way to encode this in a table would be:

;spell
1,aura of fear
1,locate corpse
1,read magic

;student
1,A man with a black beard. *[spell]* and *[spell]*

When I try it, there is some duplication. Note the arrows:

So what I did was I added lists to Hex Describe. It now has the keywords “with” and “and” to initialise lists and to pick further elements for the same list. “with” starts a new list and “and” picks a random element up to ten times in an attempt to not pick an item already on the list.

We rewrite the tables:

;spell
1,aura of fear
1,locate corpse
1,read magic

;student
1,A woman with curly hair. *[with spell]* and *[and spell]*

The result:

No repeats!

But now let’s add some details to the spells. Let’s provide two alternatives for each spell.

;aura of fear
1,aura of fear
1,aura of terror

;locate corpse
1,locate corpse
1,locate body

;read magic
1,read magic
1,read runes

;spell
1,[aura of fear]
1,[locate corpse]
1,[read magic]

;student
1,A young teenager with short hair. *[with spell]* and *[and spell]*

We have a lot more options, but eventually the duplication is back because the two variants count as different results of the “spell” table:

The solution to this is that we need another level of indirection: the list must not be a list of final results but of keys that are resolved later. Thus, the “spell” table returns the table names that are then used in the “student” table to find the actual spells.

;aura of fear
1,aura of fear
1,aura of terror

;locate corpse
1,locate corpse
1,locate body

;read magic
1,read magic
1,read runes

;spell
1,aura of fear
1,locate corpse
1,read magic

;student
1,A girl, maybe seven years old, with long blond hair. *[[with spell]]* and *[[and spell]]*

If you look at the results, you no longer get two variants of the same spell:

Yay!

OK, but I have an even stranger thing to talk about. Let’s generate a simple sentence describing a dungeon. There are various rooms and we don’t want any repeats. It starts much like the spellbook above:

;room
1,an altar room
1,a cesspit
1,a lair

;dungeon
1,This dungeon consists of [with room] and [and room].

Simple, no duplication:

Let’s make it more interesting by having the lair connect to more rooms.

;room
1,an altar room
1,a cesspit
1,a larder
1,a natural cave
1,a lair with a secret door leading to [and room]

;dungeon
1,This dungeon consists of [with room], and [and room].

Can you spot the problem? It took me a few hours to understand what the problem was. I started seeing errors in the application and finally I added a quick fix to the code which suppresses the error but the output is still wrong. Take a look and note the arrows:

We now have two problems!

The first problem is that like in the example with the spellbook the list is only unique at the level of results of the “room” table. Thus, “a lair with a secret door leading to a larder” and “a lair with a secret door leading to a cesspit” are considered to be two different rooms.

Another problem – and that’s the problem that crashed Hex Describe – is what happens when the code starts processing [with room], and the first room it picks is a lair, which wants [and room]. The problem is that [and room] expects there to be a list of rooms already picked. But the first room is picked when [with room] is finished. Thus, for the computer, the list doesn’t exist, yet!

OK, but how do we fix this? We already know one fix: at the level of the list, we need to have table names, not the table results!

;altar
1,an altar room

;cesspit
1,a cesspit

;larder
1,a larder

;cave
1,a natural cave

;lair
1,a lair with a secret door leading to [and room]

;room
1,altar
1,cesspit
1,larder
1,cave
1,lair

;dungeon
1,This dungeon consists of [[with room]], and [[and room]].

No more errors in my log! Also note that we only have one lair per dungeon, now:

Yay!

Alright, time to go back to my tables. 🙂

Tags:

Comments

Wow, that discussion alone might just be the final push for me to join Diaspora! I love HexDescribe, especially since I can use it without a map.

Ynas Midgard 2019-05-18 22:16 UTC


Haha, please join us. To be honest, that is the only really good thread I’ve been in during my short time on Diaspora.

– Alex Schroeder 2019-05-19 08:37 UTC


Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.

Referrers: ZENOPUS ARCHIVES: The Tower of Zenopus in Ghosts of Saltmarsh Ynas Midgard's RPG Blog Dead Tree, No Shelter Dead Tree, No Shelter: Little Piggies Go to Market DIY & Dragons Dreams of Mythic Fantasy ZENOPUS ARCHIVES: Part 50: "The Dancing Dagger Is Hard To Hit" Notes From Under the Kyak