Skip to content

A Java class to create interactive yes-no "Choose Your Own Adventure" stories.

Notifications You must be signed in to change notification settings

N8python/DecisionTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

The DecisionTree class is a flexible way to build choose-your own adventure stories. It's great for Java classes, or fun little side projects. To start, create an instance of DecisionTree:

DecisionTree story = new DecisionTree("You sit by a lake, tired. Blue water flows by you. Do you drink the water?");

Then, pass the instance constructor two more instances of decision tree:

DecisionTree story =
      new DecisionTree(
        "You sit by a lake, tired. Blue water flows by you. Do you drink the water?",
        new DecisionTree(
          "You bend in and drink the water. It tastes sweet. Do you look for fish to catch in the water?",
          new DecisionTree("You look for fish. As you do, a shark swims by and attacks you. You die."),
          new DecisionTree("You withdraw from the water as a shark passes by, escaping death by moments.")
        ),
        new DecisionTree("You refrain from drinking the water. 
        A few minutes later, a shark swims by. 
        You realize that had you entered the water, you would have died.")
      );

When a decision tree instance is only passed a string, it is considered the end of the story.

Then, to "use" your story, use the static tell method of DecisionTree:

DecisionTree.tell(story);

Then boot up the console, and watch the magic happen (okay - a yes/no story isn't magical, but it is still cool that you can create one in only two lines of code.)

About

A Java class to create interactive yes-no "Choose Your Own Adventure" stories.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages