Crazy bug in randomtest that doesn't say anything; it just stops


Okay, so I’m like completely done with my second gamebook, Captive of Fortune - Volume Two of Demons Among Men. I was running the tests to get all the bugs fixed before I sent it in to CoG, but for some reason, when I run randomtest, it just stops completely. It doesn’t say anything; the tests just won’t continue. The game passes randomtest and I have the latest version of CS, so I’m not sure what the issue is. I sent it in to CoG to see if they could figure out what the problem is, but Jason is too busy at the moment so I thought I’d see if any of you guys could help me out.

When I tried testing the game manually, it always stops at the same place; when I select any of the choices about what to tell Mayor Eldon after he asks if you think you can defeat the demon, it just freezes and won’t do anything. Here is the code and the code around it. I can’t find anything that looks like it would be causing the problem so I’m totally lost about how to fix this. Here’s the code.

#You say firmly, "We must mobilize the entire guard, barricade the city, and maintain a constant lookout for the demon!"
		*set resolve %+3
		*set charisma %+3
		*set stealth %-5 
		*set guards true
		*achieve guards 
		"I don't want to see the tragedy of my own home town repeated, and I am convinced it won't be. I prepared this time, and the city is forewarned. We must station archers on the perimeter, post guards in the streets, and monitor every exit. We should also have buckets of water in case he resorts to fire again. I should take one of the guards' rune-wards, as well.

		"If the demon is found, instruct the guards to mount a full ranged attack. Under no circumstances should they approach him directly! Their duty is only to stall him until I arrive; after that, their primary objective should be to protect the civilians."
		Nodding quickly, Eldon comments, "Oh absolutely."

		You incline your head towards him, continuing, "I would also advise a before-dark curfew for the residents, and everyone should travel in large groups. Above all, make sure you yourself are well guarded; I fear your position may make you a target."

		Nodding spiritedly, Eldon replies, "I couldn't agree more! I want to show this demon that my city will not be terrorized by such scum." He stands, putting his hands on his desk for emphasis. "I will alert everyone immediately."

		Motioning for you to follow, Eldon quickly maneuvers through the building, throwing a set of silvery formal robes over his grey tunic as he goes. You follow closely, retrieving your belongings as you pass, and you both head back into the city. The mayor seems to be heading back towards the market district, and you recall the empty platform with an ornate podium you had passed at the market's head, on your way to the river.

		A few minutes later, you reach the covered platform. Eldon steps up, reaching for a golden cord; the bell above clangs loudly, echoing through the city, and civilians begin trailing into the square. They crowd around you and hang out of nearby windows, and soon the space is completely packed. While the crowd gathers, Mayor Eldon leans over and plucks at your sleeve, drawing you onto the platform. Once you are standing beside him, he raises his voice and addresses the massive crowd.

		"I, Mayor Eldon Guthery Bergington Wallace Wetherings the third, Guardian of the Peace, Baronet of Lumios, vassal to Lord Bergington, Hereditary First Seat of the Great Conference of Baronies, and Mayor of Lorden, have a very important announcement."

		*if (((charisma >= stealth) and (charisma >= cunning)) and ((charisma >= resolve)))
			*goto accustomed
		*if (((stealth > charisma) and (stealth > cunning)) and ((stealth > resolve)))
			You find yourself rolling your eyes; thankfully, no one notices.
		*if (((cunning > stealth) and (cunning > resolve)) and ((cunning > charisma)))
			*label accustomed 
			You find yourself wishing you could roll your eyes.
		*if (((resolve > stealth) and (resolve > cunning)) and ((resolve > charisma)))
			You find yourself rolling your eyes.
		Apparently, though, the citizens are accustomed to this; you even see a few of them giggling.

		"Citizens of Lorden," he continues, "I have called you here today to warn you that we are in grave danger! This courageous ${hunter} has overcome several bandits and a necromancer, and ${dhe} journeyed to Lorden after learning of a demon's plot to destroy our wonderful city."

		The mayor raises his hand and calms the crowd with impressive aplomb. "Do not fear, Lorden! With the combined efforts of our guards and ${name} the Demon $!{hunter}'s expertise, we will protect our beloved home from this evil and drive this demon back into the depths of the Netherworld!"

		Several members of the crowd cheer, though others still look terrified, and Eldon continues his speech in this vein. Soon, even the most timid are cheering as he instills them with courage and confidence. After they seem calmer, he elaborates on your plans for defense.

		"On ${name}'s advice, we have decided to barricade the city and keep a watch for the demon. We are beginning a before-dark curfew immediately; you may continue to go about your daily lives, but remember to stay in groups at all times and be home before dark. I also urge you all to ready buckets of water around your homes and shops. ${name}'s village was ravaged by fires started by the demon, so I want us to be prepared for the worst.

		"Above all, remain calm!" the mayor concludes emphatically. "Trust in our ability to fight this demon; he would love nothing more than for us to tears ourselves apart from the inside out, but Lorden will remain united!"

		The citizens look at each other, nodding and commenting in quiet voices as Eldon pauses for a moment. There is a solemn, determined air about the square. Raising his hand, the mayor dismisses the crowd. "Thank you for your attention, everyone, and rest assured that the situation is under control. You may go about your business."

		As the crowd disperses, the mayor turns to you, saying, "${name}, before we carry on with the preparations, I have to ask you something. Do you really believe we can defeat this demon?"
		*label question

		His inquiry came out of nowhere, and he looks surprisingly earnest.
			#You truly believe you can defeat the demon.
				*set charisma %+3 
				*set compassionate %+3 
				*goto can

			#You tell him the grim truth. "I don't believe it is possible to defeat this monster, not as we are now."
				*set resolve %+3 
				*set charisma %-5 
				"I won't lie; 
				*label honest
				*if (((stealth > charisma) and (stealth > cunning)) and ((stealth > resolve)))
					this demon is a master of death and deceit. I have never seen anything like this before. I have been forced to battle enemy after enemy, all of whom were recruited by the demon himself. Worst of all, I haven't caught a glimpse of him even once! He has always been a step ahead of me. I would like to think I could defeat him before he has the chance to kill me, but I fear the opposite."
					His face stony, he whispers more to himself than you, "Then all is lost..."
				*if (((cunning > stealth) and (cunning > resolve)) and ((cunning > charisma)))
					*goto charisma 
				*if (((resolve > stealth) and (resolve > cunning)) and ((resolve > charisma)))
					the is stronger than anyone I've ever faced, yes. Still, I have overcome so much during my journeys, and I am now stronger for it. 
					"I have been known to surprise myself, and I promise that even if I die in the process, I will do everything in my power to triumph. No matter what, I vow to make this devil regret ever coming here. But there just isn't enough for us to gather enough strength to defeat such terrible strength."
					His face stony, he whispers more to himself than you, "Then all is lost..."
					"Perhaps," you admit grimly.
				*if (((charisma >= stealth) and (charisma >= cunning)) and ((charisma >= resolve)))
					*label charisma 
					plainly, there isn't much of a chance of me defeating such a powerful, clever demon. Such gargantuan strength needs an equal force, or combined force, in opposition. Nevertheless, I feel it is my duty attempt vengeance, for my village's sake. 
					"I won't pretend, and disappoint you; however, I do reassure you that I will try my hardest to banish this devil, despite the odds against us all."

					His face stony, he whispers more to himself than you, "Then all is lost..."

					*if compassionate > 49 
						"Nothing is ever hopeless," you reply firmly.
					*if compassionate < 50   
						"The world is a cold, hard place," you say, shrugging.

				Looking away,
				*goto think

			#You say firmly, "There is no doubt that this will be a brutal, difficult battle, but I believe we can gain an edge through our wits, through sneak attacks and clever tactics."
				*set resolve %+3
				Choosing your words carefully, you continue, "I realize this demon is incredibly powerful, and normally well beyond a single ${hunter}'s strength, but we have more than that to pit against him. 
				*if guards
					*set cunning %+3
					With your brave citizens, the guards on alert, and my own skills, we can surprise the demon and defeat him here in Lorden. I promise, I will be analyzing his weaknesses and we will use them any way that we can." 
				*if not(guards)
					*set stealth %+3
					I think with your help - with Lorden's help - we can take the demon by surprise. I promise I will  coming up with a few surprises of my own."

				A smile spreading across his face, he replies, "I admire that in you, $!{hunter}; you aren't afraid to admit when the opposition is seems insurmountable, but at the same time you are determined to prevail. Well, good day to you! Please, send word if you need anything further; and know that I'm thankful for everything you are doing for Lorden."
				*if compassionate < 50 
					You nod, your eyes suddenly going dark. [i]I don't care about this city; I just want to finish what I started,[/i] you think to yourself. Sighing,
					*goto think
				*if (((charisma >= stealth) and (charisma >= cunning)) and ((charisma >= resolve)))
					"It's my pleasure, Mayor Eldon," you say as you
				*if (((stealth > charisma) and (stealth > cunning)) and ((stealth > resolve)))
					You nod briefly and
				*if (((cunning > stealth) and (cunning > resolve)) and ((cunning > charisma)))
					"Of course, Mayor," you reply as you
				*if (((resolve > stealth) and (resolve > cunning)) and ((resolve > charisma)))
					"Of course," you respond, and with that, you
				*goto think

			#You really don't think it's possible to defeat this demon, but you can hardly tell that to the mayor.
				*set lie true
				*if charisma > 69
					*set charisma %+3
				*set resolve %-5 
				*set cunning  %+3  
				*goto can

*label can
Your voice full of 
*if lie
	cleverly feigned 
confidence, you respond, "Mayor Eldon, I have just recently bested an incredible amount of adversaries. It will be a difficult battle, but I believe I can defeat and banish the demon. STE/RES It is the only option."

"The demon may be powerful, but I've grown in strength and knowledge during my journey. I haven't come all this way just to lose to a depraved monster."

A smile spreading across his face, Eldon says, "I think I can expect great things from you, ${name}!"

Nodding confidently, 
*label think
*if guards
	you descend the steps as Eldon turns to one side, addressing several guards. As you meander down the steps, your mind turns to the next several hours. You will need to spend that time resting and eating to regain strength for the battle ahead. By now, the sun is descending and the citizens are taking their mayor's advice, heading to their homes in groups.
	*goto prepare


I’m looking through the code now. It shouldn’t make a difference, but you have unnecessary brackets in your if statements:

*if (((charisma >= stealth) and (charisma >= cunning)) and ((charisma >= resolve)))

Can be shortened to:

*if (((charisma >= stealth) and (charisma >= cunning)) and (charisma >= resolve))

The same is true of many (all?) of these ifs in this passage: the last clause has a set of brackets too many.

I’m still reading so will let you know if I see anything else.


Looking further you.have the code:

*if guards


*if not(guards)

It could be syntax I’m unaware of but shouldn’t it be:

*if (guards)


*if (guards=false)

Everything else looks okay, assuming the spacing is correct (on my phone, so hard to tell).


Oh okay! “not(variable)” is a common code and it works every other time I use it. And the excessive brackets work, too, but I’m glad you pointed out that I don’t have to use so many. I’m not able to get to my code right now but I can try changing those things on Monday to see if it’ll work then.


Well, I’ve learnt a new command there then!
However, can you also just use *if variable without brackets to check for true?

I’m at a PC now, so will have another quick scan through…

Edit: I pasted the code into a fresh choicescript, added the variables and removed the guards achievement (I didn’t want to spend time making it!). It works. It passes randomtest and quicktest.

Although: Your very first sentence starts with #. I’m guessing this is a choice that causes the crash? What are the other options for that choice - could there be a continuity error before or after this choice?


Also, just an aside, a couple of errors:

In the first paragraph you end up with some funny speech marks:

You say firmly, “We must mobilize the entire guard, barricade the city, and maintain a constant lookout for the demon!” "I don’t want to see the tragedy of my own home town repeated, and I am convinced it won’t be. I prepared this time, and the city is forewarned. We must station archers on the perimeter, post guards in the streets, and monitor every exit. We should also have buckets of water in case he resorts to fire again. I should take one of the guards’ rune-wards, as well.

You have double speech marks in the second line and no closing speech marks at the end.

You are missing a word after the second choice. You have:
"I won’t lie; the is stronger than anyone I’ve ever faced.

You’re missing the word demon.

Also, the third choice:

you aren’t afraid to admit when the opposition is seems insurmountable

Delete ‘is’.

Finally, for the fourth choice, you have the funny phrase STE/RES half-way through. I’m guessing a note to yourself that needs deleting.


Yeah, you can!

And choosing to be secretive about the demon also leads you to the choices where you tell Mayor Eldon about whether or not you think you can defeat the demon, so it’s like that entire set of choices is what’s causing the crash. I’ll try to see if it’s really the “barricade the city” choice on Monday, though; sadly, I can’t get to my work until then.

And thanks for finding those typos. :slight_smile:


Sam I’ve just had a weird error pop up in my randomtest. Here is what i did to fix it.

Find out the last Seed where the error occurs (you can do this by pressing ctrl + f and searching for ***seed then when at the top click to search up to get to the last seed tested.

rerun randomtest doing only 1 instance and the seed that throws up the error (this time make you click the show full text option)

Scroll down to the bottom (when i did this i found out randomtest stopped because it hit a loop and constantly repeated itself so there was no actual “error” as far as randomtest was concerned so it didn’t report an error.)

I hope this helps you too.


Oh! Yeah that’s definitely a possibility. I’ll look into it on Monday. Thanks for the advice!


Hey guys,

I’m currently developing a choice of game and have run into a similar issue with the random test. It’s been running fine up until recently. But now when I try to run it it just reaches the end of the first seed and stops, there is no error message or anything telling me why it’s stopping. I tried undoing the work I’d done since I last tested the game and the result is still the same so I have no idea why it’s started doing that.

Weirdly the game it’s is running absolutely fine when I try and play through.

Does anyone have any further suggestions on what this problem might be?

As per @Nocturnal_Stillness suggestion I checked for an loop but found none.

Edit: I have no idea what I did. I just carried on doing my little thing writing and coding, with the intention to not let the day go to waste. The randomtest is now working. Apparently if you bang your head on something enough good things will happen. I’m not sure what broke it or what fixed it again, sorry for the bother.


Hehehe xD

Well, everyone, I’m gonna try to fix this problem later today. If all goes well, I’ll submit CoF tonight.


I fixed it! There was just a check that was too high so it was pretty much unreachable, and it was holding up the whole game for some reason.


Congrats! Does this mean we’ll be seeing CoF soon?


I’ll be submitting it within the next few hours, so hopefully it’ll be published sometime in the Spring. :slight_smile:


Congratulations on finishing it :slight_smile: