Problem Statement
Design and implement a Crossword Word Building Game in Python. The game involves answering a general knowledge question, building a word character by character, and creating new words based on specific rules. The game continues in rounds until the user exits, with a scoring system and validation to ensure rules are followed.
Assignment Requirements
-
Question & Answer Input
- Display a general knowledge question (e.g., "What is the national animal of India?").
- Prompt the user to specify the maximum character length of the answer.
- Collect the answer character by character, ensuring it matches the specified length.
- Display the complete answer and validate it against the correct answer.
- End the game with the correct answer if the user’s answer is incorrect.
-
Character Selection
- Prompt the user to select one character from the current word (initially the answer, later the new word).
- Validate that the chosen character is a single character present in the current word.
-
Word Creation Rules
- The user must form a new word that:
- Contains the selected character.
- Includes at least one character not in the previous word.
- Is at least as long as the previous word.
- Example: If the previous word is "TIGER" (5 letters) and the chosen character is "I", a valid new word is "INJECTION" (contains "I", has new characters, ≥ 5 letters), but "INK" is invalid (too short).
-
Validation Logic
- Validate new words to ensure they meet all rules.
- Display error messages for invalid words (e.g., missing chosen character, too short, no new characters) and prompt for retry.
- Prevent duplicate words (words already used in the game).
-
Scoring System
- Award points for valid words:
- Base points for a valid word.
- Bonus points if the new word is at least 2 characters longer than the previous word.
- Display the running score after each valid word.
-
Game Continuation
- After each valid word, ask the user to continue or exit.
- If continuing, prompt for a new character from the latest word and form a new word.
- On exit, display:
- List of all words used.
- Final score.
-
Bonus Requirement
- Store used words in a list and prevent duplicates.
- Display the list of used words at the end.
Input/Output Example
Welcome to the Crossword Word Building Game!
Q: What is the national animal of India?
Enter the maximum character length of the answer: 5
Enter the answer character by character (max 5 characters):
Character 1: T
Character 2: I
Character 3: G
Character 4: E
Character 5: R
Answer → TIGER
Choose a character from 'TIGER': I
Make a new word using 'I': Injection
✅ Valid! Score updated.
Total Score = 7
Do you want to continue? (yes/no): yes
Choose a character from 'INJECTION': N
Make a new word using 'N': Nation
✅ Valid! Score updated.
Total Score = 12
Do you want to continue? (yes/no): yes
Choose a character from 'NATION': A
Make a new word using 'A': Ant
❌ Error: New word must be at least 6 characters long.
Try again: Another
✅ Valid! Score updated.
Total Score = 17
Do you want to continue? (yes/no): no
Game Over.
Words used: ['TIGER', 'INJECTION', 'NATION', 'ANOTHER']
Final Score = 17
Assignment Tasks
-
Implementation
Write a Python program implementing the full game logic. Handle user inputs robustly (e.g., invalid characters, incorrect answer lengths).
-
Scoring System
Implement the scoring system with base and bonus points. Display the score after each valid word.
-
Validation Logic
Validate words to reject invalid entries with clear error messages and retry prompts.
-
Bonus: Duplicate Prevention
Store used words in a list to prevent duplicates and display the list at the end.
Notes
- Include at least 4 predefined general knowledge questions and answers for testing.
- Treat inputs as case-insensitive (e.g., "Tiger" and "TIGER" are the same).
- Handle invalid inputs gracefully (e.g., non-single characters, invalid words).
- Assume words are valid English words without requiring a dictionary check.
.
Problem Statement
Design and implement a Crossword Word Building Game in Python. The game involves answering a general knowledge question, building a word character by character, and creating new words based on specific rules. The game continues in rounds until the user exits, with a scoring system and validation to ensure rules are followed.
Assignment Requirements
Question & Answer Input
Character Selection
Word Creation Rules
Validation Logic
Scoring System
Game Continuation
Bonus Requirement
Input/Output Example
Assignment Tasks
Implementation
Write a Python program implementing the full game logic. Handle user inputs robustly (e.g., invalid characters, incorrect answer lengths).
Scoring System
Implement the scoring system with base and bonus points. Display the score after each valid word.
Validation Logic
Validate words to reject invalid entries with clear error messages and retry prompts.
Bonus: Duplicate Prevention
Store used words in a list to prevent duplicates and display the list at the end.
Notes
.