Feedback on a "Reactor Core" fuel rod placement puzzle

Asyranok
30 Mar 2013, 01:20
Hi guys,

I have recently finished a fully functional puzzle for WAKE that does not involve any items to solve. This is a break from the typical puzzle where someone must use their problem solving abilities to guess a passcode, or must apply items found to a puzzle to solve it.

This puzzle purely involves logic and interaction with a visible interface to solve. It is fairly simple at the moment. The player must shift several fuel rods into reactor couplings to force the reactor to overload and reset.

I've uploaded the .quest and .aslx files into a compressed folder that is attached to this post. Inside the folder are the necessary images and the convib library for playing through the .aslx. Also, the .quest file alone is uploaded to mediafire: http://www.mediafire.com/?9pmzf0ecs70038w

I am looking for feedback on whether it is an interesting puzzle; what might be wrong with it; how can I improve it?

I welcome feedback on the code, although I am not in a hurry to make it more efficient. This is my first attempt at coding something this large ever, so I will not be particularly efficient at it. Some people have given me advice for fixing code that I haven't even had time to get around to yet.

But, regardless - thank you for any help! Instructions are in the puzzle itself. Hopefully they are clear - which is something I'd love feedback on.

jaynabonne
30 Mar 2013, 09:28
The graphics don't show up for me. I assume that will make it a bit tough to solve! :)

If you publish it to a .quest game, the graphics *should* be included...

jaynabonne
30 Mar 2013, 09:38
Just a coding tip - something like this:

if (Rod 5A.position = False) {
Rod 5A.position = True
}
else if (Rod 5A.position = True) {
Rod 5A.position = False
}


can be simply written as:

Rod 5A.position = not Rod 5A.position


I would also take those big blocks of repeated "ifs" and put them in a function. That is prime candidate for factoring, and if you ever had to change things, it would keep you from going insane by having only one place to make changes!

jaynabonne
30 Mar 2013, 09:45
More thoughts... here is a little function that might help:

<function name="DumpRodRow" parameters="rodA,rodB">
if (rodA.position) {
s = "{img:rodA.png}"
} else {
s = "{img:rodC.png}"
}
s = s + " "
if (rodB.position) {
s = s + "{img:rodB.png}"
} else {
s = s + "{img:rodD.png}"
}
msg(s)
</function>


Then you can just do:

DumpRodRow(Rod 1A, Rod 1B)
DumpRodRow(Rod 2A, Rod 2B)
DumpRodRow(Rod 3A, Rod 3B)
DumpRodRow(Rod 4A, Rod 4B)
DumpRodRow(Rod 5A, Rod 5B)


instead of 20 if's.

Asyranok
30 Mar 2013, 15:34
Thanks for that! Sorry about the images didnt think of that. I originally tried to upload it as a dot quest but for some reason that file cant be uploaded to the forums.

Asyranok
30 Mar 2013, 16:45
I uploaded the quest file version to mediafire.

http://www.mediafire.com/?9pmzf0ecs70038w

jaynabonne
30 Mar 2013, 17:10
I had a similar problem with a .js file. You can always wrap it up in a zip fie (aka "compressed folder").

Asyranok
30 Mar 2013, 17:36
Ah smart. Didn't think of that, but I will do that in the future! Thanks :D

jaynabonne
30 Mar 2013, 17:38
I think it's a nice little puzzle. I like the graphical aspect of it. I wasn't sure how to interact at first, but it didn't take long to find the Rods in the right pant. My only suggestion would be if you could put the numbers in somehow, but even that's not really necessary, as there is a logic to it, and someone can figure out which is which.

NIce one! :)

Asyranok
30 Mar 2013, 17:46
Thanks! I'm glad you liked it. I will try to find a way to put the numbers in there. I wouldn't be able to put the numbers in the pictures as that would complicate things too much, but I think I can just as easily post the numbers to the left and right of each picture with very little extra effort. I'll work on that now.

Thanks again :D

And I will use your advice to make my code for flexible. That's awesome, and thanks for the sample!

HegemonKhan
31 Mar 2013, 00:51
I'm not sure if this can be explained, lol, but I'm having trouble in grasping the logic of:

Rod 5A.position = not Rod 5A.position
(and does this need an "if" in front of it too?, as I haven't looked at his~her game code, so I don't know what else is in his~her coding block in relation to these code lines)

in how it translates to:

if rod 5A.position = true
then rod 5A.position = false

if rod 5A.position = false
then rod 5A.position = true

jaynabonne
31 Mar 2013, 01:14
In Quest (and other programming languages), "not" is an operator which returns the opposite logic value from what is given it. It is the "logical negation" operator. (In a language like C, C++, Java, and Javascript, the symbol "!" is used instead for this operator.)

not true => false
not false => true

So if rod 5A.position = true, then "not rod 5A.position" will equal false.

Try this in Quest:

msg(not false)

Quest will spit out: True

So "rod 5A.position = not rod 5A.position" will assign to rod 5A.position the opposite logic value. Consider a parallel statement "x = -x" which assigns the negative of x to x (in programming languages).

"not" just negates boolean values instead of "-" which negates numeric ones.

Asyranok
31 Mar 2013, 01:24
Ah, makes sense. Although this would only work for boolean right? Since if it was an integer, it could be any whole number?

I went straight in and made all the fixes to that to cut out unnecessary code. Although, I'm embarrassed to admit that your suggestion for the dumprow function are falling on amateur ears. I have no idea how to read that and figure out what is going on there, and no way to replace my code with that so that it all works. :(

jaynabonne
31 Mar 2013, 01:32
Yes, you can only apply not to boolean values.

Going further, you can do all sorts of "logical arithmetic" outside of if's.

player.legal = player.age >= 21

game.finished = player.dead or player.parent = FinalRoom

Stuff like that (and more, including as return values for functions). An "if" statement just looks for a true or false value coming out of an expression. You can do more with those kinds of boolean expressions than just stick them in "if"s. :)

jaynabonne
31 Mar 2013, 01:42
Asyranok wrote:I went straight in and made all the fixes to that to cut out unnecessary code. Although, I'm embarrassed to admit that your suggestion for the dumprow function are falling on amateur ears. I have no idea how to read that and figure out what is going on there, and no way to replace my code with that so that it all works. :(


Basically, I just saw the pattern in your code. You had this (one case):

        if (Rod 1A.position = False and Rod 1B.position = False ) {
msg (("{img:rodA.png} {img:rodB.png}"))
}
if (Rod 1A.position = True and Rod 1B.position = True) {
msg (("{img:rodC.png} {img:rodD.png}"))
}
if (Rod 1A.position = True and Rod 1B.position = False ) {
msg (("{img:rodC.png} {img:rodB.png}"))
}
if (Rod 1A.position = False and Rod 1B.position = True) {
msg (("{img:rodA.png} {img:rodD.png}"))
}

You have two rod positions and two image slots. And if you study the above, you'll see that you always generate a row (so at least one "if" will always hit - two yes/no values make four choices). And for that, the image in slot A is rodA whenever the "A" position is false, else it's rodC. (So A position = false implies graphic is rodA, etc). And the same applies to the B slot - you get B or D for position being false or true, respectively.

I'm not sure if that helps at all. lol Basically, instead of writing out all possible cases, it just builds the string from (I assume) the same rules that generated all the if's to begin with. But by using the rules directly instead of the end results, and by letting the code generate the string for you, it can be written more concisely and, ultimately, more clearly, because you can see *why* those if's got written the way they did.

HegemonKhan
31 Mar 2013, 12:10
I understood what " not " is~does, that is very simple, what I don't understand is how this:

Rod 5A.position = not Rod 5A.position

is~does the same thing as:

if rod 5A.position = true
then rod 5A.position = false

if rod 5A.position = false
then rod 5A.position = true

how does this, " Rod 5A.position = not Rod 5A.position " , work in being~producing the same as this: " if rod 5A.position = true, then rod 5A.position = false, and if rod 5A.position = false, then rod 5A.position = true "

I don't understand the logic of it, of how it works in being the same thing as the "expanded" (the dual IF) statements.

-------------

P.S.

and your other codes are very interesting, thank you, I did not know you could do all those things, and especially without using the "IF" scripts!

-------------

P.S.S.

nvm (nevermind), I think I kinda understand now how it is working:

"function": Rod 5A.position = Return_value (not Rod 5A.position)

if Rod 5A.position = true:

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not true)
"function": Rod 5A.position = Return_value (false)

if Rod 5A.position = false:

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not false)
"function": Rod 5A.position = Return_value (true)

if Rod 5A.position = +X:

(pretending that "not" works here)

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not +X)
"function": Rod 5A.position = Return_value (-X)

if Rod 5A.position = -X:

(pretending that "not" works here)

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not -X)
"function": Rod 5A.position = Return_value (+X)

if Rod 5A.position = 0:

(pretending that "not" works with binary here)

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not 0)
"function": Rod 5A.position = Return_value (1)

if Rod 5A.position = 1:

(pretending that "not" works with binary here)

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not 1)
"function": Rod 5A.position = Return_value (0)

if Rod 5A.position = yes:

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not yes)
"function": Rod 5A.position = Return_value (no)

if Rod 5A.position = no:

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not no)
"function": Rod 5A.position = Return_value (yes)

if Rod 5A.position = hot:

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not hot)
"function": Rod 5A.position = Return_value (cold)

if Rod 5A.position = cold:

"function": Rod 5A.position = Return_value (not Rod 5A.position)
"function": Rod 5A.position = Return_value (not cold)
"function": Rod 5A.position = Return_value (hot)

etc etc etc

I didn't see how it "functions" like a function, and thus couldn't understand how it works the same as the dual IF statements.

jaynabonne
31 Mar 2013, 12:46
I'm a bit lost by the nomenclature you are using (espcially the constant referring to "function" and "return_value", when what we have here are really expressions - you've basically wrapped "not" in another level of function), but as long as it's clear now, I'm good with it. :)

HegemonKhan
31 Mar 2013, 14:56
ya, it's just my way of being able to understand how this code line is working as a replacement to the dual IF statements, lol.
It's acting like a function that returns (outputs) the opposite value of the input, at least that's how I'm able to understand it.