Skip to content

Conversation

@flynnstigator
Copy link

Game works well, cannot find any inputs that cause an unhandled error. Render function could be prettier, but gets the job done.

I wrote my name, thus demonstrating my genius!
Added the towers.rb file with a high-level description of the problem.
The game works and can be won, but the elsif implementations could be
more concise, it allows the illegal move of placing a larger disc on
top of a smaller one, there are no methods or classes, and the render
only prints out the arrays.
Separated render function. Split user input into an array.
Changed left, right, middle pegs to pegs which contains arrays within
it.

Added a method to check if move is legal, first by checking if it is
between 1 and 3, then making sure the destination peg does not already
have a smaller disc.

Added a method to move the disc.

It does not appear to be moving anything, which I think is because I’m
explicitly returning in the check_if_legal method and I believe that is
breaking out of the whole loop. Will need to find a better way to
accomplish the task.
Added a loop to keep the number of discs between 1-8.

Fixed an array index error in the legal move check and move_disc
methods.

Added comments explaining what is going on.
Improved the render function to look like a tower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant