From 081f55f09d4b3aeae6e20a15069320d93e21f3fb Mon Sep 17 00:00:00 2001 From: V Pratheek Date: Mon, 28 Oct 2024 18:27:11 +0530 Subject: [PATCH 1/2] Added the Memory Typing Game --- Game_Development/Memory Typing Game/README.md | 156 ++++++++++++++++++ Game_Development/Memory Typing Game/main.py | 79 +++++++++ 2 files changed, 235 insertions(+) create mode 100644 Game_Development/Memory Typing Game/README.md create mode 100644 Game_Development/Memory Typing Game/main.py diff --git a/Game_Development/Memory Typing Game/README.md b/Game_Development/Memory Typing Game/README.md new file mode 100644 index 0000000000..de4c18df65 --- /dev/null +++ b/Game_Development/Memory Typing Game/README.md @@ -0,0 +1,156 @@ +# Memory Typing Game ⌨️ + +This is an engaging **Python-based command-line** implementation of a **Memory Typing Game**. Test and improve your typing skills by memorizing and reproducing displayed text within a time limit. Challenge yourself with different difficulty levels and various text categories! + +--- + +## 🎯 Objective + +The goal is to accurately type the displayed text after it disappears from the screen. The game tests both your memory and typing speed while helping you improve your typing accuracy and recall abilities. + +--- + +## 🚀 How to Play + +1. **Start the Game**: Launch the Python script to begin. +2. **Choose Difficulty**: Select your preferred difficulty level: + - Easy: Shorter texts, longer display time (10 seconds) + - Medium: Moderate length texts, standard display time (7 seconds) + - Hard: Longer texts, shorter display time (5 seconds) +3. **Memorize Text**: A text snippet will appear for a limited time. +4. **Type from Memory**: After the text disappears, type what you remember. +5. **View Results**: Receive feedback on: + - Typing accuracy (%) + - Words per minute (WPM) + - Time taken +6. **Progress**: Track your improvement over multiple rounds. + +--- + +## 🛠 System Requirements + +- **Operating System**: Any system running Python 3.x +- **Python Version**: Python 3.x or higher + +### Dependencies + +```bash +pip install colorama # For colored terminal output +pip install difflib # For text comparison +``` + +--- + +## 🔧 How to Run + +1. Clone the repository and navigate to the project folder: + ```bash + git clone + cd memory-typing-game + ``` + +2. Install required dependencies: + ```bash + pip install -r requirements.txt + ``` + +3. Run the game: + ```bash + python3 memory_typing_game.py + ``` + +--- + +## 📚 Game Mechanics + +- **Text Generation**: + - Random selection from various categories (quotes, facts, sentences) + - Difficulty-appropriate length selection + - No repetition within same session + +- **Scoring System**: + - Accuracy: Calculated using difflib sequence matcher + - Speed: Words per minute calculation + - Time Bonus: Extra points for quick completion + - Perfect Match Bonus: Additional points for 100% accuracy + +- **Performance Tracking**: + - Session high scores + - Personal best records + - Progress statistics + +--- + +## 💻 System Specifications + +- Python Version: 3.x+ +- Required Space: < 10MB +- Memory Usage: Minimal (~50MB) +- Terminal: Any terminal with Unicode support + +--- + +## 📖 Features + +### Core Features +- Multiple difficulty levels +- Various text categories +- Real-time typing feedback +- Performance statistics +- Progress tracking + +### Game Modes +1. **Classic Mode**: Standard memory typing challenge +2. **Time Attack**: Reduced display time for each successful round +3. **Marathon**: Consecutive challenges with increasing difficulty +4. **Practice Mode**: No time limit, focus on accuracy + +--- + +## 🤔 Tips for Success + +1. **Memory Techniques**: + - Break text into meaningful chunks + - Create mental associations + - Focus on key words first + +2. **Typing Tips**: + - Maintain proper hand positioning + - Focus on accuracy over speed + - Practice regular finger exercises + +3. **Strategy**: + - Start with easier levels + - Gradually increase difficulty + - Take short breaks between rounds + - Review mistakes after each attempt + +--- + +## 🔄 Future Updates + +- Online leaderboard +- Custom text categories +- Multiplayer mode +- Advanced statistics +- Achievement system +- Custom difficulty settings + +--- + +## 🐛 Troubleshooting + +- **Display Issues**: Ensure terminal supports Unicode +- **Performance Lag**: Close resource-heavy applications +- **Text Not Showing**: Check terminal color support +- **Score Not Saving**: Verify write permissions + +--- + +## 📝 Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change. + +--- + +Enjoy improving your typing and memory skills with the Memory Typing Game! 🎯✨ \ No newline at end of file diff --git a/Game_Development/Memory Typing Game/main.py b/Game_Development/Memory Typing Game/main.py new file mode 100644 index 0000000000..1e6fc778d0 --- /dev/null +++ b/Game_Development/Memory Typing Game/main.py @@ -0,0 +1,79 @@ +import os +import time +import random + +def clear_screen(): + """Clear the terminal screen""" + os.system('cls' if os.name == 'nt' else 'clear') + +def calculate_accuracy(original, typed): + """Calculate typing accuracy as a percentage""" + if len(original) == 0: + return 0 + + correct = sum(1 for a, b in zip(original, typed) if a == b) + return round((correct / len(original)) * 100, 2) + +def get_random_text(): + """Return a random text for typing practice""" + texts = [ + "The quick brown fox jumps over the lazy dog", + "Programming is fun and rewarding", + "Practice makes perfect", + "Python is a versatile programming language", + "Keep calm and keep coding", + "Learning to type faster takes practice" + ] + return random.choice(texts) + +def play_game(): + """Main game function""" + score = 0 + rounds_played = 0 + + while True: + clear_screen() + print("\n=== Memory Typing Game ===") + print("\nRemember the text and type it exactly!") + print("You'll have 3 seconds to memorize.") + input("\nPress Enter when ready...") + + # Get random text and display it + text_to_type = get_random_text() + clear_screen() + print("\nMemorize this text:") + print(f"\n{text_to_type}") + + # Wait 3 seconds + time.sleep(3) + + # Clear screen and get user input + clear_screen() + print("\nNow type the text:") + user_input = input("\n> ") + + # Calculate accuracy + accuracy = calculate_accuracy(text_to_type, user_input) + + # Update score + rounds_played += 1 + if accuracy == 100: + score += 1 + + # Show results + print(f"\nOriginal text: {text_to_type}") + print(f"Your typing: {user_input}") + print(f"\nAccuracy: {accuracy}%") + print(f"Perfect rounds: {score}/{rounds_played}") + + # Ask to play again + play_again = input("\nPlay again? (y/n): ").lower() + if play_again != 'y': + break + + # Show final score + print(f"\nFinal Score: {score}/{rounds_played} perfect rounds") + print("Thanks for playing!") + +if __name__ == "__main__": + play_game() \ No newline at end of file From a12067cf27111a950c3c724b44df88b9b27e9c95 Mon Sep 17 00:00:00 2001 From: pratheekv39 Date: Mon, 28 Oct 2024 12:58:04 +0000 Subject: [PATCH 2/2] updating Project-Structure.md --- Project-Structure.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Project-Structure.md b/Project-Structure.md index 40b4d54aa2..aad4d6e265 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -510,6 +510,8 @@ * [Mastermind](Game_Development/MasterMind/mastermind.py) * Maze * [Maze](Game_Development/Maze/Maze.py) + * Memory Typing Game + * [Main](Game_Development/Memory%20Typing%20Game/main.py) * Number Guessing Game * [Main](Game_Development/Number%20Guessing%20Game/main.py) * Pig Dice Game