Generate Anything Site

A while ago, when I was playing Dungeons & Dragons with some friends of mine, I would come across tables of different things in the rulebooks and online for various things you could use in your campaign. Magic items, potions, character quirks, etc. I always thought they were neat and enjoyed them, but I also thought, what if you could take these tables one step further? Like procedurally generated games, what if the result of a rolled value from a table could be further modified by another table?

What if instead of just randomly picking a weapon from a table you could also randomly pick the enchantment for that weapon at the same time? What if instead of just randomly picking a character's name from a table for a new NPC you could also randomly choose a weapon for that character at the same time (say using the tool that previously picked weapons). What if you could randomly roll for the size of a town from a table and create all of the inhabitants of that town at the same time, all with their own randomly generated details (say using the previously mentioned NPC generator)?

All of that might be pretty tedious to do manually, but computers can pick many random values from different related tables almost instantly. This led me to create generate anything.

Generate anything is a web app that I made as a small project in my free time. You can use to set up what I call "generators" to randomly generate things that can have randomly generated attributes and relations to other generated things as well. It's a little abstract, which makes it a bit difficult to explain, but that also makes it more powerful. You can it to generate random things for tabletop roleplaying games, writing, other worldbuilding projects, and anything that you want complex random values.

How it works

To start generating random values you first create generators by assigning values that they can pull from as well assigning how the generators relate to each other. Then all you need to do is select a generator and you can generate as many values as you need.

Currently there's two "generators": the table generator and the entity generator.

Table Generator

You can set up a table generator just like the tables from the D&D rulebooks (hence the name) by just entering in a bunch of values at the table generator creation screen. For example you might create a table generator for different tools and enter in "wrench", "hammer", "plunger", etc. in the value fields. You can also add in other generators into the table as values that can be generated. For example if you previously created a "musical instrument" generator filled with different names of musical instruments, you could add this as a value in the "tools" table. Then when you randomly select a value from the table or "generate" a value from the table generator, if it selects an instrument, that "musical instrument" generator will then generate a musical instrument name as the resulting tool. This lets you reuse and combine tables so you don't have to re-add values from one table into another if the values of one table could go into another.

Entity Generator

The entity generator uses other generators as named "attributes" to help describe some "entity". For example you might create a "person" entity with a "first name" attribute connected to a "first name" generator", a "last name" attribute connected to a "last name" generator, and an "eye color" attribute connected to a "color" generator. Then when you run this entity generator it will create a new "person" who has a random first name, last name, and eye color. You can even connect it to other entity generators so if you wanted to simplify the names by creating a "name" entity that has both a "first name" and "last name" attribute. Or maybe you want to add a "mentor" attribute connected to the "person" entity generator itself in order to generate a random mentor with a name and eye color. The great thing about that mentor attribute is then that mentor also has a randomly generated mentor, and that mentor has a randomly generated mentor, and so on, and so on... You can create an infinite chain of related values.

You can learn more about how it works on the site's about page.

There's a couple more tweaks that I want to make in the future such as creating a "group" generator which will allow you to run a generator a random number of times and collect the values. Currently, creating a generator to, for example, generate a randomly sized population of a village is a little awkward with the current generators.

I also want to add the ability to set the distribution of randomly selected values of a table generator for values you want to come up more or less often for various uses. Using table generators in other table generators, like the "musical instrument" generator in the "tools" generator also skews the distribution if you wanted all value to be equally likely, so weighting the values could help offset that.

How it was built

You can find the code for the site at the github repo generate-anything-ui for the site. The foundation of the code for the site is based on a library I created just called generate-anything that I plan to go into detail about in another blog post.

Besides the generate-anything logic, the rest of the site I made with mostly React and bootstrap. I think the bootstrap makes it look a little generic, but it's quick and easy, and it certainly looks a lot better than it did before putting a coat of Bootstrap on it.

Using React and React Router helped make it feel pretty quick, organize the code, and give it that "Single Page Application" feel. The back end is static and it's relatively small so I didn't have to worry about anything slowing down the site or worrying about requests slowing down the site since it doesn't make any requests currently.

It doesn't use any local storage or have a back end so the generators you've created disappear when you refresh the page. To accommodate for that, and to allow for sharing generators, I added some functionality to export and import your generators as JSON so you could save them in a file locally. Serializing the generators wasn't too difficult since the generators representations aren't much more complicated than key-value structures in plain javascript objects. However when a generator refers to another generator I had to replace that with a little "reference" object since it could create a reference cycle if the object referenced the initial object which would cause an error with the javascript JSON serializer.

I was hesitant to use cookies or local storage because I wasn't 100% sure about what's required by GDPR. However I think since it's only saving that data locally, and it's not doing any tracking it probably would have been fine. I might add a little backend and database eventually just for saving that stuff so I'll probably end up learning more later anyways.

There's still a lot I'd like to clean up about it, but I think it's good enough for a version 0.1.0 release. I'd also like to improve the explanation about how to use it, however the whole thing is kind of abstract which makes it a bit tricky.

Anyways, it was a fun little project to create! I'll try to make a few tweaks and maybe add some improvements in the future. Hopefully you'll find it both an interesting and useful tool to help you fill any worlds you might be constructing!