October 3, 2008

Extending Gygaxian Naturalism I (or Directed Graph Theory for Monster Ecology)

Recently, James Maliszewski posted about something he calls "Gygaxian Naturalism". If you haven't read this post of his - then please take a walk over there first. It is a real gem of the RPG blogosphere. OK, back already?

If you read through the comments of his post you would have noticed my shameless plug of the Monsters & Terrain Core List. My interest in developing this list is an extension of my D&D roots, if you will, and of what Mr. Maliszewski calls Gygaxian Naturalism. The general idea is that game designers set down guidelines the habitats and environs of every creature, who they live with, and some basic information about their culture, society or behavior. Guidelines, not rules, for DMs to fiddle with to suite their own campaigns of course.

OK, where am I going with this? Well, lets just say that - while useful - the Monsters & Terrain core list is just not enough for me. I want something more; something that gives me an idea of what groups of creatures are found together given their terrain and climate. Not just single creature groups, like 1d10 orcs or 2d4 dire hyenas. Instead, I want a system for randomly generating cohorts of creatures. For example: you encounter 2d10 orcs and among them 2 ogres and 2 dire boars. More generally speaking, I want a table of probabilities that associates Creature X with Creature Y, given Terrain and Climate A and B. In my field, we would call this a directed graph, which in practice is represented by a huge table of probability functions. Yeah, I know... this is stupidly nerdish. Think I care? ...

OK, maybe some of you math nerds out there are already with me on this. Maybe not. In mathematics, graphs (i.e. networks) are commonly represented by nodes and edges. The nodes are the entities and the edges are the lines connecting them. Edges can also represent probability functions. As a simple example, lets say we have 2 nodes (A and B) and two edges (A>B, B>A). Let's also say that the probability of B, given you already have A, is 50%. Let's also say that the probability of A, given you already have B, is 10%. The resulting graph would look like this:
Now lets add a third node, C, into the mix.
Finally, lets call each of these nodes orcs (A), ogres (B), and trolls (C).
This graph essentially describes a (simple) fictitious ecology of Orcs, Ogres, and Trolls. From this graph you can say "OK, if we encounter orcs, there's a 50% chance of ogres being present, and a 1% chance some trolls will be there as well." Conversely, if you encountered Trolls, there is a 5% chance they are going to have some orcs with them, and a 25% chance there might be some ogres in their cave too. NOTE: If you were willing to let the graph run unassisted, you could also extend the results to include 'two steps' or more - but going beyond one-step for each node is beyond the scope of this discussion.

Now imagine for a moment that a giant graph, such as the one described above, was created for all the 600+ monsters in the Monsters & Terrain Core List. Then throw together an application that utilized all this data for DMs everywhere. The result would be stupendously nerdish - but, also awesome! Any given DM would be able to click "Temperate Forest", "Level 5 Encounter", and voila! an encounter could be generated that made sense. Without any of the work of hunting down good combinations of creatures, etc.

The Monster Ecology Table would be how such a graph would be represented (another list!). Its set up would be easy to implement, but very time consuming to fill with all the needed pieces of data. The 3 node directed graph shown about, for example, could be represented using a tiny table such as the one below.

The problem arises when you try to extend such a table to 600 entitites. Well, its not so much a problem as it is a burden - a table with 600+ columns and 600+ rows (360,000 cells) is rather unwieldy. A better data structure for this directed graph would be a lookup table (i.e. a hash table), since each entry might only have 3 or 4 associated nodes. For example - orcs (in our example) are only associated with themselves, trolls, and ogres. An edge in the graph that connects orcs with elves would have a probability of 0 (lets assume orcs and elves don't mix, shall we?), thus there is no need to even list it. A look up table for Monster Ecology would be 600+ rows long (one for each monster) and include (possibly) a maximum of 5 or 6 columns for associated monsters. Our 360,000 cell table now shrinks to a maximum of about 3,600 cells. This may seem like alot, but the table of Monsters & Terrain I've already assembled contains 13,200 cells (ugh... makes me sick to think I acutally filled it all out). In any case, Monster Ecology table is therefor very doable.

I've said enough (read: way too much) about this today.

In my next post on this topic I've going to go over some of the research that is needed for (as far as I'm concerned) a correct view of each monster's place in its environment. I'm talking about looking at each monster/creatures role and fictional habitat across each of the 5 editions of Dungeons & Dragons, and how the game designers have changed things right under our noses...


  1. This sounds like a very interesting project. I'm interested in both the results and methodology.

  2. Great! at least one person will be following this series. =D

  3. Indeed...this is definitely something to keep an eye on...given enough effort we might just see one of the most extensive naturalist random encounter tables ever...

    Hope you don't break your brain!...

  4. Don't forget to take alignment and racial type into account.

    In 3E terms, an aasimar and a Succubi could be found on the same planar locale, but not together, saavy?

    Or another good one would be CE bad guys rolling with just evil ones. The CE would probably be viewed with fear and loathing even by the other "evil" creatures.

  5. Quick question, dont trolls eat orcs? lol.

  6. Ah.. yes! now the statistical model simply grows in complexity.. alignment, food choice... mwhahhahaha

    yes, with Gary's House Rules, trolls eat orcs - and whatever else they can grab. Thats why only 5% of trolls have any orcs around. Maybe those orcs unfortunate enough to have a troll around keep them happy by bringing them a constant supply of tasty dwarf slaves to snack on in the meantime...

    wait, did you hear that? ... an adventure was just born.

    ^ i think that's my new tagline for the blog.

  7. I am in awe of your geekness.

    Do you intend to do this with Google Docs (I am not knowledgeable on their capabilities)?

  8. ...and adventure is born...

    Nice tagline, unless I STEAL IT FIRST! MWAHAHAHA!

  9. @MadBrew : Google docs would be suitable probably only for the data entry. If the project ever sees the light of day, then flatfiles or a remote mysql server would be the option I would choose. Why... interested in a collaboration? Boy o boy it would be a stupendous waste of time! Sort of like when I coded the NPC Equipment Generatorthrough two versions way back when.

    @Donny : I grabbed it! =D

  10. Well we could add it all my other stupendous wastes of time, a MUD, some Flash games, and various other projects that didn't even last long enough to be named.

    The problem is that I could best do it with a .NET solution, which means a stand alone app, unless one of us gets Windows hosting.

  11. im on a mac. =P so...

    freehost to use a mysql server (free)

    javascript for the interface - on a page with adsense (hey.. nickles add up!)

    well, that's what I was thinking eventually. I need to sharpen my javascript skillz though - haven't done much coding with that in a couple years.

    But before that all would happen - more work would need to go into thinking about data structures and how to represent the 'network' of creature:creature interactions, etc.

  12. Interesting, but I suspect way overkill. Really, I would expect most of the lists to contain only the self node. Orcs and Trolls, maybe. Displacer beasts and anything else? Not in a remotely naturalistic ecology, despite the ice caves in Baldurs Gate: Dark Alliance.

    Couldn't you get almost all the plausible combinations by listing out only the sapient species, and for each of them allied sapients and domesticated beasts with a chance of occurrence?

  13. Love this idea. Having this kind of creature ecology resource would save me lots of work in building naturalistic scenarios.

  14. > stupendously nerdish - but, also awesome!

    I propose that statement to be redundant.

    Just because every project needs its scope extended.

    You can also make non-monster nodes. Treasure came to mind first. Captives, livestock (maybe one and the same). Particular features in lair, shrine, throne room, secret treasure room. If there is a leader, a shaman, other class types. Non-combatants, children.

  15. @ njharman : thanks for stopping by and welcome! Hopefully I'll be able to get back to this project after the Anthology is published. I still think it would be super geek aweshum to make a gygaxian naturalism random encounter generator - but i don't have the time right now to develop it.


By submitting your comment below, you agree to the blog's Terms of Service.