-
Notifications
You must be signed in to change notification settings - Fork 0
Towers of Hanoi #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Conversation
| function checkForWin() { | ||
| // Your code here | ||
|
|
||
| if (stacks.c[3] === 1){ //checks for the "1" block on top of a four-stack in stack "c." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like that you reset the board.
Checking to see if the last piece is 1 assumes that the reset of your code will not let that happen.
While this is logically correct, a better approach might have been to verify that the a and b stacks are empty and the c stack - 4,3,2,1
| //console.log("Length of startStack: " + begin.length); | ||
| //console.log("Value of block being moved: " + begin[begin.length - 1]); | ||
| //console.log("Value of block being topped off: " + final[final.length - 1]); | ||
| if (begin[begin.length - 1] > final[final.length - 1]) { //making sure the "block" is being move onto a larger "block" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should return a false if it is not a legal move.
Also checking for a legal move is a better approach. IE start out assuming the move is not legal unless you prove otherwise.
This implementation allows you to move piece back to its own stack. Not wrong just weird that it would be allowed.
| // Your code here | ||
|
|
||
| /* | ||
| *This function removes a block from a stack and adds that block to a different stack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the documentation, and it was obvious you used log statements to debug as you were going along. Nice!
| //console.log("Length of startStack: " + begin.length); | ||
| //console.log("Value of block being moved: " + begin[begin.length - 1]); | ||
| //console.log("Value of block being topped off: " + final[final.length - 1]); | ||
| if (begin[begin.length - 1] > final[final.length - 1]) { //making sure the "block" is being move onto a larger "block" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also allow me to move from an empty stack to another empty stack, or from an empty stack to a non-empty stack
Checkpoint Rubric
This is the rubric that your instructor will use to grade your checkpoints. Please do not edit.
Checkpoint 1
Checkpoint 2
Checkpoint 3