## Weather and Ancillary Events

I made the `Universe` a bona fide Entity in the program so it could also generate moves / events, and gave it the ability to generate different kinds of weather events sporadically: rain, snow, sunny weather, etc. I also gave animals the ability to have a preference of sunny or cold weather. Cats like sunny weather, whereas wolves prefer cold weather, for example. I also added the notion of unconditional ancillary events to a main event: if something makes an entity happy, for example, it will always want to express appreciation for that event and I shouldn’t have to shoehorn that into the move generation machinery. (I need to retool the “express gratitude” event for the dog-gives-the-duck-a-stick story to use this new formalism.)

It’s interesting to see how Harible (I should start calling him Chip for branding purposes I suppose) tries to maximize happiness depending on the initial entities of the universe.

Here’s the story that’s generated when the universe consists of a single house cat:
``` # evaluated: 6, score: 5, eval: 0```

``` ```

```Best score: 5 The weather changed to sunny. Cammie Cat expressed appreciation to the universe. Cammie Cat went away.```

…whereas this is the “ideal” story generated when the universe consists of a single wolf:
``` # evaluated: 6, score: 5, eval: 0```

``` ```

```Best score: 5 The weather changed to snow. Woody Wolf expressed appreciation to the universe. Woody Wolf went away.```

Fascinatingly enough, if I add both a wolf and house cat to the universe, we get this:
``` # evaluated: 19, score: 5, eval: 0```

``` ```

```Best score: 5 Woody Wolf went away. The weather changed to sunny. Connie Cat expressed appreciation to the universe.```

Why did the wolf go away first? Because Chip saw that if the wolf was present when the weather became sunny, the wolf would have been unhappy, so it maximized the story’s happiness by first making the wolf go away, then allowing the sun to come out!

Finally, if I increase the search depth from 2 to 3, we get this:
``` # evaluated: 29, score: 20, eval: 0```

``` ```

```Best score: 20 Wally Wolf saw Connie Cat and wanted to chase Connie Cat. Wally Wolf chased Connie Cat for awhile. Wally Wolf and Connie Cat reconciled and became friends.```

Chip found it a happier story that the two animals became friends because the search depth of 3 allowed him to find that possibility. (Also, I didn’t factor the cat’s fear of being chased into the happiness equation. 🙂 ).

Again, this doesn’t really feel like the way that real authors concoct a story, but I’m getting interesting and fascinating results, so I’m going to continue down this path.

## Dog Chases Cat

Added better names and the class hierarchy as per the previous post. Also added event sequences which can span multiple moves. Here is a chase sequence, which has a `WantToChaseEvent`, `ChaseEvent` and `ReconcileEvent` whereby both chaser and chasee are happy with the reconciliation:

`# evaluated: 2, score: 20, eval: 0`

``` ```

```Best score: 20 Dilly Dog saw Cassie Cat wanted to chase Cassie Cat. Dilly Dog chased Cassie Cat for awhile. Dilly Dog and Cassie Cat reconciled and became friends.```

## Next Task: More Animals, Better Names

I’m going to create a class hierarchy of a larger list of animals: their likes, dislikes and capabilities, and also try to generate better names for the animals, cross referencing the names against an actual name database. I’m also going to allow the universe to speak: it can serve as the narrator.

A friend of mine told me this the other day:

Spencer (age 12) just read the story about Donica Duck and the tree. His response: “does the AI that wrote the story know that the duck didn’t necessarily intend the stick to be for the dog? It just said “the duck brought the stick to the ground” The duck could have had other plans for the stick…and the dog might have eaten the duck…hmmm…maybe they had a “no eating” pact…

I treat this response as a total success for robot fiction, because Spencer has placed himself in the world created by the story… and I’m also impressed with Spencer’s observation that the dog’s gratitude may have been misplaced.

## Duck Gets Dog a Stick: SUCCESS!

Happy New Year!

After toiling away at this for over a week, I’m declaring this a success! (See the previous post for the backstory behind this.) Here’s the generated story:
``` # evaluated: 7, score: 110, eval: 0```

``` ```

```Best score: 110 Donica Duck moved the stick down from the tree to the ground. Deruiter Dog took the stick from the ground. Deruiter Dog expressed appreciation to Donica Duck. ```

I first had expressed the rules in Prolog and threw both my self-made Prolog interpreter as well as an open source Prolog interpreter at this, but it turned out to be too slow, so I did the move generation by hand. I also cannibalized a chess program I had previously written, generalizing the concepts of “board”, “move”, etc. so that the chess board is the story universe and a move is an event in this universe. The current evaluation function simply maximizes happiness but can later be made more sophisticated by introducing drama, misery, etc.

Although I’m ecstatic this worked, I’m not 100% sold on this approach because:

• if the branching factor is too great, the maximum achievable search depth will be greatly restricted
• this doesn’t intuitively feel like the way stories are created by humans

That said, a hybrid approach might be possible. And as long as my goal of creating an entirely new art form (computer-generated fiction that humans find engaging) is achieved, I don’t care by what mechanism that ends up happening.

## Duck Gets Dog a Stick?

Even the goals I outlined for myself in November, 2015 are too ambitious for the time I have at my disposal. Let’s try something simpler.

Dogs enjoy sticks because they can run around with them. There’s a stick in a tree that would be perfect for a dog but it can’t reach it. A duck could fly to the tree and get the stick for the dog, though, thereby making the dog happy.

Let’s make a set of rules and inferences for this and see if we can get Harible to generate a pleasurable story by processing these.

## Next Ambitious Mini-Project: Use Searching and Inference

I’ve been procrastinating on my next mini-project because it’s more ambitious. It involves taking a stock list of animals, then generating a story based on their likes and dislikes. They will push a button and go to different habitats, where different animals living in those habitats may be, then join each other and interact with both each other and their world based on their preferences. Random events will also occur. Their actions will also ideally be based on hypothetical simulations. (For example, a duck doesn’t necessarily care for a stick, but if it can retrieve it from a place inaccessible to a dog and give it to the dog, it can make the dog happy.)

Here’s a brain dump of what I have so far, in a format that is only meant to be understood by me:

```cat
- likes chasing small moving things
- hates water
- purrs when it's happy
- is afraid of dogs
- is afraid of larger animals
- can inflict damage with claws
- likes treats
- likes food```
```dog
- likes to chase cats
- likes to please its owner
- likes belly rubs
- likes to swim in water
- likes treats
- likes food```
```duck
- loves water
- can fly
- likes treats
- likes food```
`dolphin`
`robin`
```snake
- likes the sun
- hates water
-```
```lizard
crow
sparrow
pig
goose
fox
goat
wolf```
```home
habitat
behavior```
```random universe elements
- random landscape

forest
desert
woods
- pond
- no pond
mountain```
`- random events`
`push a button - go somewhere else`
```random events
- rain
- sunny
- snow
- hail```
```things you can find in these places
attitudes towards events and things```
`if X and Y and Z, then occurs({Q:probability, R:probability, NOTHING:probability})`
`if X then utter({Q:probability, R:probability, NOTHING:probability})`
`want to do nice something for the other`
`meets(X,Y)`
```generate story timeline events
start
conflict
denoument```

## Animal Names / Story 00002

Found this gem:

http://www.speech.cs.cmu.edu/cgi-bin/cmudict

Based on this, I concocted a primitive phonetic matching algorithm to generate random animal names. Here are some of Harible’s next stories, which involve two randomly-generated animals being the best of friends:

Furniture Ferret and Conover Crayfish were the best of friends.
Longacre Lion and Diviney Dove were the best of friends.
Satagaj Swan and Pas-de-deux Piglet were the best of friends.
Jenninger Jaguar and Faraha Fox were the best of friends.

## Next Assignment: Animals

OK – here’s my next assignment. We’re going to start small, with children’s stories. I think I have a good handle on how to write a decent children’s story myself.

We’ll start the attack like this:

• Gather a list of common animals. (Done)
• Come up with a way to generate cute prefixes for the names of these animals in English (Janga Jackal, Kiminy Kangaroo, or something like that – no idea how I’m going to do this).
• Handcode some basic knowledge about each of the animals in this list that will give rise to goals that a given animal would want to accomplish within a story (a mole wants dark and to burrow, a cat wants to chase things).

After the above, I’ll figure out what to do next.