An End of Tarred Twine, a Monstrous Moby-Dick Hypertext

In my previous post I listed all the digital creative/critical works I’ve released in the past 12 months. (Whew, it was a lot, in part because I had the privilege to be on sabbatical from teaching in the fall, my first sabbatical since 2006. I made the most of it.)

Now, I want to provide a long overdue introduction to each of my newest works, one post at a time. Let’s start with An End of Tarred Twine, a procedurally-generated hypertext version of Moby-Dick. I made An End of Tarred Twine for NaNoGenMo 2019 (National Novel Generation Month), in which the goal is to write code that writes a 50,000 word novel. Conceived by Darius Kazemi in 2013, NaNoGenMo runs every November, parallel to National Novel Writing Month. I’ve always wanted to participate in NaNoGenMo, but the timing was never good. It falls right during the crunch period of the fall semester. But, hey, I wasn’t teaching last fall, so I could hunker down and finally try something.

An End of Tarred Twine is what I came up with. The title is a line from Moby-Dick, where Captain Bildad, one of the Quaker owners of the Pequod is fastidiously preparing the ship for its departure from Nantucket. As sailmakers mend a top-sail, Bildad gathers up small swatches of sailcloth and bits of tarred twine on the deck that “otherwise might have been wasted.” That Captain Bildad saves even the smallest scrap of waste speaks to his austere—one might say cheap—nature. The line is also one of the few references to twine in the novel. This was important to me because An End of Tarred Twine is made in Twine, an open source platform for writing interactive, nonlinear hypertext narratives.

An End of Tarred Twine is like the white whale itself—at once monstrous and elusive. And that’s because all the links and paths are randomly generated. You start off on the well-known first paragraph of Moby-Dick—Call me Ishmael & etc.—but random links in that passage lead to random passages, which lead to other random passages. Very quickly, you’re lost, reading Moby-Dick one passage at a time, out of order, with no map to guide you. Or as Ishmael says about the birthplace of Queequeg, the location “is not down in any map; true places never are.”

A Monstrous Hypertext

Here, this GIF shows you what I mean. It starts with the start of Moby Dick but quickly jumps into uncharted waters.

An End of Tarred Twine
Clicking through the opening sequence of An End of Tarred Twine

This traversal starts off in chapter 1, jumps to chapter 24, then on to chapter 105, and so on. One paragraph at a time, in random order, with no logic behind the links that move from passage to passage. As a reading experience, it’s more conceptual than practical, akin to the Modernist-inflected hypertext novels of the 1980s. As a technical experiment, I personally think there’s some interesting stuff going on.

Look at these stats. An End of Tarred Twine has:

  • 250,051 words (the same as Moby Dick, minus the Etymology and Extracts that precede the body of the novel)
  • 2,463 passages (or what old school hypertext theorists would call lexias)
  • 6,476 links between the passages
  • 2.63 average links on any single passage

Another visual might help you appreciate the complexity of the work. One of the cool features of the official Twine app (i.e. where you write and code your interactive narrative) is that Twine maps each passage on a blueprint-like grid. For the typical Twine project, this narrative map offers a quick overview of the narrative structure of your story. For example, here’s what Masks, one of my other recent projects, looks like on the backend in Twine:

A map of the game Masks in Twine
A map of Masks in Twine

Each black line and arrow represents a link from one passage to the next. Now look at what An End of Tarred Twine looks like on the backend in Twine:

EKtmWCDWsAEsMH2
An End of Tarred Twine in Twine

The first passage (labeled 0) is the title screen, with the word “Loomings” linking to the second passage (1). You can see that passage then has outbound links as well as some inbound links. Here’s another view, deeper into the hypertext:

EKtmWCEWoAArtdo
Lost in the map of An End of Tarred Twine in Twine

There are so many links between passages by this point that the link lines become a dense forest of scribbles. You can almost image those lines as a detail taken from Rockwell Kent’s stunning illustration of Moby Dick breaching the ocean in his 1930 edition of Moby-Dick.

A whale breaching the ocean, illustration by Rockwell Kent

Workflow

Now, how did I create this unnavigable monstrosity? The point of NaNoGenMo is that you write the code that writes the novel. That’s really the only criteria. The novel itself doesn’t have to be good (it won’t be) or even readable (it won’t be).

Here’s how I made a several-thousand passage Twine with many more thousands of random connections between those passages:

  1. First, I downloaded a public domain plain text version of Moby-Dick from the Gutenberg Archive. I chopped off all the boilerplate info and also deleted the Etymology and Extracts at the beginning of the novel, because I wanted readers to dive right in with the famous opening line.
  2. Now, the Twine app itself doesn’t foster the editing of huge texts like Moby-Dick. And it doesn’t allow programmatic intervention—say, selecting random words, turning them into links, and routing them to random passages. But Twine is really just a graphical interface and compiler for a markup language called Twee. The fundamental elements of Twee are simple. Surround a word with double brackets, and the word turns into a link. For example, in Twee, [[this phrase]] would turn into a link, leading to a passage called “this phrase.” Or here, [[this phrase->new passage]] will have the text “this phrase” link to a new passage, clumsily called “new passage.” There are other compilers for Twee aside from the official Twine application. I use one called Tweego by Thomas Michael Edwards. With Tweego, you can write your Twee code in any text editor, and Tweego will convert it a playable HTML file. This means that you can take any text file, have a computer program algorithmically alter it with Twee markup, and generate a finished Twine project. So that’s what I did.
  3. I wrote this Python program. It does a number of things, which follow.
  4. First, it breaks Melville’s 1851 masterpiece into 2,463 individual Twine passages—basically every paragraph became its own standalone passage.
  5. The program also gives each passage a title using the simplest method I could think of: the first passage is 0, the next is titled 1, the third is 2, and so on. That’s why there are numbers in each passage block in the screenshots above.
  6. Next, the program uses the SpaCy natural language processing module to identify several named entities (i.e. proper nouns) and verbs in each passage.
  7. Finally, the program links those nouns and verbs to one of the other over 2,463 passages by surrounding them with double brackets. This technique makes it a simple matter to direct links to a random passage. You just have Python pick a random number between 1 and 2,462 and direct the link there. Note that I excluded 0 (the title passage) from the random number generation, because that would have created an endless loop. The title passage only appears once, at the start.
  8. After the Python has done all the work, I use Tweego on the command line to compile the actual Twine HTML file.

Sample Twee

You can check out the Python program that does the heavy-lifting on Github. But I thought people might also want to see what the Twee code looks like. It’s so simple. Here’s the first main passage. The double colons signify the passage title. So this passage is “1.” Then whenever you see double brackets, that’s a link to a different passage, which is also a number. For example, the name “Ishmael” becomes a link to passage #1626.

:: 1
Call me [[Ishmael->1626]]. [[Some years ago->2297]]--never mind how long precisely--having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly [[November->526]] in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off--then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.

The links in this sample Twee code are different from the version of An End of Tarred Twine that I posted for NaNoGenMo and published on Itch. Because every time I run the Python script it creates an entirely new hypertext, with new links and paths through it. This what tickles me most about the project: anyone can take the source text and my Python program and generate their own version of An End of Tarred Twine. It reminds me of Aaron Reed’s recent novel Subcutanean, in which every printed version is different, algorithmically altered so that words, phrases, even entire scenes vary from one copy to the next—yet each version tells the fundamentally same story. In her review of Subcutanean, Emily Short suggests that the multitudinous machined variations fit the theme of the novel, of “the unknowable proliferation of motives and outcomes.”

Similarly, with An End of Tarred Twine we could have thousands of versions of the story, none alike. Just fork my code and make your own. A thousand different paths through Moby-Dick, none of them really Moby-Dick, but all of them monstrously “nameless, inscrutable, unearthly”—like the vengeful malice that drives Ahab himself to his ruin, dragging his beleaguered crew down with him.