Choose your own adventure digraphs

The structure of a choose your own adventure–type book is a directed graph. At the end of each page, you are instructed to turn to the next page or to a specific numbered page, or you get to choose from a selection of numbered pages.

It's pretty easy and fast to pull out the structure of any book, without actually reading it, and only looking at each page once, and then visualize it using a program like Graphviz. Start at the first page, and look at each page in order (i.e., don't follow the instructions about where to turn next). Let's say you are on page 5. If the book tells you to turn to the next page, write down the graph edge

5 -> 6
If the book tells you to turn to page 40, write down the graph edge
5 -> 40
If the book says if you fight the mummy, turn to page 12; if you run away, turn to page 65, write down the graph edges
5 -> 12
5 -> 65
If the book says The End, label the page as an ending state (you can also annotate whether it's a good ending or a bad ending, etc.):
5 [label="5\nThe End"]
Then throw the whole thing into Graphviz's dot mode, and it will link up all the edges for you.

I was mainly curious to see whether diverging paths ever reconverged, and whether the graph could have cycles. One of the books I looked at had a simple graph, and the other was complicated.

Table of contents

Related links


Mystery of the Sacred Stones

Cover of Mystery of the Sacred Stones

Mystery of the Sacred Stones by Louise Munro Foley, #79 in the Choose Your Own Adventure Series, has a structure that is a rooted tree. Once you choose a path there's no turning back; no two choices lead to the same ending.

Source: sacredstones.dot. To recreate the graph, run dot -Tpng sacredstones.dot > sacredstones-graph.png.

Digraph for Mystery of the Sacred Stones

Pipe Down!

Cover of Pipe Down!

Pipe Down! by Clyde Bosco/Russell Ginns, #5 in Nintendo Adventure Books, has a much more interesting structure. It is not even a DAG because it has cycles: certain choices can bring to back to an earlier position.

Reviews of Pipe Down! at Demian's Gamebook Web Page.

Pipe Down! has an inventory system. You are meant to keep track of your current inventory in pencil on a scorecard on the last page. Some choices are determined by what items or how many coins you have.

Some of the choices you are offered are accompanied by a puzzle. Solving the puzzle correctly tells you the "right" choice to make. I've annotated the edges with whether they are the correct or incorrect solution to a puzzle. It's not clear that the "right" choice always leads to the best outcome. See for example the choice on page 25, where the "wrong" choice of going to the show vault allows you to skip ahead with no penalty versus the "right" choice of following the princess.

There are various funny cycles, such as page 3, which, if you choose the center pipe, just takes you back to page 47 where you came from. The puzzle on page 21 lets you collect a variable number of coins. It's not possible to collect less than 10 or more than 50 coins, but the book tells you to go to page 42 if you did. Page 42 tells you that what you just did was impossible and sends you back to page 21.

To get the only good ending, you need to have collected the cowboy boots on page 19 and released them on page 62 (which in turn forces a choice on page 27). Even then, it's possible to lose if you have less than 50 coins or if you choose Luigi on page 33. If you missed the cowboy boots, you have one chance to recover as long as you chose the flower lever on page 52 to collect the starman and didn't lose it in an attack on Ludwig on page 30. Searching the room on the left from page 45 will take you back to make the boot choice again.

Source: pipedown.dot. To recreate the graph, run dot -Tpng pipedown.dot > pipedown-graph.png.

Digraph for Pipe Down!