Randomness and Simple Chat

So I thought I had this figured out, but apparently not. What I want to do is have a section of dialog that is controlled by numbered menus - i.e. what simple chat does. But there’s a twist, I want it to have some randomness in it. I’ll try to explain.

The conversation starts with Bob picking a random node to start at. The player gives a response and then regardless of which node bob started at or what response the player gives we (usually - some responses may have special handling) end up at the same node. The player picks and option, Bob gives a response and then we have to pick another random node for Bob.

I thought I could accomplish this by adding some “run a conversation from the bob’s randomly picked node” and then “run a conversation from the player master node” or something to that effect, and it works. Up to a point. What I didn’t realize is that running another conversation from within a conversation doesn’t automatically end the current one. This leads to recursion, which isn’t a problem at first, but eventually causes Inform to complain about too many rulebooks in use.

So my question is this; is there a way within simple chat to accomplish this. What I guess I need to be able to do is after completing one node, automatically jump to another node. Any ideas?

Okay, I guess maybe my question wasn’t clear. Here’s a simple example that demonstrates the problem:

"The Quiz"

Include Simple Chat by Mark Tilford.

The studio is a room.

The Quiz Master is a person in the studio.

quiz_master, question1, question2, question3, rome, paris, london, node_11, node_12, node_20, june, may and december are chat nodes;

when play begins:
	run a conversation from the quiz_master;

instead of giving text for quiz_master:
	choose a random row from the table of quiz questions;
	run a conversation from the node entry;

Table of quiz questions
node	question-text	response-1	response-2	response-3
question1	"'What's the capital of France?'"	rome	paris	london
question2	"'How many are in a dozen?"	node_11	node_12	node_20
question3	"'What is the fifth month of the year?'"	june	may	december

Table of quiz responses
node	link-text	response-text
rome	"Rome"	"You say 'Is it Rome?'"
paris	"Paris"	"You say 'Is it Paris?'"
london	"London"	"You say 'Is it London?'"	
node_11	"11"	"You say 'Is it 11?'"
node_12	"12"	"You say 'Is it 12?'"
node_20	"20"	"You say 'Is it 20?'"
june	"June"	"You say 'Is it June?'"
may	"May"	"You say 'Is it May?'"
december	"December"	"You say 'Is it December?'"

Report giving text for a node listed in the table of quiz questions:
	say "[question-text entry]" instead;

Carry out finding responses to a node listed in the table of quiz questions:
	if there is a response-1 entry:
		link to response-1 entry;
	if there is a response-2 entry:
		link to response-2 entry;
	if there is a response-3 entry:
		link to response-3 entry;

Report giving link to a node listed in the table of quiz responses:
	say "[link-text entry]" instead;

Report giving text for a node listed in the table of quiz responses:
	say "[response-text entry]";
	run a conversation from quiz_master instead;

Run this (and yes it will repeat questions) and keep answering questions. Around the 9 or 10th question inform will crap out. It doesn’t like using “run a conversation from x” as a way to skip around nodes. Anybody got any better ideas? And I certainly don’t excluding dumping simple chat altogether if there’s a better way. My requirements are to be able to pick a random question and then present answers in a numbered menu (because asking / telling obviously ain’t gonna cut it) and keep cycling until I decide to stop.

Inform’s limits on the number of rulebooks that can run simultaneously makes your approach impossible; the simplest solution would be to let each conversation end and immediately start a new one. What about something like:

[code]Running-quiz is a truth state that varies. Running-quiz is true.

Every turn:
while running-quiz is true:
choose a random row from the table of quiz questions;
run a conversation from the node entry.[/code]
Untested code, but I guess the principle should work.

Hmmm…that’s a thought - I’ll have to give it a try.

Okay, that actually works great. Thanks.

Here’s an idea of what I eventually settled on (leaving out the special handling of whether the answers to questions are right or wrong):

"The Quiz"

Include Simple Chat by Mark Tilford.

The studio is a room.

The Quiz Master is a person in the studio.

quiz_master, question1, question2, question3, myq1, myq2, myq3, rome, paris, london, node_11, node_12, node_20, june, may and december are chat nodes;
	
Running-quiz is a truth state that varies. Running-quiz is true.

To decide which chat node is the next question:
	choose a random row from the table of quiz questions;
	decide on the node entry.

Next-node is a chat node that varies.

when play begins:
	now the next-node is the next question;

Every turn:
	while next-node is not no quip chosen:
		run a conversation from the next-node;

Table of quiz questions
node	question-text	response-1	response-2	response-3
question1	"'What's the capital of France?'"	rome	paris	london
question2	"'How many are in a dozen?"	node_11	node_12	node_20
question3	"'What is the fifth month of the year?'"	june	may	december

Table of quiz responses
node	link-text	response-text
rome	"Rome"	"You say 'Is it Rome?'"
paris	"Paris"	"You say 'Is it Paris?'"
london	"London"	"You say 'Is it London?'"	
node_11	"11"	"You say 'Is it 11?'"
node_12	"12"	"You say 'Is it 12?'"
node_20	"20"	"You say 'Is it 20?'"
june	"June"	"You say 'Is it June?'"
may	"May"	"You say 'Is it May?'"
december	"December"	"You say 'Is it December?'"

Table of my-quiz questions
node	question-text	response-text
myq1	"'What is the square root of 81?'"	"'Ha! Easy...9!'"
myq2	"'Who was know as the Red Baron?'"	"'Baron von Richthofen. Give me a difficult one!'"
myq3	"'What is the meaning of life, the universe and everything?'"	"'43!' The quiz master says confidently.[paragraph break]'No! 42! You lose!' You laugh."

Report giving text for a node listed in the table of quiz questions:
	say "[question-text entry]" instead;

Carry out finding responses to a node listed in the table of quiz questions:
	if there is a response-1 entry:
		link to response-1 entry;
	if there is a response-2 entry:
		link to response-2 entry;
	if there is a response-3 entry:
		link to response-3 entry;

Report giving link to a node listed in the table of quiz responses:
	say "[link-text entry]" instead;

Report giving text for a node listed in the table of quiz responses:
	say "[response-text entry]";
	now the next-node is quiz_master instead;

Report giving link to a node listed in the table of my-quiz questions:
	say "[question-text entry]" instead;
	
Report giving text for quiz_master:
	say "[paragraph break]'Ok, now you ask me one.' The quiz master says with glee.'" instead;
	
Carry out finding responses to quiz_master:
	repeat through table of my-quiz questions:
		link to node entry;
	
Report giving text for a node listed in the table of my-quiz questions:
	say "[response-text entry][paragraph break]";
	now the next-node is the next question instead;

Ignoring my stupid questions for a moment, this could actually form the basis of an interesting puzzle where you have to figure out what the quiz master doesn’t know about in catch him out.