Starting with Setting

My procedural novel generator (see also part one, part two, and part three) has now been augmented with some rudimentary support for settings, both time and place. An example follows:

Here is a tale from the world of Samoa. Samoa is mostly populated by Italians.

I, Giusa Rosi, am a thirty-nine-year-old woman. I have black hair. I have green eyes. I stand 146 centimetres tall. I am somewhat reluctant to accept new ideas. I am easily disturbed or irritated.

Baffaele Bianchiccino is a fifteen-year-old boy. He has black hair. He has green eyes. He stands 184 centimetres tall. He is very open to new ideas and experiences.

I do not know Baffaele Bianchiccino very well. I scorn Baffaele Bianchiccino. I do not trust Baffaele Bianchiccino.

One thousand three hundred sixty-four seconds ago, I walked to Lita.

Seven hundred fifty-four seconds ago, I met Baffaele Bianchiccino. Then, Baffaele Bianchiccino and I walked to Rovo.

Ten seconds ago, Baffaele Bianchiccino kicked me. I kicked Baffaele Bianchiccino.

Clearly, I have been focusing more on the story itself rather than the writing style (no serious author would mark up each line with the exact number of seconds ago the event took place).

Advertisements

A Procedural Novel Generator

I have embarked on a weeks-long journey to demonstrate computational creativity. I will start with a procedural novel generator. The goal of this project is to generate a world, characters, and a plot, and then express that plot as a novel.

I anticipate that this will be a large project, so I’ve brought in machinery from LIJN (a past project of mine) to get it started. So far, piggybacking on LIJN’s sentence tokenizer, I’ve gotten done a rudimentary way for the computer to “write”:

story = [syntax.Word('this'),
         syntax.Word('is'),
         syntax.Word('a'),
         syntax.Word('test'),
         syntax.Word('story'),
         syntax.COMMA,
         syntax.Word('set'),
         syntax.Word('in'),
         syntax.Word('the'),
         syntax.Word('world'),
         syntax.Word('of'),
         syntax.ProperWord(self.setting.name),
         syntax.PERIOD,
         syntax.NEXT_PARAGRAPH,
         syntax.Word('it'),
         syntax.Word('is'),
         syntax.Word('a'),
         syntax.Word('demonstration'),
         syntax.Word('of'),
         syntax.Word('what'),
         syntax.Word('is'),
         syntax.Word('to'),
         syntax.Word('come'),
         syntax.PERIOD
         ]

…which when reassembled will produce this not-so-interesting output:

This is a test story, set in the world of Cinova.

It is a demonstration of what is to come.

The name of the world is generated with a Markov chain algorithm also conveniently already included in LIJN.

I hope to get some more done on this in the following weeks and post updates when there’s something interesting.

You can read Part 2 here.

Python is inconsistent, but logically so

Today I realized that Python (the programming language) has a ton of ways to negate expressions:

Equality

a == b
a != b

The first = sign is converted to a ‘!’ sign to negate equality.

Identity

a is b
a is not b

A not keyword is inserted after the in keyword.

Test if in collection

a in b
a not in b

A not keyword is inserted before the in keyword.

Most other stuff

hasattr(a, b)
not hasattr(a, b)

A not keyword is placed before the whole expression.

Despite these inconsistencies, the above is perfectly logical, and very easy to understand and read. It just goes to show that exceptions are not always a bad thing.