Wolfram Computation Meets Knowledge

From Writer’s Block to the Cat’s Meow with the Wolfram Language

A version of this post was originally published on Tech-Based Teaching, a blog about computational thinking, educational technology and the spaces in between. Rather than prioritizing a single discipline, Tech-Based Teaching aims to show how edtech can cultivate learning for all students.

From Writer's Block to the Cat's Meow with the Wolfram Language

A blank page, bane to any writer!

If you’re trying to write a story, be it for National Novel Writing Month or just for fun, you’ll have to face a blank page eventually. The seeds of an idea can help your story grow, blooming into a sweet rose of romance or a carnivorous tale of horror. Without those ideas, all that’s left is a blinking cursor… and frustration.

If you’re stuck on what to write, maybe a little randomness can help. Using some of the Wolfram Language’s Random functions, you can brainstorm ideas, pull from image prompts, create mood boards and even chart the rise and fall of a plot.

Ready? Let’s write!

Getting Our Setup: Genre and Subject

What genre are we writing in? Genre is a way of framing ideas, featuring useful tropes we can use or deconstruct. To get a genre, let’s fill up a word list with some genres we enjoy writing. We can then pick one at random with RandomChoice.

Here is what we’d type for a choice among sci-fi, fantasy and horror, as well as the random result:

RandomChoice
&#10005


What is our story about? Let’s use ResourceFunction["RandomWikipediaData"][] to pull up a random Wikipedia page:

RandomWikipediaData
&#10005


Hm. That’s okay, but if we reevaluate the function, maybe we’ll find something better:

RandomWikipediaData
&#10005


Yes! Who doesn’t love a fjord?

Note that once we have the function, we can highlight the cell and evaluate it over and over until we get an inspiring result. (Or you could write on hard mode and use whatever result you get, even if it’s the bio of an obscure Polish shoemaker.)

If you’re not inspired through the RandomWikipediaData function, you can get some more ideas through a random list of words with ResourceFunction["RandomText"][3]:

RandomText
&#10005


Two friends travel to Greenland, and due to mixed signals, they have a falling out, resulting in sulkiness once their boat’s anchor malfunctions….

A sulky scientist sets up anchorage at a fjord and finds an unusual signal….

Once you’ve gotten an idea or two, you can find your story’s theme by changing the number at the end of the function to [1]. This will show a single, thematic word.

Let’s try it. Our theme is:

RandomText
&#10005


Not your typical theme, but perhaps it’s a metaphor for hidden depths. The sulky scientist isn’t so one-dimensional after all!

Visualizing the Story with Random Images

Having words in mind is good, but another way to keep the ideas flowing is to use random images. There are several random image functions available, so let’s try one and see what happens.

If we type in ResourceFunction["GetLoremFlickrImage"][], we can get a Creative Commons–licensed image:

GetLoremFlickrImage
&#10005


If there’s an internet, there’s a cat. Guess the scientist has a feline friend. At least the fjord has plenty of fish.

Images can help with all sorts of visualizations. For example, if there are people in the images, they can act as friends and enemies (to lovers). If there’s a location, it can be a scene in our story. A random object can act as a MacGuffin or Chekhov’s gun to ramp up the story’s tension.

How about looking at the story as a whole? Using ImageAssemble[Table[ResourceFunction["RandomPhoto"][150,150],3,3]] gives us nine random photos arranged in a table to create a mood board. Mood boards, like theme and genre, reflect the story’s core ideas and reader expectations:

ImageAssemble
&#10005


It’s a bit of work to connect the images, but there’s bleakness, prickliness, open water and looking up from the depths. There’s no horror just yet, but the fog is ominous.

Note that by priming the story with the previous random prompts, it’s easier to see where this mood board might connect with those initial seeds. This same set of random images could just as easily skew toward a rom-com where a surly, high-achieving businessman moves back to his hometown by the sea, only to discover a special someone who protects wild moose….

What a Character!

Now that we have an idea of where and what our story is, let’s figure out who the story is about.

Let’s name our characters with ResourceFunction["RandomPetName"][], which will give us a random name. If we run the function in two different cells, we can get two random names at the same time:

RandomPetName
&#10005


RandomPetName
&#10005


Salem Adams, sulky scientist, and Flora, feline first officer, star in a tale of horror as they investigate a mysterious signal from the depths of Greenland’s fjords….

Random functions aren’t just good for naming your characters: they can describe what your characters do. Say you’re writing a romance. What’s your love interest’s job? Use ResourceFunction["RandomPretentiousJobTitle"][] to find out:

RandomPretentiousJobTitle
&#10005


C’mon, we can get more pretentious:

RandomPretentiousJobTitle
&#10005


For all the sci-fi writers, let’s throw in an alien name for fun. Use ResourceFunction["RandomString"][] to create a random string of letters. Put a number in the brackets for a specific number of letters:

RandomString
&#10005


His friends call him Ulb. His enemies never even learn his name….

Hey, Plot, Where Are You Going?

At this point, your fingers might be flying over the keys, drawn into this random story. But what’s the shape of your story?

There are many ways to look at narrative and story structure. There are five-act stories that have a rise and fall. There’s the monomyth, which cycles through patterns and archetypes. There are narratives that loop and reshape themselves around characterization, focusing on snatches of time.

We’re going to let Graphics[BezierCurve[RandomReal[1,{5,2}]]]—a function that draws a random Bézier curve through a certain number of points in a certain area of space—tell us the path of our plot. Maybe it’s the level of excitement in our narrative. Maybe it’s character growth over time. Either way, we can use the random path as inspiration.

Let’s see some examples:

Random Bezier curve
&#10005


The situation steadily worsens before history repeats itself, leaving Salem once more facing peril.

Random Bezier curve
&#10005


Salem is about to lose his grant funding, and he’s hoping that the fjord trip will result in something big. Too bad he gets his wish, ending up at a lower point than when he started.

Random Bezier curve
&#10005


It’s one step forward, one step back, but Salem is never happy.

Feel free to change the numbers and see what happens. If you want to dive deeper into random scribbles, check out this explainer that explores all the parts of the function and takes you into the 3D space. (How might that change your story’s plot structure? Perhaps converging narratives?)

Mad Libs, for When You Don’t Know What to Write

Say you hit a rough patch, and you’re not sure where the story should go. Maybe you’re even at the home stretch, but you can’t think of a way to end things.

Like with the word lists and single random words for theme from earlier, you can get random words through the RandomWord function. Even better, you can request only certain types of words, such as nouns, verbs or adjectives. In this sense, we can use Mad Libs–style random words to complete our story.

First, let’s create the blanks of our Mad Libs, which will all be designated by variables. We’ll give them easy names, like adj1, adj2 and so on.

Here’s a random list of words, with those words assigned to variables:

RandomWord
&#10005


That’s interesting, but how can we use these words? We can create an ending template and insert our variables, giving us human-readable text on output. To do that, we’ll use the StringForm function. Note that you can use tick marks (``) to mark places for your variables. If you use quotation marks in your text, be sure to add a backslash (\) to keep them!

Here’s a sample snippet of code:

StringForm
&#10005


Time to gad, indeed! Start writing and see where randomness takes you.

Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.