← Tiny Subversions

Even a beginner programmer can make a novel generator

by Darius Kazemi, Nov 4, 2019

It's that time of year again... National Novel Generation Month, aka NaNoGenMo!

NaNoGenMo is a yearly event where people from around the world pledge to spend the month of November writing code that writes a novel. It's based on NaNoWriMo and we use one of their old definitions of a valid novel for the event: it's simply 50,000 words of fiction. Of course, in the spirit of keeping things weird we do not have a firm definition of either "word" or "fiction"—NaNoGenMo works tend to defy genre and bend the very concept of language.

It's a friendly event and there is no winning or losing. You simply pledge to participate, and if you manage to finish, then you can pat yourself on the back!

Of course, a lot of people are excited this year to try out new high-tech artificial intelligence and language models to see if they can make something min-blowing. But I'd like to encourage beginner programmers to give this a shot too—in particular, a beginner programmer who knows a thing or two about stories is as likely to make a great generator as an experienced programmer who is liberal-arts-challenged.

What does a computer-generated novel look like?

The official rules to participate are simple and I won't repeat them here, but one thing that can help wrap your head around this event is to see some of the output. There exist several "best of NaNoGenMo" lists out there, including:

These tend to feature really impressive works, so I'm going to excerpt a few 2018 novels here that are in my opinion more representative of a "normal" entry. You don't need to be some kind of programming wizard to participate, and people of all experience levels end up making cool stuff.


Drupe was Bring it on. Tate watched as his brother adjusted his hat again, lowered himself onto the bull's back, looped his hand under the leather rigging and secured it in . He decided to try to verify his uncle's notes. It had to be easier to do here in Ireland than from the other side of the world. He asked for help at reception.

Several direct references to began. Six hundred German wounded soldiers were found in a military hospital. Former Wehrmacht members or deserters were ordered to turn themselves in at the , cottony- aromatic.

Karwinska gathers together photographs taken over more than five years all over Poland, documenting what remains of a once extravagant plan to neonize the entire country during the s, s and s.


This one uses no artificial intelligence and no fancy natural language processing. This person wrote a bunch of code that grabs excerpts from Google Books, tries to identify valid sentences, and slams them all together. It's about 150 lines of very simple Python code.

The Cases are Two by Riccardo Crosa

I am an invisible man and on the spur of the moment I close a flowering escort. If I close a flowering escort the cases are two: the escort is jovially clog or the escort is worriedly reload. If the escort is worriedly reload that is powerful, but if the escort is jovially clog, the cases are two: the escort is rotate or the escort is fully rest. If the escort is fully rest that is fabulous, but if the escort is rotate, the cases are two: the escort is mend or the escort is gratefully derail.


Crosa's entry is based on a word game that you can play to strengthen your ability to link words and ideas with one another. It is based on a simple Tracery grammar! There's a live generator page here, too.

A Fantastical Dream by Elizabeth Finto

I'll certainly be glad to see, relieved the tense situation.But each time she had seen dart from behind them and they stood talking together in low strange voices.Later it had not wanted a little pig as ever lived.Just as Nancy ascended the front door.

Nancy's heart suddenly gave a leap of relief.

On the lower part of life I needed to be in love, she thought.Dorothy felt as if she were about to ask the police officer left, taking Willie Wharton or one of those men ordered me to pull up to the others, that no more accidents could happen.Quickly she opened it, and then pick it up.Perhaps this was actually left alone as the two girls sat down.It seemed the Grand Duke was just an orange juice salesman named Jefferson Jefferson.


This is a simple example of running a Markov process on a bunch of text, and the results are pretty coherent!

A Little Robot's Guide to Witchcraft by Ilana Bromberg

Enchantment for Rest

rose quartz citrine thyme spinel

First, take the rose quartz and the citrine and stir in water. Next, add the thyme under the light of a solar eclipse and stir in water. Finally, burn the spinel and mix together while meditating over. Apply result to forehead.


A book of spells! This is generated by taking a bunch of ingredients from Corpora and slapping them into some lovingly-crafted text templates.

Olyssas by Jemas Juyca and Jeff Leee

Stetaly, plomp Bock Molligen cema frum tha steirhaed, baering e buwl uf lethar un which e mirrur end e rezur ley crussad. E yalluw drassingguwn, ongirdlad, wes sosteinad gantly bahind him un tha mild murning eir. Ha hald tha buwl eluft end intunad:

—Intruibu ed eltera Dai.

Heltad, ha paarad duwn tha derk winding steirs end cellad uot cuersaly:

—Cuma op, Kinch! Cuma op, yuo faerfol jasoit!


This extremely clever project simply goes through a text (in this case Joyce's Ulysses) and replaces certain letters with similar-sounding letters! So "a" becomes "e", "o" becomes "u", and so on.

Give it a shot!

If you can program "Hello World", you can write a novel generator (even if it is just "Hello World" repeated 25,000 times).

Plus, every single novel ever posted to NaNoGenMo has the source code available, so you could always start by copy/pasting someone else's code and going from there.

If you're intrigued by any of this, you can open a Github issue and get started! (And if you don't know how to use Github issues, you can always contact me for help.)