I’ve spent the last week or so exploring Seventh Sanctum data files. Ultimately they proved to be less complicated than I thought at first, but they do involve some unexpected design choices.
Not my best code, I’ll admit, but for a proof of concept it’ll do.
All three file formats are handled.
Vocabulary Files
This is the easiest format to work with, mostly because the content is static. There were a few wrinkles in the syntax (word ‘types’ are indeed numbers… treated as bitmasks), but I got it sorted.
$ ../7s.pl magicguilddat.txt 10
- Cursed Advocate Card
- Magpie Harp Guild
- Werewolf Glittering Guild
- Unconscious Fish Guild
- Murdering Otter Guild
- Faun Prince Faun
- Baroness Road Guild
- Cyclops Sentinel Guild
- Enchanted Killing Counsellor
- The Skin Goblin
These also gets used in configuration files.
Seed Files
Surprisingly easy to implement, after all. There are really only four record types:
- Top-level ‘table’ records
- Row records
- Table modifier records
- Table modifier row records
- Table modifier records
- Row records
Loading and parsing the file was easy. Tokenizing row records also was easy. The only tricky bit was remembering to reset the dictionary after each iteration of string generation.
$ ./7s.pl whatifgendat.txt 10 SEED
- …Mohammed was indirectly responsible for the invention of the League of Nations?
- …the fall of Satan involved nuns/monks?
- …Tomas Edison was a police officer?
- …the advent of Christianity had never happened?
- …the advent of Christianity involved virtual reality?
- …Adam Smith was actually Plato?
- …Nero lived in a world where the warring states period in China had never happened?
- …the Klondike Gold Rush involved the telephone?
- …the American Revolution involved faster-than-light travel?
- …the rise of the Maya Empire involved a terrible secret?
Having looked more closely at this, I’m confident dynamic tables can be replaced with a set of static tables. I suspect that set of static tables will be annoyingly large and convoluted, though.
Configuration Files
I consider vocabulary files easier to work with because they can be self-contained and generate output. Configuration files are simpler to load and parse, but they need more processing to be ‘useful’ (give output).
My first implementation was inefficient. I load each referenced file as I find out. In one configuration file, I found 36 copies of the same file. Ah well. It was easy enough to delay loading the references files until needed.
Configuration files can import either vocabulary files or seed files. My implementation can differentiate on a per-symbol basis, but I believe the existing configuration files do not do this.
For example, pizzaconfdat.txt
imports vocabulary files with differing ‘organization’ records (random generation templates), but share a file with the ingredient list.
$ ../7s.pl ../conf/pizzaconfdat.txt 10 MEAT
- A pizza with Sausage and Pulled Pork, topped with Emmental and Provolone.
- A pizza with Tuna and Clams, topped with Paneer and Cheese Sauce.
- A pizza with Pepperoni, Chicken, Salami, Buffalo Meat, and Cilantro, topped with Havarti and Cream Cheese.
- A pizza with Canadian Bacon and Ham, topped with Emmental, Tomato Sauce, and White Sauce.
- A pizza with Clams, topped with Mascarpone, Roasted Fennel, and Paneer.
- A pizza with Shrimp, Pulled Pork, Linguica, and Clams, topped with Colby and Gruyère.
- A pizza with Short Rib Meat, Fennel, and Basil.
- A pizza with Sausage, Pulled Pork, and Prosiccuto, topped with Clam Sauce and Cream Cheese.
- A pizza with Canadian Bacon, Meatballs, Egg, Pepperoni, Basil, and Red Chillies.
- A pizza with Shrimp, Tuna, Short Rib Meat, and Cilantro, topped with Mint Chutney and Jalapenos.
With seed files, it looks like configuration files are used to identify entry points into the seed file. Each configuration file that imports seed files imports the same seed file for all entry points.
$ ./7s.pl conf/mlponyconfdat 5 SEEDANY
Okay, that’s got all three file types covered.
- This gangly male pony is an earth pony who is romantic and witty. His coat is plum-colored. He has a mane that reminds you of a plume of smoke. His hooded eyes are gray. His mark is four bones.
- This leanly-built stallion is an earth pony who is slow-witted and industrious. His coat is brown. He has a mane that is black, and it reminds you of a puffy dandelion. His eyes are brown. His mark is a tiara and a card.
- This pudgy male pony is an earth pony who is calm, smooth-talking, and moral. His coat is amber. He has a mane that reminds you of a gush of water. His eyes are yellow. His mark is a carrot.
- This lean male pony is a unicorn who is classy and educated. His coat is rust-colored. He has an extremely long mane that is blue and gray. His eyes are yellow. His mark is three pumpkins.
- This bulky female pony is an earth pony who is calm and air-headed. Her coat is apricot-colored. She has a mane that is purple, and it reminds you of a trailing ribbon. Her eyes are white. Her mark is a bannana peel and a bow.
Closing Comments
This was an interesting puzzle. I think I’ve got everything covered, at least enough to make use of the information. I am now confident I can get what I actually want out of these files (more tables!). I also see some utilities I might want to incorporate into my own random generation program.
If I were to implement this in a less exploratory, more ‘production’ way I’d want to rewrite my code, though.