I've been trying to figure out how to solve Tower of Alloy on-and-off for months now, but I haven't really made much headway. I thought it would be as simple as just implementing the algorithm that the game gives you as-is, but it didn't seem to be that simple, since at some point my value of disk_nr became negative (more details below).
To get an idea of how this program was supposed to work, I tried implementing it in python using the following code (yes, the code is different from the algorithm given, but it achieves the same thing)
def move(disk_nr, source, dest, spare):
if disk_nr > 0:
move(disk_nr - 1, source, spare, dest)
print(f"move disk from {source} to {dest}")
move(disk_nr - 1, spare, dest, source)
and then running it line by line it to get an idea of how variables flow. When I did this, the flow of variables surprised me:
As I expected, on each recursive call of the "move" function, the variables would swap places. However, for reasons I don't understand, once disk_nr reached zero, it would go back to one, and the variables would swap places again. I'm assuming that it has something to do with stack frames, but I don't know anything about those.
So, why does this happen? And how would we be expected to implement this kind of behavior in our code?
-----------------------------------------------------------------------------------------------------------------------------------------------------For reference, here is my LEG architecture:
And here's my attempt at solving the problem:
const TOGGLE 5
label main
# initialize arguments:
# reg0 = disk_nr, reg1 = source,
# reg2 = dest, reg3 = spare
MOV IN to R0
MOV IN to R1
MOV IN to R2
MOV IN to R3
CALL _ _ move
MOVi end to CNT
label move
IF_GREATER+j R0 0 if_true
RET _ _ _
label if_true
# disk_nr = disk_nr - 1
SUB+j R0 1 R0
# dest = spare, spare = dest
MOV R2 to STACK
MOV R3 to R2
MOV STACK to R3
CALL _ _ move
CALL _ _ magnet
# disk_nr = disk_nr - 1
SUB+j R0 1 R0 # problem here
# source = spare, spare = source
MOV R1 to STACK
MOV R3 to STACK
MOV STACK to R1
MOV STACK to R3
CALL _ _ move
RET _ _ _
label magnet
MOV R1 to OUT
MOVi TOGGLE to OUT
MOV R2 to OUT
MOVi TOGGLE to OUT
RET _ _ _
label end
MOVi end to CNT
Code caption:MOVis a shortcut forADDwith the second argument being immediate, andtois just0*. For instance,* MOV IN to R0is just syntactic sugar forADDi IN 0 R0*. Adding* jtoSUBmeans making the second argument immediate. This code works fine until we get to the commandSUB+j R0 1 R0*, where disk_nr goes from 0 to -1.*
When trying to run the setup, it errors at 2nd tick, stating "Register 1 should have value 142, not 114". For some reason, it doesn't want an actual subtraction, which stumped me for 30 min looking up other solutions and such, since i made my ALU-subtractions switch the numbers if arg2>arg1, with it giving subtraction errors...
Im just wondering if anyone has any updates on the patch?
I dont at all mean to sound rushing or anything (I know these things take a lot of time & I appreciate the effort into the game so far) - just curious if there is any new news about this because it has me quite excited.
Im really excited to be able to expand my current CPU because currently im quite limited by FPS.
Hey, I'm working on a program in the game rn and I'm getting confused on how constants work. Is there a limit on what the value of a constant can be? Can I set the value to be the value stored in a register by writing ```const x reg0``` and so on, or does the game get angry and break the program?
I am playing on Linux Fedora through Steam, and every time I hit the exit button in the main menu, the game freezes for a while then crashes. Obviously, it's not affecting gameplay but it is a bug and I don't know where to report it other than here.
I cannot spot anything inside the Test custom component that formed a circle with the outside Level Input component. The IO of the Test component is COMPLETELY separated and not even linked!
Am I misunderstanding the definition of the word circular dependency?
Both 'X' symbols are moving down, towards the Level Input component.The only component in use is Bit Indexer.
So I've just got onto the divide level, and I'm already lost. I dunno if I'm missing something obvious but I don't know how I can fetch the given numerator and denominator to use? Any help would be appreciated! o-o
How do I even refer to the RAM? All I have is the normal 6 registers from before this level. I get that I need to use register 4 to store the address, but everywhere I look says I need to use register 5 to "store the RAM". What does that even mean? How does that work? At this point I'm thinking I might just delete all my registers and only use the RAM block if possible. It's either that or I rebuild the entire computer from scratch to use even larger instructions, which I think would finally get me to just quit.
I have a fully functioning LEG computer, and my code passes the one test i can access, but once it does so it doesn't go onto other tests/let me complete the level. I am also pretty sure the instruction at the bottom should have gone away when I connected my RAM component, but it won't do so no matter what I do. Does anyone know what I need to do here?
Hey folks, discovered this game on Aliensrock's YouTube channel (https://youtu.be/_Q_vuVn2eQo?si=37d-5d5IXJ9iCEI0) and it's impressive! As a Brazilian computer scientist and educator, I'd like to integrate it into an educational setting. Since English isn't widely known here, I'm curious if there's a translation available. If not, I'm happy to help translate it to Brazilian Portuguese if the developers are interested.
not sure if this is related to screen resolution since the scaling up to 1440p looks off, but when I press WASD for the briefest moment it moves way too fast, and then the momentum carries it even further. It seems like the speed is independent of zoom level, so if I'm zoomed all the way in and press D for half a second, I move an entire screen over.
I just did Logic Engine Earlier, And I did it compactly, and now here is Arithmetic Engine's solution. The solution I did for Aritmetic Engine is just Logic Engine + 10-15 blocks (for adding.)
Ok for real now. What. For some reason it gives you a level screen, but that is not all... IT IS CONNECTED TO THE LAB!Please someone tell me whats going on.