Conversation
…e, Discord Bot, ML Image Classifier, and RL Game Agent
Removed beginner and intermediate project sections from the README.
There was a problem hiding this comment.
Pull request overview
This pull request adds six new Python project examples to the repository across different difficulty levels. The projects range from a simple Hangman game to advanced reinforcement learning and machine learning implementations. The README has been updated to include descriptions of all new projects, and the difficulty level "Expert" has been added.
Changes:
- Added "Expert" difficulty tier to the project collection
- Added 6 new project implementations: Hangman, Todo List Manager, Chess Game, Discord Bot, Machine Learning Image Classifier, and Reinforcement Learning Game Agent
- Renumbered existing projects in README to accommodate new additions
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 26 comments.
Show a summary per file
| File | Description |
|---|---|
| Readme.md | Updated to include new Expert tier, added descriptions for 6 new projects, renumbered existing projects |
| Easy/26_Hangman.py | Word guessing game with ASCII art hangman display |
| Medium/19_Todo_List_Manager.py | Command-line task manager with JSON persistence |
| Medium/20_Chess_Game.py | Two-player chess implementation with move validation |
| Medium/todo_list.json | Sample data file for todo list manager |
| Hard/25_Discord_Bot.py | Feature-rich Discord bot with multiple commands |
| Hard/25_Discord_Bot_requirements.txt | Dependencies for Discord bot |
| Hard/26_Machine_Learning_Image_Classifier.py | CNN for MNIST digit classification |
| Hard/26_Machine_Learning_Image_Classifier_requirements.txt | Dependencies for ML classifier |
| Expert/26_Reinforcement_Learning_Game_Agent/main.py | Entry point for RL tic-tac-toe agent |
| Expert/26_Reinforcement_Learning_Game_Agent/game.py | Tic-tac-toe game logic |
| Expert/26_Reinforcement_Learning_Game_Agent/agent.py | Q-learning agent implementation |
| Expert/26_Reinforcement_Learning_Game_Agent/requirements.txt | Dependencies for RL agent |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| game.print_board() | ||
|
|
||
| next_state, reward, done = game.make_move(action) | ||
| state = next_state | ||
|
|
||
| if not done: | ||
| print("\nYour turn:") | ||
| game.print_board() |
There was a problem hiding this comment.
The agent always plays first (as X) and the human always plays second (as O), but the game logic doesn't enforce turn order properly in the play method. If the agent wins on its first move or if there's any edge case, the human might not get a turn even though the message says "You go second." Consider checking if the game is over before prompting for human input.
| game.print_board() | |
| next_state, reward, done = game.make_move(action) | |
| state = next_state | |
| if not done: | |
| print("\nYour turn:") | |
| game.print_board() | |
| next_state, reward, done = game.make_move(action) | |
| state = next_state | |
| game.print_board() | |
| if not done: | |
| print("\nYour turn:") |
| def is_valid_move(self, start, end): | ||
| start_row, start_col = self.algebraic_to_coords(start) | ||
| end_row, end_col = self.algebraic_to_coords(end) | ||
|
|
||
| if not (0 <= start_row < 8 and 0 <= start_col < 8 and 0 <= end_row < 8 and 0 <= end_col < 8): | ||
| return False | ||
|
|
||
| piece = self.board[start_row][start_col] | ||
| if piece == ' ': | ||
| return False | ||
|
|
||
| # Check if it's the correct player's turn | ||
| if self.current_player == 'white' and piece.islower(): | ||
| return False | ||
| if self.current_player == 'black' and piece.isupper(): | ||
| return False | ||
|
|
||
| # Basic move validation (simplified) | ||
| if piece.upper() == 'P': # Pawn | ||
| return self.is_valid_pawn_move(start_row, start_col, end_row, end_col, piece) | ||
| elif piece.upper() == 'R': # Rook | ||
| return self.is_valid_rook_move(start_row, start_col, end_row, end_col) | ||
| elif piece.upper() == 'N': # Knight | ||
| return self.is_valid_knight_move(start_row, start_col, end_row, end_col) | ||
| elif piece.upper() == 'B': # Bishop | ||
| return self.is_valid_bishop_move(start_row, start_col, end_row, end_col) | ||
| elif piece.upper() == 'Q': # Queen | ||
| return self.is_valid_queen_move(start_row, start_col, end_row, end_col) | ||
| elif piece.upper() == 'K': # King | ||
| return self.is_valid_king_move(start_row, start_col, end_row, end_col) | ||
|
|
||
| return False |
There was a problem hiding this comment.
The move validation doesn't check if the destination square contains a piece of the same color before allowing the move. A player could potentially capture their own pieces. Consider adding a check to ensure the destination piece (if any) belongs to the opponent.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| choice = input("Enter your choice: ") | ||
|
|
||
| if choice == "1": | ||
| episodes = int(input("Enter number of training episodes (default 10000): ") or "10000") |
There was a problem hiding this comment.
The code uses int(input(...) or "10000") which will raise a ValueError if the user enters a non-numeric value other than an empty string. For example, if a user enters "abc", this will crash. Consider wrapping this in a try-except block or validating the input before conversion.
| episodes = int(input("Enter number of training episodes (default 10000): ") or "10000") | |
| while True: | |
| episodes_input = input("Enter number of training episodes (default 10000): ") | |
| if not episodes_input: | |
| episodes_input = "10000" | |
| try: | |
| episodes = int(episodes_input) | |
| break | |
| except ValueError: | |
| print("Invalid number. Please enter a valid integer.") |
| ### #28 - Discord Bot | ||
|
|
||
| A feature-rich Discord bot with commands for games, utilities, server information, and user management. |
There was a problem hiding this comment.
There's a discrepancy between the filename numbering and the README numbering. The README lists this as "#28 - Discord Bot", but the file is named "25_Discord_Bot.py". This inconsistency could confuse users trying to match projects in the README with their corresponding files. Consider either renumbering the file to "28_Discord_Bot.py" or updating the README to reference "#25".
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Easy
Hangman.py
Medium
Todo_List_Manager.py
Chess_Game.py
Hard
Discord_Bot.py
Discord_Bot_requirements.txt
Machine_Learning_Image_Classifier.py
Expert
Reinforcement_Learning_Game_Agent