Bughunt: Random, rare error


#1

Trying to nail down the fix for this elusive bug. Happens maybe once out of 50 identical test runs.

The section that’s failing is a long list of *ifs. It’s a skill list that only shows the skills for the class you picked. Looks like this:

*choice
    *if (((((((class = "Musician") or (class = "Brawler")) or (class = "Spirit")) or (class = "Faceman")) or (class = "Tester")) or (class = "Dancer")) or (class = "Thief")) #Stealing
        *stuff happens
    *if ((((class = "Brawler") or (class = "Spirit")) or (class = "Dancer")) or (class = "Thief")) #Fighting
        *stuff happens
    etc.

The error is that there’s no choices available, which means my long list of *ifs failed. I don’t get why this only happens 1 in 50 identical runs.

Anyone know why this happens? Is there a better/more reliable way to write this?

I read somewhere that Java has rare erratic problems when comparing strings. Is that the issue? If so, would changing all the classes to number codes fix it? IE if class = 4, if class = 3, etc.


#2

I temporarily added this to the end of it:

*else
    THAT BUG HAPPENED
    *choice
        #End?
            *return

But I haven’t been able to trigger the bug since I added it. Still testing…


#3

The *bug command is useful for this, in combination with Randomtest. https://www.choiceofgames.com/make-your-own-games/testing-choicescript-games-automatically/#bugcommand


#4

ty thats a lot more elegant than mine :]

I have used randomtest before with no luck. I added the *bug thing and still randomtest passes fine.

“RANDOMTEST PASSED
Time: 140.755s”

10,000 iterations


#5

Ran another randomtest

RANDOMTEST PASSED
Time: 141.287s
10,000 again

Still fails randomly during regular use. Sent to a friend to try on his system + chrome instead of firefox, and he got the same problem on his first run (but not second or third). Always same error about ‘no choices’.


#6

You want to post so we can check it out manually? It sounds like an @CJW problem, but he’s gone until April. Also, browser/OS, and are playing it locally, or over the internet?


#7

@rinvalak have you used the same *if statements elsewhere in your game? Maybe the “no choices available” is showing up as there ARE no available choices. It’s an *if statement and will only show if the conditions are met. Have you tried to play it up to those if statements? Or run a quick test instead of only using a random test? Maybe try a simple one then slowly add the extra codes in so you can see what part it doesn’t like.

*choice
*if ((musician) or (brawler)) # choice 1
Written text for choice 1
*goto whatever_label

Hope your able to fix your bug


#8

@silverstone, The problem I’m having is that I can run through it successfully ~50 times in a row, then randomly at some point it errors out (picking the same exact choices). Happened again, the exact error is: “No selectable options.” Quicktest passes too. I just added a debugging option “#IF THIS IS THE ONLY CHOICE YOU SEE, IT BUGGED OUT” that doesn’t have any *if in front of it. So hopefully the next time it fails I’ll see that as the only option I guess.

Also, I did cut out 90% of the game by adding in a *if debug = true *finish, so it ends immediately after the problem section. Makes testing faster.

@Reaperoa, I’m running it locally via firefox. Like I said I’ve sent it to a friend to run on chrome and he got the same issue.

Alright, hope this helps:

*label skillselect
*if (skillnumber = 0)
    *return
Choose [i]${skillnumber}[/i] Skill(s)
*choice
    *if (((((((class = "class1") or (class = "class2")) or (class = "class3")) or (class = "class4")) or (class = "class5")) or (class = "class6")) or (class = "class7")) #skill1
        *set skill1 true
        *set skillnumber -1
        *goto skillselect
    *if ((((class = "class1") or (class = "class3")) or (class = "class4")) or (class = "class7")) #skill2
        *set skill2 true
        *set skillnumber -1
        *goto skillselect
    *if ((class = "class1") or (class = "class7")) #skill3
        *set skill3 true
        *set skillnumber -1
        *goto skillselect
    *if ((((class = "class1") or (class = "class4")) or (class = "class6")) or (class = "class7")) #skill4
        *set skill4 true
        *set skillnumber -1
        *goto skillselect
    *if ((((((class = "class1") or (class = "class8")) or (class = "class10")) or (class = "class13")) or (class = "class9")) or (class = "class11")) #skill5
        *set skill5 true
        *set skillnumber -1
        *goto skillselect
    *if (((((((class = "class1") or (class = "class12")) or (class = "class3")) or (class = "class4")) or (class = "class13")) or (class = "class9")) or (class = "class11")) #skill6
        *set skill6 true
        *set skillnumber -1
        *goto skillselect
    *if (((((class = "class1") or (class = "class6")) or (class = "class7")) or (class = "class13")) or (class = "class9")) #skill7
        *set skill7 true
        *set skillnumber -1
        *goto skillselect
    *if ((((((class = "class1") or (class = "class2")) or (class = "class8")) or (class = "class6")) or (class = "class13")) or (class = "class11")) #skill8
        *set skill8 true
        *set skillnumber -1
        *goto skillselect
    *if (((((((((class = "class1") or (class = "class12")) or (class = "class8")) or (class = "class4")) or (class = "class5")) or (class = "class10")) or (class = "class13")) or (class = "class9")) or (class = "class11")) #skill9
        *set skill9 true
        *set skillnumber -1
        *goto skillselect
    *if (((((class = "class1") or (class = "class2")) or (class = "class3")) or (class = "class8")) or (class = "class6")) #skill10
        *set skill10 true
        *set skillnumber -1
        *goto skillselect
    *if ((((((((((class = "class1") or (class = "class12")) or (class = "class3")) or (class = "class8")) or (class = "class4")) or (class = "class5")) or (class = "class6")) or (class = "class7")) or (class = "class10")) or (class = "class9")) #skill11
        *set skill11 true
        *set skillnumber -1
        *goto skillselect
    *if (((((class = "class1") or (class = "class12")) or (class = "class8")) or (class = "class5")) or (class = "class9")) #skill12
        *set skill12 true
        *set skillnumber -1
        *goto skillselect
    *if ((((((class = "class1") or (class = "class2")) or (class = "class3")) or (class = "class8")) or (class = "class6")) or (class = "class7")) #skill13
        *set skill13 true
        *set skillnumber -1
        *goto skillselect
    *if (((((class = "class1") or (class = "class2")) or (class = "class3")) or (class = "class8")) or (class = "class6")) #skill14
        *set skill14 true
        *set skillnumber -1
        *goto skillselect
    *if ((((class = "class1") or (class = "class7")) or (class = "class10")) or (class = "class13")) #skill15
        *set skill15 true
        *set skillnumber -1
        *goto skillselect
    *if (((((((class = "class1") or (class = "class2")) or (class = "class3")) or (class = "class5")) or (class = "class7")) or (class = "class10")) or (class = "class13")) #skill16
        *set skill16 true
        *set skillnumber -1
        *goto skillselect
    *if ((class = "class1") or (class = "class7")) #skill17
        *set skill17 true
        *set skillnumber -1
        *goto skillselect
    *if (((((class = "class1") or (class = "class12")) or (class = "class5")) or (class = "class7")) or (class = "class10")) #skill18
        *set skill18 true
        *set skillnumber -1
        *goto skillselect
    #IF THIS IS ALL YOU CAN SEE, A BUG HAPPENED.
        *bug thebug

#9

Followup. This is what it looks like now that I’ve added that bug message. This happens maybe once in 20-100 identical playthroughs.

Restart, click the same choices again, and it works fine ~50 times in a row after that.


#10

I think theres no available options after a certain amount of skill picking. I had this problem when I was playing through my own WiP last week. Theres still skill points to spend yet there is no more options to pick. Do you think thats what might be happening?

Althought it didnt happen randomly for me. So this happens with the exact same choices each time you end up with that message?

Also, silly me I just noticed. When you finish adding the skills did you have an #option to move on to the next part of your story?


#11

I would personally add

*if (((((((((((((((((skill18=false) and (skill17=false)) and (skill16=false)) and (skill14=false)) and (skill13=false)) and (skill12=false)) and (skill11=false)) and (skill10=false)) and (skill9=false)) and (skill8=false)) and (skill7=false)) and (skill6=false)) and (skill5=false)) and (skill4=false)) and (skill3=false)) and (skill2=false)) and (skill1=false)) skill1=false
        *set skillnumber 0
        *goto skillselect

#12

@silverstone yes, same exact choices. The randomness is what’s making it so difficult to troubleshoot. The connection back to the rest of the game is lines 2 and 3. The code loops until you run out of skillpoints, then it *returns.
@lordirish This is a looping bit with multiple skill points. So setting the skillnumber to 0 would only give you 1 skill choice. It loops until skillnumber = 0, then it moves on to the next part of the game.


#13

Hmm… each to their own. Hope you can get it fixed then. I used *selectable_if and *temp to create a skill boosting part in my WiP. Took ages to work out the kinks but in the end it worked the way I wanted. Im not sure how *return works in an *if statement because I dont use it but have you tried to change it to a *goto and see if that fixes the problem of returning?


#14

From what I can see, there’s a fair chance the error is being caused by something outside the quoted section (assuming it’s not some odd mechanical error only CJW or Dan will be able to point out).


#15

according to your screenshot there is still 1 skill left unassigned so I’d say in that particular playthrough you had more skillnumber than skills available


#16

@nocturnal_stillness The choices being visible depends on your class. So one in fifty playthroughs, choicescript/javascript thinks that “class1” does not equal “class1”, therefore none of the *ifs apply and no choices are displayed except for my bug message. (my current best guess)

Anyway, just to be super clear, sometimes this error happens as soon as I get to the skill menu, sometimes it happens after I pick a few skills. (identical choice clicks every time). No consistent spot, or else it would be easy to troubleshoot and fix.

@silverstone *return is part of using subroutines, which are similar to ‘functions’ in coding. During character creation, I say *gosub skills, which is my choosing # skills menu, then *return and it pops me back where I was in char-creation. Very handy. https://www.choiceofgames.com/make-your-own-games/choicescript-advanced/


#17

Thanks for that rinvalak. I’ve tried it before and the way I’ve scripted so far doesn’t like it so I keep it simple and steer clear of it. (gosub and return commands). I had too many bugs with it.

Not sure where the bug is then if you’ve tried simplifying the statements down and it’s still getting the same problems. Sorry not much help.


#18

To test your theory that “class1” doesn’t equal “class1” for some reason, have you ever output variable “class” to see what it actually is?

What I mean is to do something like:

Replace: Choose ${skillnumber} Skill(s)

With: Choose [i]{skillnumber}[/i] Skill(s) [DEBUGGING: class = {class}]

Then, when the bug happens, make sure class really still is “class1”.

Have you tried copy-pasting just that section of code to its own game all by itself and testing it that way?

Another thing to try would be to use a script program to record all mouse clicks to make sure you really are making all the EXACT same choices along the way.

It’s a weird bug, that’s for sure, and I’d be interested to see what the cause is. However, if you try the above and just can’t find it, I’d suggest making a separate *choice block for each class. Something like:

*if class = "class1"
     *choice
          ...
*elseif class = "class2"
      *choice
          ...

and so on. It’d suck to have to do this, but well… I hope it doesn’t come to this, and you find the cause.


#19

Great ideas across the board, thank you! Yeah the error happens after 3 choices, so it’s fairly easy to tell I’m picking the same three every time.

Will be trying all your suggestions, and the last one if it comes to that