Simple CYOA

version 1 by Mark Tilford

  • Home page
  • Beginning
  • Next

  • Documentation

    This allows the user to make simple gamebooks. Also supports 'look' (redisplay current text), 'undo', 'save', 'restore'.

    There is a kind of value 'game page'. The author must give a type of game page for each reference in the game. (For example, "The game pages are at entrance, left door, right door, down hall, take sword, climb ladder, take potion, back down, take sword 2, left bridge, right bridge, drink, and across bridge."). The author must also set the variable 'initial page' appropriately. (Continuing, "Initial page is at entrance.").

    For each page, the author must add a rule "Instead of displaying page _____, instead ...". For each choice the player can make on that page, put in the text "[link ____](Description of choice)", where ____ is the game page which follows. (For example, Instead of displaying page at entrance, say "You find yourself in a long hall with doors on either side. Do you [link left door]go left, [link right door]go right, or [link down hall]go forward?".) To end the game, do not provide any links from a page. To move to a different page without prompting for a choice in between, put "[continue to ____]" in the description.

    If the game is to have any state beyond the current page, the author must add appropriate variables to the 'game state' kind. (For example, if you want to keep track of a score, "A game state has a number called the player score.") and initialize initial state appropriately. (The player score of initial state is 0.) Display page actions should not make any changes to game state; instead, put any changes into a prepare page rule. (For example, Instead of preparing page take sword: increase player score of current state by 1; now current state is has sword. Instead of displaying page take sword: say "Taken. Now do you [link climb ladder]climb up the ladder or [link right door]go out the door?".)

    There is also a rulebook called the interturn rules, used to monitor for changes. They will be called after the text and all choices have been displayed, but before prompting for input. The state of the game before the choice is accessible in the variable backup state, if the author wishes to compare the two. (For example, to notify on score changes, An interturn rule: if player score of current state is greater than player score of backup state then say "Your score went up by [player score of current state - player score of backup state] point[s] to [player score of current state].". An interturn rule: if player score of current state is less than player score of backup state then say "Your score went down by [player score of backup state - player score of current state] point[s] to [player score of current state].".) The game should not modify backup state in any way.

    By default, each choice is displayed on its own line. To have choices listed within the text (as in "You can 1) enter the house or 2) back off slowly."), put the line "Use inline choices;" at the start of the file.

    For debugging a game, adding "Use mention all changes;" before include Simple CYOA will cause it to list all changes detected between turns or when undoing.

    At present, there can not be more than 4 choices from any single page. In addition, the undo buffer is limited to a fixed size of 100 (50 turns with no state, 25 turns if there is one variable which changes every turn, close to 50 turns if state variables change very rarely). Both these limits should be author-settable in future releases.