Day 7 – Gronking dialogue graphs


These past two days have been spent working on the dialogue parser. Most of it on working out a structure for the data. In essence dialogue trees will always form a graph of nodes and branches. So a few lines and choices like this

They raised their head, eyes glinting in the soft light.
*   The two met in an embrace.
*   But neither dared make the first move.
    The silence grew heavy between them.
    * * They told an anectote to fill the space.
        Even a forced laugh helped.
    * * Soon it was too late to say anything.
- As the first signs of dawn approached they headed back.
    

will form a graph like this

Line("They raised their head, ...")
Choice [
  Option("The two met in an embrace") [
  ]
  Option("Neither dared make the first move") [
    Line("The silence grew heavy")
    Choice [
      Option("They told an anectote") [
        Line("Even a forced laugh helped")
      ]
      Option("Soon it was too late to say anything") [
      ]
    ]
  ]
]
Line("As the first signs of dawn approached they headed back.")

Every set of choices descend into nodes which may contain further choices, and so on. Nothing novel there but being an amateur I have no experience with this sort of data structure. Working out how to construct it from the simple input, how to descend into and return gracefully from nodes when requested took a lot of time. My unfamiliarity is probably clear from the code, which is about 80% very verbose tests to ensure that the results are correct (or well, should be correct). Recursion isn't difficult, treating edge cases is.

Having finally finished a dialogue graph and parsing individual marked up lines from text the next step is to work out an API that can go through a story, serving text and choice sets to the program (and player). Then, basic conditionals and variable substitution. 

Finally, while it's still somewhat frustrating to be working on the game tech rather than content, I enjoy this sort of problem solving. Still plenty of days left in the jam, I'll see what I can get done in that time.

Today's code is here (all recent work is in the `inkling` workspace).

Leave a comment

Log in with itch.io to leave a comment.