i need help rewriting a few of the functions because i was curious about the different ways, specifically the last function and the "domove" function, any hints or help?
i need help rewriting a few of the functions because i was curious about the different ways, specifically the last function and the "domove" function, any hints or help?
Could you be more specific? In what way do you need help? How do you need it to be changed? The one thing I would definitely change are the names of your variables.
Yes i plan on doing that, well i figure i cant really change the swap function becasue that is pretty legit. I just need help changing the others i mentioned around cause i also have this program to complete. is there any way to do those two that i mentioned a different way such as a different if statement for the last one?
I should mention there is a difference between optimal amounts of coding and optimal amounts of CPU cycles. If you are asking "how do I change my condition to a loop" I should remind you that the way you have been writing isn't necessarily the cleanest looking, but they are the least amount of ticks.
ok so your saying the if statement can be "cleaner" by using a loop ?
I am saying you have things written to be fast. Which in my opinion is good. I am more of a speed over neatness kind of fella.
ok, what other way could i possible do it?
Loops. I refuse to help someone produce code I find to be less than optimal. So you can wait for someone kind explainer of alternate methods to jump into this one (matsp).
ok thank you..what about the do move function?
I don't see a problem with the doMove() function. Assuming the logic works properly (I didn't check that).
ok im trying not to use the same code as the other one, any more possible hints?
The big massive if at the bottom can be improved a bit, in my opinion. There's not much here: find the chosen tile, find the blank, swap if legal. That's what a move is in this game, so you're going to have to more-or-less follow that pattern.
ok thanks , what other variable names can i use
ok is it necessary to initialize all my variables to 0 in function 1 or the others?