- Overview
- Features
- Technologies Used
- Getting Started
- Usage
- Future Enhancements
- Contributing
- License
- Acknowledgements
- Contact
The Water Bucket Puzzle is a Python-based interactive game that simulates the classic water jug problem. The objective is to manipulate three buckets with capacities of 3 liters, 5 liters, and 8 liters to measure exactly 4 liters of water. This project enhances problem-solving skills and provides an engaging way to understand algorithmic thinking.
- Interactive Command-Line Interface: Users can Fill, Empty, and Pour water between buckets to achieve the desired volume.
- Beautiful User Interface: Utilizes ipywidgets and matplotlib to create a dynamic and visually appealing UI within Google Colab.
- Real-Time Visualization: Displays the current state of each bucket using graphical representations, updating in real-time based on user actions.
- Type-Hinted Code: Implements Python’s
typing
module for improved code readability and maintainability. - Extensible Design: Easily modify bucket sizes or add new features, such as automated solvers using algorithms like Breadth-First Search (BFS).
- Python: Core programming language for developing the game's logic and functionality.
- ipywidgets: For building interactive UI components that make the game engaging and easy to navigate.
- Matplotlib: To visualize the bucket states dynamically, providing users with immediate feedback on their actions.
- Google Colab: Platform for developing, running, and sharing the interactive notebook, making it accessible to a wider audience.
Follow these instructions to set up and run the Water Bucket Puzzle on your local machine or within Google Colab.
- Python 3.6+: Ensure you have Python installed. You can download it from python.org.
- pip: Python package installer.
- Google Colab Account (Optional): For running the interactive UI in a cloud environment.
-
Clone the Repository
git clone https://github.com/hakhan2001/Water-Bucket-Puzzle.git cd Water-Bucket-Puzzle
-
Create a Virtual Environment (Optional but recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install ipywidgets matplotlib
-
Enable Jupyter Widgets Extension (For Interactive UI in Jupyter Notebooks)
jupyter nbextension enable --py widgetsnbextension
Run the command-line version of the Water Bucket Puzzle directly from your terminal.
-
Navigate to the Project Directory
cd Water-Bucket-Puzzle
-
Run Run the file of python.ipynb
-
Follow the On-Screen Prompts
- Fill (F): Fill a bucket to its maximum capacity.
- Empty (E): Empty a bucket completely.
- Pour (P): Pour water from one bucket to another.
- Quit (Q): Exit the game.
Experience the Water Bucket Puzzle with a beautiful and interactive UI using ipywidgets and matplotlib within Google Colab.
-
Open Google Colab
Navigate to Google Colab and sign in with your Google account.
-
Open the Notebook
Click on
File
>Open notebook
and enter the URL to your notebook or upload it from your local machine. -
Run the Notebook
Execute each cell by clicking the
Run
button or pressingShift + Enter
. Follow the interactive prompts to play the game. -
Interact with the UI
Use the provided buttons to Fill, Empty, and Pour water between buckets. Watch the real-time visual updates to solve the puzzle.
- Automated Solver: Integrate algorithms like BFS to automatically solve the puzzle and guide users through optimal steps.
- Advanced Visuals: Enhance the UI with more detailed graphics and animations for a richer user experience.
- Customizable Buckets: Allow users to define their own bucket sizes, creating varied and personalized challenges.
- Move Counter: Implement a counter to track the number of moves taken to solve the puzzle.
- Solution Hints: Provide hints or step-by-step solutions for users who are stuck.
Contributions are welcome! If you have suggestions, bug reports, or want to contribute new features, please follow these steps:
-
Fork the Repository
-
Create a New Branch
git checkout -b feature/YourFeatureName
-
Commit Your Changes
git commit -m "Add your message here"
-
Push to the Branch
git push origin feature/YourFeatureName
-
Open a Pull Request
Describe your changes and submit the pull request for review.
This project is licensed under the MIT License. You are free to use, modify, and distribute this software as per the terms of the license.
- Python Community: For providing excellent libraries and resources.
- ipywidgets Documentation: For comprehensive guides on building interactive widgets.
- Matplotlib Documentation: For detailed tutorials on creating dynamic visualizations.
- OpenAI: For the GPT-4 model that assisted in developing project documentation.
Hassan Ali Khan
📧 armanashraf015@gmail.com
🔗 GitHub - Water-Bucket-Puzzle
🔗 LinkedIn
Feel free to reach out for any questions, feedback, or collaboration opportunities!