From 602df6e4a5ea03bf71f4c5e2b516c9de367c295a Mon Sep 17 00:00:00 2001 From: sanika1345 <153575361+sanika1345@users.noreply.github.com> Date: Wed, 23 Oct 2024 06:38:14 +0530 Subject: [PATCH] added ai-typing game --- .../ai-typing-game/ai-typing.py | 68 +++++++++++++++++++ .../ai-typing-game/readme.md | 56 +++++++++++++++ .../ai-typing-game/requirments.txt | 1 + .../package-lock.json | 7 +- .../package.json | 3 +- Website/package-lock.json | 7 +- Website/package.json | 3 +- 7 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 Algorithms and Deep Learning Models/ai-typing-game/ai-typing.py create mode 100644 Algorithms and Deep Learning Models/ai-typing-game/readme.md create mode 100644 Algorithms and Deep Learning Models/ai-typing-game/requirments.txt diff --git a/Algorithms and Deep Learning Models/ai-typing-game/ai-typing.py b/Algorithms and Deep Learning Models/ai-typing-game/ai-typing.py new file mode 100644 index 000000000..83ee1571e --- /dev/null +++ b/Algorithms and Deep Learning Models/ai-typing-game/ai-typing.py @@ -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() diff --git a/Algorithms and Deep Learning Models/ai-typing-game/readme.md b/Algorithms and Deep Learning Models/ai-typing-game/readme.md new file mode 100644 index 000000000..5c7b1e6bc --- /dev/null +++ b/Algorithms and Deep Learning Models/ai-typing-game/readme.md @@ -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! diff --git a/Algorithms and Deep Learning Models/ai-typing-game/requirments.txt b/Algorithms and Deep Learning Models/ai-typing-game/requirments.txt new file mode 100644 index 000000000..da77e16f4 --- /dev/null +++ b/Algorithms and Deep Learning Models/ai-typing-game/requirments.txt @@ -0,0 +1 @@ +Python 3.x diff --git a/Generative AI & LLMs/LLM Copilot Ext for VS Code IDE/package-lock.json b/Generative AI & LLMs/LLM Copilot Ext for VS Code IDE/package-lock.json index 3d08dbcbc..f9bcd98b1 100644 --- a/Generative AI & LLMs/LLM Copilot Ext for VS Code IDE/package-lock.json +++ b/Generative AI & LLMs/LLM Copilot Ext for VS Code IDE/package-lock.json @@ -8,7 +8,8 @@ "name": "my-ext", "version": "0.0.1", "dependencies": { - "axios": "^1.7.3" + "axios": "^1.7.3", + "my-ext": "file:" }, "devDependencies": { "@types/node": "20.x", @@ -1240,6 +1241,10 @@ "dev": true, "license": "MIT" }, + "node_modules/my-ext": { + "resolved": "", + "link": true + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", diff --git a/Generative AI & LLMs/LLM Copilot Ext for VS Code IDE/package.json b/Generative AI & LLMs/LLM Copilot Ext for VS Code IDE/package.json index 8acd2bb0f..e9e674f18 100644 --- a/Generative AI & LLMs/LLM Copilot Ext for VS Code IDE/package.json +++ b/Generative AI & LLMs/LLM Copilot Ext for VS Code IDE/package.json @@ -34,6 +34,7 @@ "vscode-test": "^1.6.1" }, "dependencies": { - "axios": "^1.7.3" + "axios": "^1.7.3", + "my-ext": "file:" } } diff --git a/Website/package-lock.json b/Website/package-lock.json index 8790fa30a..b481786fe 100644 --- a/Website/package-lock.json +++ b/Website/package-lock.json @@ -11,7 +11,8 @@ "dependencies": { "dotenv": "^16.4.5", "express": "^4.19.2", - "node-fetch": "^3.3.2" + "node-fetch": "^3.3.2", + "server": "file:" } }, "node_modules/accepts": { @@ -753,6 +754,10 @@ "node": ">= 0.8.0" } }, + "node_modules/server": { + "resolved": "", + "link": true + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", diff --git a/Website/package.json b/Website/package.json index 79a988322..abd23ab45 100644 --- a/Website/package.json +++ b/Website/package.json @@ -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:" } }