Debugging Challenges


I’ve noticed that we have some very skilled coders on these forums, some middle of the road (like me), and some who really want to learn. Well I figure why don’t we?

I propose that coders with better knowledge about choicescript create a purposefully bugged script, and post it here so the rest of us can practice fixing them. This could also be challenges with a purpose, like ‘make a variable dependent on how many of 5 people like each other’ and we compare who has the most effective and efficient script.

If you would like to propose a challenge, please fill out the below app;

Username: (What is your username)
Date: (What day is it? mm/dd/yy)
Title of challenge: (A way to tell your challenge from others)
Description: (What do we have to do)
Script: (Either the script copy and pasted or a link to view it)

Finally, if you have any questions or suggestions please post them. Criticism is definitely welcomed here


I like this concept. It would surely help someone like me figure out how to use certain aspects of coding! Only a day ago I learned what the heck a boolean was and how it can be used!


I have a challenge. Make up a random name generator, that will take syllables and concoct fantasy sounding names. Or which will take words and create werewolf-esque names. I started on one and then got lazy. It’d be great if someone else would do it. Or if they’d tweak my random name code to make it more streamlined.


Oooh interesting…

I have an open request which might be interesting. Devise any kind of word puzzle using CS, just so I get ideas.


@Caddmuss Could you be more specific on exactly what you want this to do?

@FairyGodfeather Where can we view your original name generator so we can compare our own to yours?


Basically, any semi-interesting puzzle that a player has to complete. It doesn’t have to be ultra-complex, but obviously a bit of thought would be nice. It shouldn’t be riddle-related, though doesn’t necessarily have to be ASCII art. Think of thing’s like the Towers of Hanoi or Peg Solitaire.

#7 was my thread about creating a name generator. Ignore the earlier pastebin links since I eventually made it to dropbox.


The most efficient way to code the Towers of Hanoi is via recursion.


I’ve played one choice game which was a fantastic puzzle that needed to be worked out and the puzzle itself was so well integrated into the storyline. That was the Paradox Factor which @Lucid wrote. I hope it’s okay to discuss it since there was another version of the game online. I think that’s the way to do puzzles and it was just so very clever. I’m looking forward to it being released and hope that the puzzle remains untouched.

Otherwise I find puzzles frustrating in Choice games. I’ve yet to see them implemented well. I do think there is a lot we could take from text adventures and that style of interactive fiction. I also think ethical dilemmas where you discuss a situation with people, get their viewpoints and then make a decision upon that in order to implement a solution, is the sort of thing that could be done, and done well with choicescript.

I think a puzzle-fight system similar to Gun Mute might also be able to be implemented quite well.


@FairyGodfeather Unfortunately Choicescript doesn’t allow for data structures like associative arrays and hash tables that can store a long list of a hundred names in an easy to access fashion. You could trade away the two hundred *if’s by creating a pair of “faux” arrays, each with a hundred *create’s. Then you could dynamically extract the correct name from the correct “faux” array by constructing a string that matches the correct “faux” array member and “referencing” it. While computationally the code would be more efficient, it wouldn’t be any shorter or simpler looking. It would be a hair longer and require quite a bit more brain power to write. One of Choicescript’s major limitations is that it just wasn’t designed with the idea in mind that you might need to store and access a long list of data. This is why writing an inventory system like @CJW’s is such a great amount of work.


What’s the difference between using elseif and using if?


With *if, every single *if is always checked every time even if one of the *if’s has already been matched, unless you also include a *goto for each *if to skip the rest of the *if’s. *elseif/*elsif’s only get checked if the previous if and elsif’s haven’t matched. So it’s computationally more efficient, and thus faster, to use elsif’s. Nevertheless I believe there was an issue with *elsif breaking on the Kindle at one point. So people stopped using *elsif for this reason. Maybe I’m mistaken, but I was under the impression that this had been fixed.


Oh thanks! Once I thought about it I suspected it might be something like that. Would it be better to add gotos after all of them then? I didn’t really understand the point of elsif before so I never used it, but I can see how it’s useful.


Actually, the best thing is probably to ask @dfabulich, the author of choicescript, if there is any reason to avoid using elseif/elsif at this point, because a lot of people are still clearly avoiding it. Nevertheless I notice that it’s still in the recently rewritten online Introduction to Choicescript doc, I’ve seen it used occasionally in some of the newer official CoG games, albeit sparingly, and I recall seeing a few commits to the choicescript git code repository relating to elseif/elsif over the past year or so.


If anyone has experience with JavaScript they could go in an alter the base code that choicescript runs on. Do you think the authors would get mad if we did that?


I made a thing! It’s an extremely basic Rock Paper Scissors game. It was inspired by this thread. I wanted to implement a gun if you hit 10 loses and from that point you can cheat, and a tropy if you hit 10 wins but I got bored since the random generator kept cheating.

I was also too lazy to work out how to upload it in a playable way so just copy the code into the online tester at

Anyway the Rock Paper Scissors code is at I think it works but since I just churned it out quickly it might not.


I’ve got one:

Title of challenge: Choicescript Hangman Coding Challenge
Description: Provided is some basic code for a hangman game in choicescript. There are no particular goals to achieve, but you should try and improve upon the current design - there are definitely things missing, or things that could be done more efficiently.

Online Choicescript Tester


*elseif is supposed to work as you’d expect; I know of no known issues/bugs with it.

It doesn’t improve performance at all. But it does serve two purposes:

  1. It’s a lot easier to read/understand *if/*elseif/*else than it is to just read *if/*if/*if.

  2. Specifically, using *else helps the Quicktest automated testing program to avoid “fake bugs,” as explained here.


Indeed, arrays suck in ChoiceScript. But remember that you can use *setref and curly parens (without “$”) to indirectly refer to variables, allowing you to simulate a lot of fancy array stuff. See the “Truly bizarre references” section at the end of the Advanced guide.

*temp fibonacci_0 1
*temp fibonacci_1 1
*temp fibonacci_2
*temp fibonacci_3
*temp fibonacci_4
*temp fibonacci_5
*temp fibonacci_6
*temp fibonacci_7
*temp fibonacci_8
*temp fibonacci_9

*temp i 2
*temp j
*temp k
*temp fib
*label loopstart
*if i < 10
  *set j i-1
  *set k i-2
  *setref "fibonacci_${i}" {"fibonacci_${j}"} + {"fibonacci_${k}"}
  *set fib {"fibonacci_${i}"}
  ${i}: ${fib}

  *set i +1
  *goto loopstart

I’ll admit, that’s still pretty annoying. One feature I’ve yet to code that would make that a little less annoying would be to allow you to define a bunch of numbered temp variables at once, like this:

*temp_list fibonacci 10

It would also be nice to allow arbitrary expressions in ${}, like this:

*setref "fibonacci_${i}" {"fibonacci_${i-1}"} + {"fibonacci_${i-2}"}
${i}: ${"fibonacci_${i}"}

Those together would let you rewrite the Fibonacci code as something like:

*temp_list fibonacci 10
*set fibonacci_1 1
*set fibonacci_2 1

*temp i 3
*label loopstart
*if i <= 10
  *setref "fibonacci_${i}" {"fibonacci_${i-1}"} + {"fibonacci_${i-2}"}
  ${i}: ${"fibonacci_${i}"}

  *set i +1
  *goto loopstart

Sadly, stuff like this just isn’t at the top of my list right now. :frowning:


@CJW So I looked at your challenge. At first, I was like, “Oh, Hangman? That can’t be too difficult, right?” After an hour and a half, I was like, “Well, crap…” I can’t even figure out where to start with it! I can’t even figure out where all the codes lead you and what the heck is even going on with all those commands and stuff! That is much more difficult than I would have ever thought it could be.