diff --git a/Game_Development/Word Ladder Puzzle Game/README.md b/Game_Development/Word Ladder Puzzle Game/README.md new file mode 100644 index 0000000000..21e5bd0746 --- /dev/null +++ b/Game_Development/Word Ladder Puzzle Game/README.md @@ -0,0 +1,69 @@ +# Word Ladder Puzzle 🔤 + +This is a simple **HTML, CSS, and JavaScript-based web implementation** of the classic **Word Ladder Puzzle**. In this game, you need to transform one word into another by changing only one letter at a time, with each intermediate step being a valid word! + +## 🎯 Objective + +The goal is to transform the start word into the end word by creating a chain of valid words. Each word in the chain should differ by only one letter from the previous word. + +## 🚀 How to Play + +1. **Start the Game**: Open the `index.html` file in a web browser. +2. **Enter Words**: Input a start word and an end word in the respective fields. +3. **Begin the Puzzle**: Click the "Start Game" button. +4. **Make Word Changes**: Enter a new word that differs by one letter from the current word. +5. **Submit Your Word**: Click the "Submit" button to add your word to the chain. +6. **Receive Feedback**: After each submission, you'll get one of these responses: + * "Invalid word. Try again." if the word is not in the dictionary. + * "You can only change one letter at a time." if more than one letter was changed. + * "Congratulations! You've completed the word ladder!" if you reach the end word. +7. **Keep Transforming**: Continue changing words until you reach the end word. + +## 🛠 System Requirements + +* **Web Browser**: Any modern web browser (Chrome, Firefox, Safari, Edge) + +## Dependencies + +This game uses only HTML, CSS, and vanilla JavaScript, so no additional dependencies are required. + +## 🔧 How to Run + +1. Clone the repository and navigate to the project folder: + +``` +git clone +cd +``` + +2. Open the `index.html` file in your web browser. + +3. Enjoy playing the Word Ladder Puzzle! + +## 📚 Game Mechanics + +* **Word Validation**: The game checks if each word exists in its dictionary. +* **One-Letter Difference**: Each word must differ by only one letter from the previous word. +* **Word Chain**: The game displays the chain of words as you progress. +* **User Input**: You enter each new word in the input field. +* **Feedback**: The game provides immediate feedback on each word submission. + +## 💻 System Specifications + +* HTML5 +* CSS3 +* JavaScript (ES6+) +* Any modern web browser + +## 📖 Additional Information + +The Word Ladder Puzzle is an excellent way to enhance your vocabulary and practice lateral thinking. It's also a great introduction to basic web development concepts like DOM manipulation and event handling. + +## 🤔 Strategy Tips + +1. Focus on changing one letter at a time that gets you closer to the end word. +2. Sometimes, you may need to change a letter that doesn't seem to get you closer, to set up for future moves. +3. If you're stuck, try to think of words that are similar to your target word and work backwards. +4. Expand your vocabulary! The more words you know, the easier the game becomes. + +Enjoy playing the Word Ladder Puzzle! 🎉 \ No newline at end of file diff --git a/Game_Development/Word Ladder Puzzle Game/main.py b/Game_Development/Word Ladder Puzzle Game/main.py new file mode 100644 index 0000000000..d6326d68ba --- /dev/null +++ b/Game_Development/Word Ladder Puzzle Game/main.py @@ -0,0 +1,58 @@ +import random + +class WordLadderPuzzle: + def __init__(self): + self.words = set(self.load_words()) + + def load_words(self): + # In a real implementation, this would load from a file + return ['cat', 'cot', 'dot', 'dog', 'log', 'lag', 'bag', 'big', 'pig', 'pin', 'pan'] + + def get_neighbors(self, word): + return [w for w in self.words if self.is_neighbor(word, w)] + + def is_neighbor(self, word1, word2): + if len(word1) != len(word2): + return False + return sum(c1 != c2 for c1, c2 in zip(word1, word2)) == 1 + + def find_ladder(self, start, end): + if start not in self.words or end not in self.words: + return None + + queue = [(start, [start])] + visited = set() + + while queue: + (word, path) = queue.pop(0) + if word not in visited: + visited.add(word) + + if word == end: + return path + + for neighbor in self.get_neighbors(word): + if neighbor not in visited: + queue.append((neighbor, path + [neighbor])) + + return None + + def play(self): + print("Welcome to Word Ladder Puzzle!") + start = input("Enter the starting word: ").lower() + end = input("Enter the target word: ").lower() + + if len(start) != len(end): + print("Words must be of the same length.") + return + + ladder = self.find_ladder(start, end) + if ladder: + print(f"Found a ladder in {len(ladder) - 1} steps:") + print(" -> ".join(ladder)) + else: + print("No valid word ladder found.") + +if __name__ == "__main__": + game = WordLadderPuzzle() + game.play() \ No newline at end of file diff --git a/Project-Structure.md b/Project-Structure.md index 037e2b2332..5450e53835 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -479,6 +479,8 @@ * [Turtle Collection Game](Game_Development/Turtle%20Collection%20Game/Turtle%20Collection%20Game.py) * Visual Novel Code * [Novel](Game_Development/Visual_novel%20_code/Novel.py) + * Word Ladder Puzzle Game + * [Main](Game_Development/Word%20Ladder%20Puzzle%20Game/main.py) ## Generative-Ai * Code-Llm-Bot