Honors 295 - Fall 2003
Project 1: Random comics, part 2

Due by email to DD, before class, Oct 15


Description

In this assignment, you will continue to explore storytelling in comics. The assignment involves extending the scheme program from class October 1 so that it generates random comics in a new way.

You will again use the imagery from The Unstrung Harp: Or Mr. Earbrass Writes a Novel the 1953 classic by Edward Gorey. (Republished by Harcourt, 1999.)

In class, we developed two ways of writing random comics.

Actually, it didn't seem like either of these procedures was that effective. The random comics were always a little too random.

Here's some motivation for a different random comic procedure. A good story isn't just any sequence of transitions. It uses particular transitions in order to portray some meaningful events. For example, it might have a few introductory panels in which some kind of problem arises for the main character: that sequence might particularly involve action-to-action or subject-to-subject transitions. Then the story might continue to highlight the main character's response to the predicament. We might see a few scene-to-scene transitions. The conclusion of the story would be another portrayal of events and consequences, with action-to-action and subject-to-subject transitions.

In other words, you give a more interesting direction to the organization and plot of the story by describing the specific structure of transitions that you want. To represent the structure of the story in scheme, you would use a list of transitions. For example:

(define s1 '(action-to-action subject-to-subject scene-to-scene
             scene-to-scene action-to-action subject-to-subject))
Now to create a random structured story, you can choose a sequence of images that match these transitions. At each step of creating this story, you have the current panel and the list of transitions you need to finish the story. To complete the story, you start with the next transition that you need. You know what images follow the current image with that transition, from looking at all the stories we made for homework. You pick one at random, and proceed to generate the rest of the transitions starting from the chosen image.

This assignment asks you to write a scheme program that creates a random structured story in this way.

Scheme

You'll need two files (which you should place in the same directory as goreydisplay.scm and the images from part 1 of this assignment):

[Update 10/13]: If you're working in the cereal lab, then get these files by doing the following:
         cp /ilab/project/vfam/scheme/goreydisplay.scm .
         cp /ilab/project/vfam/scheme/comics.scm .
         cp /ilab/project/vfam/scheme/annotations.scm .

You need to write 2 functions (and a helper function for the second one):

  1. Define (labeled-transition-starts-with p label) that uses filter to process the annotations list into a list where each transition starts with p and has transition type called label. What you write will greatly resemble transition-starts-with; you're only changing the lambda expression so that it filters based on label as well as p. (Don't forget that = is only for numbers; you need eq? to compare labels.)

    For example, the expression:
         (labeled-transition-starts-with 8 'subject-to-subject)
    has the value
         ((8 11 subject-to-subject) (8 21 subject-to-subject)).
    Compare this to the output of (transition-starts-with 8), which contains transitions of any type.

  2. Define (random-structured-story struct) which generates a random story that respects the transitions in struct. This function, and its corresponding helper function, are different in two ways from (random-unstructured-story len):

    For example, the expression
         (random-structured-story s1)      (using the s1 from above)
    produced:
         ((tell "A series of unfortunate random events.") (show 11) (show 28) (show 22) (show 13) (show 11) (show 28) (show 21) (tell "The End."))

    Of course, since it's random, it will produce a different story each time. It's possible it produces a shorter story; this means that it dead-ended with a story it couldn't finish.

    When you're trying out your function, test it on a short list of transitions (1 or 2) so you can understand what is going on.

The scheme file comics.scm also contains two more utility functions that weren't mentioned in class, that you might find helpful when testing or playing with your program. The first, called (tell-it story) is the same as running (tell-story story gorey-earbrass-list). But it also returns the story that was passed in. This way, if you see a random story that you like, you can watch it again by saving or copying the value printed in the scheme execution window. For instance:
     (tell-it (random-structured-story '(scene-to-scene)))
shows you the pictures in the story, but actually returns the value:
     ((tell "A series of unfortunate random events.") (show 4) (show 7) (tell "The End."))

The second function, (try-to-tell-it struct attempts) runs (random-structured-story struct) repeatedly (how many times is given by attempts) until it finds a story that uses the entire list of transitions, struct. If it finds one, it uses tell-it to show you; otherwise it produces #f. An example:
     (try-to-tell-it s1 20)      (again, using s1 from above)
which means it will try up to 20 times to find a complete story with 6 transitions (or 7 pictures) in it.

Given the combinations of transitions in annotations, many stories are just not possible. For instance, a story that has a non-sequitur transition is impossible, as nobody labeled any transition using that label. For any reasonable combination, a value of 10 or 20 for attempts is fine; you shouldn't have to use a value much larger than 100. Instead, try to find a more likely set of transitions.

[Update 10/13]: The scheme feature let isn't in the book, and was only talked about in class. We made a brief supplement that might help, available as either a scheme file or just plain text.

What to hand in

Hand in your new scheme program. The program should contain:

Extra Extensions

If you get this done quickly, and want to experiment some more with Scheme, you might try changing random-structured-story so that its stories never contain duplicate images.

Here's a hint about how to do that. You get a duplicate image when you follow a transition back to an image you've seen before. That means that you can avoid duplicate images by filtering the list of available transitions, and removing those that take you back. This filtering needs to happen at each step of recursion, so that all the images you use are avoided. At each stage of recursion, your function needs to be supplied the right list of filtered transitions as an extra argument.