Problem 2 – using Python to write stories
Let’s look at a fairly simple problem. In this section, we want to create an algorithm that produces a story based on input from a user. We can make this as simple as we want, or add some options. Let’s dig into what this is.
Defining, decomposing, and planning a story
First of all, what is it we’re trying to create? Well, a story. Because of the nature of this problem, we’re going to start in reverse, with a sample of the output we want to achieve – that is, a sample story. Let’s take a look at a quick story generated by our algorithm before we get into the algorithm:
There once was a citizen in the town of Narnia, whose name was Noemi. Noemi loved to hang with their trusty dog, King Kong. You could always see them strolling through the market in the morning, wearing their favorite purple attire.
The preceding output was created by an algorithm that substituted names, locations, time...