Fun with TraceryJune 25, 2017 | View Comments | |
I’ve been playing around with GalaxyKate’s’s Tracery. It’s a sort of simple programming language for generating random text (or other content). It’s been used to create a lot of Twitter bots and games - you should check it out.
Anyway, below is a randomly generated story I made using Tracery (the first one, actually). Click here to generate new one.
King Weathercon, Prince Ballston and Mr Sainston-Smythe are standing in the garden. 'I say,' says Mr Sainston-Smythe, 'I had a good time in the pantry last night.'. Prince Ballston looks uncomfortable. The End.
I like my favourite story (thus far) for the accidental pathos of its ending:
Lord Weatherton and Madam Thropbury are painting a merry jig. ‘What do you think of liberalism?’, says Madam Thropbury. ‘The Devil’s work!’, replies Lord Weatherton. Madam Thropbury looks tremendous. Meanwhile, King Weatherton is sitting in the pantry. King Weatherton thinks about the war. The End.
For the technical people out there, the basic approach I’ve taken uses recursion and inspiration from functional programming. Each story has 3 people, but may only focus on some at a time. When the focus is on 2 people (P1 and P2, with P3 absent), the possible results (selected randomly) are:
- P1 interacts with P2 (or vice versa)
- P3 arrives, and the focus switches to P1, P2 and P3
- P1 or P2 leaves, and the focus stays on the remaining person
- The focus moves to P3
When the focus switches to, say, 1 person (we’ll call them P1 below), the possible results are:
- P1 does something
- P2 or P3 arrives, and the focus switches to them and P1
By continuously applying these rules, the story’s focus moves between different people, with something happening at each step (like a randomly selected interaction). The result is a story of variable length (how many times we switch focus is random) which has a different structure each time (a more naive approach would have all stories based on a template, like “One day, X went to Y. When they got there, they met Z. The End.”).comments powered by Disqus