Skip to content
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
68 changes: 68 additions & 0 deletions Algorithms and Deep Learning Models/ai-typing-game/ai-typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import random
import time

# Word lists for different difficulty levels
easy_words = ['cat', 'dog', 'sun', 'book', 'tree', 'car', 'bird']
medium_words = ['elephant', 'giraffe', 'balloon', 'umbrella', 'vacation']
hard_words = ['substitution', 'enlightenment', 'interrogation', 'psychological', 'astronomy']

# Function to select a random word based on difficulty
def generate_word(level):
if level == 'Easy':
return random.choice(easy_words)
elif level == 'Medium':
return random.choice(medium_words)
elif level == 'Hard':
return random.choice(hard_words)

# Function to adjust difficulty based on score
def adjust_difficulty(score):
if score >= 50 and score < 100:
return 'Medium'
elif score >= 100:
return 'Hard'
else:
return 'Easy'

# Function to run the typing game
def start_game():
score = 0
level = 'Easy'

print("Welcome to the AI-Powered Typing Game!\n")
print("Instructions:")
print("Type the given word correctly to score points.")
print("Difficulty will increase as your score increases.\n")

# Main game loop
for round_num in range(10): # Number of rounds (10 in this example)
print(f"\nRound {round_num + 1}: Difficulty Level - {level}")
word_to_type = generate_word(level)
print(f"Type this word: {word_to_type}")

start_time = time.time() # Start the timer
user_input = input("Your input: ")

# Check if the user typed the correct word
if user_input.lower() == word_to_type.lower():
time_taken = time.time() - start_time
score += 10 # Increase score for correct input
print(f"Correct! You took {time_taken:.2f} seconds.")
print(f"Your score: {score}")
else:
print("Incorrect! Try harder next time.")

# Adjust the difficulty based on score
level = adjust_difficulty(score)

print("\nGame Over!")
print(f"Your final score: {score}")
if score >= 100:
print("You're a typing master!")
elif score >= 50:
print("Good job! Keep practicing!")
else:
print("Keep trying! You'll get better.")

# Run the game
start_game()
56 changes: 56 additions & 0 deletions Algorithms and Deep Learning Models/ai-typing-game/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# AI-Powered Typing Game

This is a simple AI-powered typing game written in pure Python. The game challenges players to type words correctly to score points. The difficulty level increases as the score improves, making the game progressively harder.

## How to Play

1. You will be given a word to type, starting at an **Easy** difficulty level.
2. Type the word exactly as shown (case-insensitive) and press Enter.
3. If you type the word correctly, you will score 10 points.
4. The game consists of 10 rounds, and the difficulty will increase as follows:
- **Easy**: 0 - 49 points
- **Medium**: 50 - 99 points
- **Hard**: 100+ points
5. At the end of the game, your final score will be displayed, and you'll get feedback based on your performance.

## Running the game
1. Download the ai-typing.py file.
2. Run the game using the following command:
python ai-typing.py
3. Enjoy playing!


## Game Features

- The game adjusts difficulty dynamically as the player progresses.
- Timed responses show how long it took you to type the word (though it doesn’t affect your score).
- Encouraging feedback at the end of the game based on your total score:
- **100+ points**: Typing master!
- **50 - 99 points**: Good job!
- **0 - 49 points**: Keep practicing!

## Example Gameplay

```bash
Welcome to the AI-Powered Typing Game!

Instructions:
Type the given word correctly to score points.
Difficulty will increase as your score increases.

Round 1: Difficulty Level - Easy
Type this word: cat
Your input: cat
Correct! You took 1.23 seconds.
Your score: 10

Round 2: Difficulty Level - Easy
Type this word: dog
Your input: doog
Incorrect! Try harder next time.

...

Game Over!
Your final score: 70
Good job! Keep practicing!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Python 3.x

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"vscode-test": "^1.6.1"
},
"dependencies": {
"axios": "^1.7.3"
"axios": "^1.7.3",
"my-ext": "file:"
}
}
7 changes: 6 additions & 1 deletion Website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"dotenv": "^16.4.5",
"express": "^4.19.2",
"node-fetch": "^3.3.2"
"node-fetch": "^3.3.2",
"server": "file:"
}
}
Loading