Jump to content

Hey guys,

 

I'm writing a program that mimics the way 'choose your own adventure' stories work. I'm stumped on what to use to direct the conversation/dialog tree. I've considered XML, since it's a tree structure and easily update-able, or maybe a TreeMap object.

 

I'm writing this in Groovy so anything within the JVM is an option. Any ideas from fellow experts here?

 

Thank you in advance!

Link to comment
https://linustechtips.com/topic/32566-jvm-dialogconversation-tree/
Share on other sites

Link to post
Share on other sites

A TreeMap is not appropriate since it is implemented over a red-black tree. This is a binary tree, and as such will limit your design to each choice leading to a maximum of 2 paths. On top of that, it is a balanced and ordered tree, which would totally mess up your logic (and you wouldn't have any control over where you put your nodes).

 

Write a simple n-ary tree implementation. This does not require (or rather, must not implement) ordering or balancing, so it's very straightforward.

 

XML could be used to structure your choices, but I'm guessing this information would be stored in a file? You'd really want to load this to memory on a faster data structure. Maybe in chunks if it's too big to hold everything at once.

I guess a tree could be used. Or some XML parser, which probably uses an internal data structure (I haven't written a lot of code in Java so I don't know what you have available for this purpose).

Want to solve problems? Check this out.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×