Towers of Hanoi: A Classic Puzzle Reimagined in Your Terminal
Remember the classic Towers of Hanoi puzzle? I decided to this would be an interesting project to develop for the terminal, combining my newfound Python skills with a love for timeless puzzles. As a Codecademy student, I'm only really just getting started with Python and I wanted to create a little project that was not only fun but also a practical demonstration of my understanding of Python, input handling, and terminal interaction. I chose Towers of Hanoi because it's a puzzle that's both elegant and engaging. This project allowed me to practice using Git for version control, navigate the command line, and ultimately, build a playable game for anyone to enjoy. The game is structured into two main classes: Screen and Game. The Screen class handles the terminal display, using colorama for enhanced visuals and shutil to monitor the terminal size. The Game class encapsulates the game logic, managing the pegs, moves, and user input. I initially started out using input as per the project spec, but in the end replaced it with pynput for non-blocking keyboard input, allowing for a smoother interactive experience. Save and load functionality was implemented using the pickle library. The core game logic, including move validation, is handled within the try_move method, ensuring the game adheres to the rules of Towers of Hanoi. Input validation prevents the user from making illegal moves, and the clear input buffer function keeps the terminal clean. Throughout the project, I used Git for version control, committing changes regularly and pushing them to GitHub. I faced some challenges with cross-platform input handling, but I managed to resolve them by implementing platform-specific solutions. The full source code is at GitHub: https://github.com/kev51773/TowerOfHanoi/ I'd love your feedback. This project was a fantastic learning experience, solidifying my understanding of Python programming and terminal interaction. I'm excited to share this game with my friends and family, and I hope you enjoy playing it as much as I enjoyed creating it. Building this project has shown me the power of Python, and the fun that can be had when creating programs. I look forward to creating more projects in the future. If you have any suggestions or feedback, feel free to leave a comment or contribute to the GitHub repository. Happy puzzling!

Remember the classic Towers of Hanoi puzzle? I decided to this would be an interesting project to develop for the terminal, combining my newfound Python skills with a love for timeless puzzles. As a Codecademy student, I'm only really just getting started with Python and I wanted to create a little project that was not only fun but also a practical demonstration of my understanding of Python, input handling, and terminal interaction. I chose Towers of Hanoi because it's a puzzle that's both elegant and engaging. This project allowed me to practice using Git for version control, navigate the command line, and ultimately, build a playable game for anyone to enjoy.
The game is structured into two main classes: Screen and Game. The Screen class handles the terminal display, using colorama for enhanced visuals and shutil to monitor the terminal size. The Game class encapsulates the game logic, managing the pegs, moves, and user input. I initially started out using input as per the project spec, but in the end replaced it with pynput for non-blocking keyboard input, allowing for a smoother interactive experience. Save and load functionality was implemented using the pickle library. The core game logic, including move validation, is handled within the try_move method, ensuring the game adheres to the rules of Towers of Hanoi. Input validation prevents the user from making illegal moves, and the clear input buffer function keeps the terminal clean. Throughout the project, I used Git for version control, committing changes regularly and pushing them to GitHub. I faced some challenges with cross-platform input handling, but I managed to resolve them by implementing platform-specific solutions.
The full source code is at GitHub: https://github.com/kev51773/TowerOfHanoi/
I'd love your feedback.
This project was a fantastic learning experience, solidifying my understanding of Python programming and terminal interaction. I'm excited to share this game with my friends and family, and I hope you enjoy playing it as much as I enjoyed creating it. Building this project has shown me the power of Python, and the fun that can be had when creating programs. I look forward to creating more projects in the future. If you have any suggestions or feedback, feel free to leave a comment or contribute to the GitHub repository. Happy puzzling!