Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#883 Added the Memory Typing Game #903

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions Game_Development/Memory Typing Game/README.md
Original file line number Diff line number Diff line change
@@ -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 <repository-url>
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! 🎯✨
79 changes: 79 additions & 0 deletions Game_Development/Memory Typing Game/main.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 2 additions & 0 deletions Project-Structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading