Annoying duplication bug

So there’s a weird bug in TDUP where a critical one-off scene happens twice instead of once.

The code for that segment looks like this:

*label arcy_downtime

*if (downtime_count = 2)
  *set downtime_count +1
  *goto get_over_fear

*if (downtime_count = 4)
  *gosub_scene downtime age_increase
  *set downtime_count +1
  *goto brutal_sacrifice

*if (downtime_count >= 6)
  *gosub_scene downtime age_increase
  *goto decision

Ignore my terrible naming conventions by the way. I called two separate things downtime because I’m an idiot with no experience and bad foresight.

So let me just add some code to test for the bug …

*temp brutal_sacrifice false

...

*label brutal_sacrifice
*if (brutal_sacrifice = true)
  *bug The sacrifice has happened twice.
*set brutal_sacrifice true

...

And let’s run randomtest. I haven’t been able to get it to work recently because of how easy it is for random choices to get stuck in endless loops in this game. I’ve included some workarounds over the past few days as I’ve been refining my ability to actually test the damn game. Let’s do this. Let’s find this bug.

It Only Took 28 Seeds

*****Seed 28
startup *choice 298#2 (line 302) #Choose your character (skip introduction).
startup *choice 305#1 (line 306) #The Arch-Druid.
startup *choice 374#1 (line 375) #Yes.
startup *choice 386#2 (line 389) #No, keep sexual content disabled.
startup *choice 397#1 (line 398) #Male.
startup *choice 407#1 (line 408) #Male.
downtime *choice 7#1 (line 8) #Work on myself.
skills *rand increase 35
skills *rand bonus 292
skills *choice 15#2 (line 19) #I’ve been wanting to explore the known world.
omens *rand location 4
omens *rand reaction 5
skills *choice 133#2 (line 137) #I seek the assistance of sailors and pirates and learn their ways.
skills *choice 150#2 (line 153) #The Coral Snake
skills *choice 179#1 (line 180) #Yes.
downtime *choice 7#3 (line 12) #View the map of Circadia.
downtime *choice 7#3 (line 12) #View the map of Circadia.
downtime *choice 7#3 (line 12) #View the map of Circadia.
downtime *choice 7#3 (line 12) #View the map of Circadia.
downtime *choice 7#3 (line 12) #View the map of Circadia.
downtime *choice 7#2 (line 10) #Seek out rumours of immortal beings.
rumours *rand randomtest_romance 1
clooth *rand increase 13
clooth *choice 28#3 (line 31) #Who gives someone a dead fish as a gift?
clooth *choice 37#2 (line 40) #Kick down the door.
clooth *choice 71#3 (line 80) #“You must be C’looth-Thili.”
clooth *choice 105#2 (line 109) #“How many of you are there?”
clooth *choice 105#2 (line 112) #“What exactly do you do?”
clooth *choice 105#1 (line 106) #“What’s a coven?”
clooth *choice 143#3 (line 156) #“Why a dead fish?”
clooth *choice 143#2 (line 147) #“Why did you try to contact me using such a strange language?”
clooth *choice 182#1 (line 183) #“I’ve sailed on plenty of ships. I know what I’m doing.”
clooth *choice 201#3 (line 206) #“Isn’t this a bit dangerous?”
clooth *choice 222#3 (line 227) #Say nothing. Focus on setting it up.
clooth *choice 235#3 (line 240) #“And then blast it out of the water with magic?”
clooth *choice 253#1 (line 254) #“How long does it usually take before they tire out?”
clooth *choice 256#1 (line 257) #“I don’t think I can keep this up. Let me try something else.”
clooth *choice 282#2 (line 363) #“On second thought, I think I can do it your way.”
clooth *choice 407#1 (line 408) #… among a posse of fishermen knocking back their fifth tanker of ale each.
clooth *choice 432#1 (line 433) #“You seem to know the townsfolk pretty well.”
clooth *choice 464#2 (line 467) #“No, I’m sorry. I just don’t think this will work.”
clooth *rand increase 32
omens *rand location 6
omens *rand reaction 1
downtime *choice 7#1 (line 8) #Work on myself.
skills *rand increase 25
skills *rand bonus 29
skills *choice 15#5 (line 30) #I’d like to better understand the mortal body by practicing medicine.
omens *rand location 5
omens *rand reaction 5
skills *choice 414#1 (line 415) #I study the traditional way, with textbooks and plenty of practice.
downtime *choice 7#2 (line 10) #Seek out rumours of immortal beings.
rumours *rand randomtest_romance 1
rumours *rand randomtest_romance 1
rumours *rand randomtest_romance 1
rumours *rand randomtest_romance 0
arcy *rand approxplusminus 1
arcy *rand approxrandom 34
arcy *choice 53#3 (line 64) #Attempt to reason with it.
arcy *choice 134#1 (line 137) #“I consider myself a guardian of the natural world.”
arcy *choice 153#3 (line 158) #“Kind of gives me the creeps.”
arcy *choice 165#3 (line 170) #“I’m just curious how you became a lich.”
arcy *choice 176#2 (line 179) #“Public speaking.”
arcy *choice 198#2 (line 202) #“Go ahead.”
arcy *choice 244#2 (line 246) #“That’s it, just yes or no?”
arcy *choice 250#2 (line 254) #“I’d rather live a short life with someone I love than live forever on my own.”
arcy *choice 269#2 (line 299) #“Why did you come here without your zombies?”
arcy *choice 269#3 (line 315) #“What else do you know about me?”
arcy *choice 318#2 (line 320) #“You’re a bit off.”
arcy *choice 322#1 (line 323) #“Yes, it weirds me out.”
arcy *choice 269#1 (line 270) #“Do you kill people?”
arcy *choice 277#2 (line 296) #“No.”
arcy *choice 269#1 (line 303) #“Have you always been alone?”
arcy *choice 269#1 (line 330) #“Shall we head back?”
arcy *choice 335#3 (line 340) #“It’s still a bit spooky.”
arcy *choice 344#1 (line 345) #“What do you mean by that?”
arcy *choice 352#1 (line 353) #I transform into a tiny tarantula hawk wasp to confuse and paralyze them.
arcy *choice 405#3 (line 416) #“Next time, give me more.”
arcy *choice 555#1 (line 556) #“I can’t accept this. I’ll find an inn back in town.”
arcy *choice 575#1 (line 576) #Fling the door open.
arcy *choice 600#2 (line 603) #“How do I know it’s not poisoned if you won’t eat?”
arcy *choice 615#1 (line 616) #“I’ve never felt so full and well-rested.”
arcy *choice 628#1 (line 629) #“That’s very kind of you.”
arcy *choice 649#2 (line 677) #“Even if it’s only for a short while, it’s worth it.”
arcy *rand increase 24
arcy *choice 735#5 (line 752) #I carve through her disposable armies to strengthen my magical powers.
omens *rand location 1
omens *rand reaction 5
arcy *rand increase 7
arcy *choice 735#3 (line 744) #I dig deep into the history of the Tower of Rackenwort.
omens *rand location 5
omens *rand reaction 2
omens *choice 1103#1 (line 1104) #“I had a terrible dream.”
omens *choice 1106#1 (line 1107) #“Yeah.”
omens *choice 1112#3 (line 1141) #“Not yet.”
arcy *choice 2360#1 (line 2361) #I’m doing it out of rebellion to my overbearing father.
arcy *choice 2377#2 (line 2380) #Run away.
arcy *choice 2385#3 (line 2390) #“Nothing but pure curiosity.”
arcy *choice 2422#1 (line 2423) #“Do you ever wish you could see your family again?”
arcy *choice 2422#2 (line 2433) #“What do you think happens when we die?”
arcy *choice 2422#1 (line 2428) #“Does your ritual magic keep you alive?”
arcy *choice 2463#2 (line 2465) #I don’t care what the old man thinks. Maybe he’s not even my father.
arcy *choice 2494#2 (line 2497) #Regibald.
arcy *choice 2511#3 (line 2514) #“Shut up and follow close behind.”
arcy *choice 2538#3 (line 2554) #“Is there no life after death?”
arcy *choice 2538#2 (line 2543) #“Is it possible to resurrect someone completely?”
arcy *choice 2538#1 (line 2539) #“Is there still a soul in the zombie?”
arcy *choice 2590#3 (line 2602) #It will be a home for Harriet and I as we grow old.
arcy *choice 2640#2 (line 2642) #I can’t live without her. Even seeing her like this is worth it.
arcy *choice 2654#2 (line 2657) #I search for revenants, zombies that have retained the intelligence of their former selves.
arcy *choice 2681#2 (line 2683) #Three orphans from a broken home.
arcy *choice 2689#3 (line 2694) #In an unremarkable hole in the courtyard.
arcy *choice 2718#2 (line 2721) #I spare her the pain of seeing what I’ve become.
arcy *choice 2738#3 (line 2743) #“Are you really wearing Harriet’s skeleton?”
arcy *rand increase 14
arcy *choice 2916#1 (line 2917) #“What are you doing?”
arcy *choice 2927#2 (line 2935) #Do nothing.
arcy *choice 2949#1 (line 2950) #Stay with her.
arcy *rand increase 7
arcy *choice 735#1 (line 736) #I help Arcy with her alchemy hobby.
omens *rand location 1
omens *rand reaction 3
arcy *choice 769#2 (line 776) #Take some time to wave away the smoke.
arcy *choice 786#1 (line 787) #“It was my fault, not yours.”
arcy *choice 817#1 (line 818) #“Wow. You’re beautiful.”
arcy *choice 832#1 (line 833) #“Remind me of the purpose of this potion we’re brewing.”
arcy *choice 873#1 (line 874) #“I’m astounded by the realism.”
arcy *choice 1126#2 (line 1135) #I recall some back routes I noticed earlier and pull us through a detour.
arcy *choice 1166#2 (line 1169) #“Squid skin and oyster shells.”
arcy *choice 1185#2 (line 1200) #Extend your senses through the Weave to locate what you’re looking for.
arcy *choice 1242#1 (line 1243) #Calm the guard down with a subtle spell.
arcy *choice 1306#1 (line 1307) #Drink the potion.
goals *choice 94#2 (line 97) #Yes.
goals *choice 113#7 (line 126) #Honeycomb-coloured, and also honeycomb-shaped.
goals *choice 135#3 (line 140) #Bleached white.
arcy *choice 1364#2 (line 1368) #I wink and say, “You still don’t have any clothes on.”
arcy *rand increase 39
omens *rand location 2
omens *rand reaction 2
RANDOMTEST FAILED: Error: arcy line 2905: Bug: The sacrifice has happened twice.

First thing’s first, I was still defeated by my lack of thoroughness and it got stuck on the map screen for a while. Lemme just fix that.

*selectable_if ((exploring = true) and (choice_randomtest = false))

Done.

Next: what the hell causes the bug? Randomtest actually didn’t give me any insights into that. I thought that including a *bug command would fix all my problems magically??? Disappointment abounds.

I can’t really find a reason it would screw up like this.

Maybe the subroutine screws up the downtime_count variable increasing? Let me try swapping those around to …

*gosub_scene downtime age_increase
*set downtime_count +1

Let’s run randomtest again …

Nope. This time only Seed 17. Forgot to copy it. It’s pretty much identical to the last one anyway.

Maybe there’s another way that it’s getting to *label brutal_sacrifice? Nope, only 1 hit in the search bar. Clean entry and exit.

The part where she covers you in spiders also triggers in a pretty similar way so let’s add another bug there.

Literally Seed 2

*****Seed 2
startup *choice 298#2 (line 302) #Choose your character (skip introduction).
startup *choice 305#2 (line 323) #The Champion.
startup *choice 374#1 (line 375) #Yes.
startup *choice 386#2 (line 389) #No, keep sexual content disabled.
startup *choice 397#1 (line 398) #Male.
startup *choice 407#1 (line 408) #Male.
downtime *choice 7#2 (line 10) #Seek out rumours of immortal beings.
rumours *rand randomtest_romance 1
clooth *rand increase 31
clooth *choice 28#1 (line 29) #That was kind of weird.
clooth *choice 37#2 (line 40) #Kick down the door.
clooth *choice 71#1 (line 72) #“Yes, that’s me.”
clooth *choice 105#2 (line 109) #“How many of you are there?”
clooth *choice 105#1 (line 106) #“What’s a coven?”
clooth *choice 105#1 (line 112) #“What exactly do you do?”
clooth *choice 143#1 (line 144) #“Who was that girl you sent to talk to me?”
clooth *choice 143#2 (line 156) #“Why a dead fish?”
clooth *choice 182#1 (line 185) #“I’ve never fished before.”
clooth *choice 201#2 (line 204) #“What’s that shark doing with its tail?”
clooth *choice 222#2 (line 225) #“I can handle it.”
clooth *choice 235#1 (line 236) #“And then reel it onto the ship?”
clooth *choice 253#2 (line 261) #“Are you sure we can’t get this thing on the ship some other way?”
clooth *choice 282#2 (line 363) #“On second thought, I think I can do it your way.”
clooth *choice 407#2 (line 412) #… next to a group of older housewives gossiping and tittering.
clooth *choice 432#3 (line 443) #“Aren’t you going to eat?”
clooth *choice 464#3 (line 469) #Kill him when he least expects it. Dismantle the cult. Nothing good can come from this.
clooth *choice 3403#2 (line 3406) #Destroy the town. Kill everyone. No trace of the cult should remain.
clooth *rand increase 20
omens *rand location 1
omens *rand reaction 4
downtime *choice 7#1 (line 8) #Work on myself.
skills *rand increase 32
skills *rand bonus 230
skills *choice 15#1 (line 16) #I’d like to become a world-renowned writer.
omens *rand location 3
omens *rand reaction 6
skills *choice 49#3 (line 56) #A scholar.
skills *choice 68#3 (line 79) #I join dozens of writing groups in dozens of different cities.
skills *choice 93#5 (line 102) #The Burning Wings of Bolia
skills *choice 120#1 (line 121) #Yes.
downtime *choice 7#1 (line 8) #Work on myself.
skills *rand increase 35
skills *rand bonus 182
skills *choice 15#5 (line 30) #I’d like to better understand the mortal body by practicing medicine.
omens *rand location 6
omens *rand reaction 4
skills *choice 414#2 (line 417) #I make friends with doctors, nurses, surgeons, and medicine men and learn primarily through observation.
downtime *choice 7#2 (line 10) #Seek out rumours of immortal beings.
rumours *rand randomtest_romance 0
arcy *rand approxplusminus 0
arcy *rand approxrandom 34
arcy *choice 53#3 (line 62) #Wrestle it to the ground.
arcy *choice 134#1 (line 141) #“No, I wouldn’t consider myself a mage first and foremost.”
arcy *choice 153#3 (line 158) #“Kind of gives me the creeps.”
arcy *choice 165#3 (line 170) #“I’m just curious how you became a lich.”
arcy *choice 176#1 (line 177) #“Spiders.”
arcy *choice 198#1 (line 199) #“Maybe keep it light.”
arcy *choice 207#3 (line 210) #“Well then. Give me a second to think.”
arcy *choice 215#4 (line 222) #“I would immediately devolve into hedonism.”
arcy *choice 231#2 (line 235) #“Can I ask you something?”
arcy *choice 269#3 (line 303) #“Have you always been alone?”
arcy *choice 269#3 (line 315) #“What else do you know about me?”
arcy *choice 318#1 (line 319) #“That’s about right.”
arcy *choice 322#3 (line 327) #“Not at all.”
arcy *choice 269#2 (line 299) #“Why did you come here without your zombies?”
arcy *choice 269#1 (line 270) #“Do you kill people?”
arcy *choice 277#1 (line 278) #“Yes.”
arcy *choice 280#3 (line 293) #“It doesn’t bother me … that much.”
arcy *choice 269#1 (line 330) #“Shall we head back?”
arcy *choice 335#2 (line 338) #“Depends on what happens afterwards.”
arcy *choice 344#2 (line 346) #“Uh oh.”
arcy *choice 352#2 (line 381) #I roll my eyes. “That’s all? It’s hardly worth the effort.”
arcy *choice 383#1 (line 384) #“Put them back in their graves.”
arcy *choice 405#3 (line 416) #“Next time, give me more.”
arcy *choice 555#3 (line 560) #“Aren’t you going to stay?”
arcy *choice 575#2 (line 581) #Listen first.
arcy *choice 600#2 (line 603) #“How do I know it’s not poisoned if you won’t eat?”
arcy *choice 615#3 (line 622) #“They’re alright.”
arcy *choice 628#1 (line 629) #“That’s very kind of you.”
arcy *choice 649#3 (line 685) #I just hug her.
arcy *rand increase 30
arcy *choice 735#2 (line 740) #I help Arcy refine her spellcasting abilities.
omens *rand location 3
omens *rand reaction 5
arcy *choice 1521#1 (line 1522) #“Let them come. They don’t stand a chance.”
arcy *choice 1706#1 (line 1707) #Summoning circles that surround the adventurers with zombies when tripped.
arcy *choice 1716#1 (line 1717) #Poisoned food that charms them into eating it.
arcy *choice 1726#2 (line 1729) #Pots and pans catapulting sizzling oil.
arcy *choice 1736#1 (line 1737) #Depressed blocks that send them flying into an iron maiden to be perforated with needles.
arcy *choice 1966#1 (line 1967) #Distract the priest.
arcy *choice 2047#2 (line 2062) #Weaken the orc with a spell that atrophies his muscles.
arcy *choice 2138#1 (line 2139) #Use the environment around you to kill them.
arcy *rand increase 22
arcy *choice 735#2 (line 744) #I dig deep into the history of the Tower of Rackenwort.
omens *rand location 5
omens *rand reaction 3
omens *choice 1103#2 (line 1182) #“It’s nothing.”
arcy *choice 2360#3 (line 2363) #I’m doing it out of desperation. I’ll never find anyone to love with a face like mine.
arcy *choice 2377#2 (line 2380) #Run away.
arcy *choice 2385#2 (line 2388) #“I was hoping you’d have a remedy.”
arcy *choice 2422#3 (line 2433) #“What do you think happens when we die?”
arcy *choice 2422#2 (line 2428) #“Does your ritual magic keep you alive?”
arcy *choice 2422#1 (line 2423) #“Do you ever wish you could see your family again?”
arcy *choice 2463#3 (line 2466) #This whole charade is worth giving up. It’s time that the family quietly died out.
arcy *choice 2494#2 (line 2497) #Regibald.
arcy *choice 2511#2 (line 2513) #“I just needed the right person to bring it out.”
arcy *choice 2538#1 (line 2539) #“Is there still a soul in the zombie?”
arcy *choice 2538#1 (line 2543) #“Is it possible to resurrect someone completely?”
arcy *choice 2538#1 (line 2554) #“Is there no life after death?”
arcy *choice 2590#3 (line 2602) #It will be a home for Harriet and I as we grow old.
arcy *choice 2640#1 (line 2641) #I don’t care. Any time alive is better than no time at all.
arcy *choice 2654#1 (line 2655) #I search for liches, wizards that have preserved their souls past death.
arcy *choice 2681#1 (line 2682) #Three homeless people taken from a major city.
arcy *choice 2689#1 (line 2690) #In my father’s grave.
arcy *choice 2718#2 (line 2721) #I spare her the pain of seeing what I’ve become.
arcy *choice 2738#2 (line 2741) #“I think I saw your memories.”
arcy *rand increase 22
RANDOMTEST FAILED: Error: arcy line 2808: Non-existent variable ‘get_over_fear’

So clearly it’s the way i’ve coded that particular segment. I’m not sure what I’m doing wrong, though. When it comes back to that hub point, and the downtime_count is at a certain number, the very first thing it does is increase that number by 1. Therefore it should never trigger again because 2+1 is never 2. So what’s wrong?

EDIT: Well I dumbly didn’t actually create that last variable so I’ll start there tomorrow morning if I haven’t figured it out by then.

The Next Morning

Woke up, fixed the little error I made, removed the bug report from brutal_sacrifice, and …

We’re on 2,500 seeds through the randomtest and no bugs from the fear section yet. Which means that the bug is somehow related to how I’ve coded the sacrifice, but not related to how I’ve coded the fear section! What in the name of the lord is going on? What is causing this bug?

Let’s figure out what’s different and do some investigating.

As far as I can tell: downtime_count is 4, it goes to the if statement, does its little age increase dance, increases downtime_count to 5, goes to the sacrifice, stay with Arcy, head back to downtime, downtime_count is 5, and … it goes back to the sacrifice. But it doesn’t make the same error for the fear section.

Wait …

Yep.

Yep @anon8836198 you nailed it.

Added in an else statement right before:

*else
  *goto arcy_downtime

*label brutal_sacrifice

Done.

2 Likes

The label right before brutal_sacrifice skips altogether because none of the *ifs land a condition (probably because in that specific playthrough fear string had blank value?) That skip leads to the game going over to brutal_sacrifice when downtime is < 4. Then you choose an option in downtime screen and go to sacrifice label the second time, now with downtime = 4.

2 Likes