This project is a C implementation of the "Evil Hangman" game, where the computer cheats by dynamically changing the word it's "thinking of" to make the game as difficult as possible for the player. The game uses advanced data structures including generic vectors and binary search trees to efficiently manage word families during gameplay.
- Generic Vector Implementation: A reusable generic vector data structure that can store any type of data (void pointers)
- String Library: Custom string implementation with dynamic resizing and common string operations
- Word Family Management: Uses binary search trees to organize words into families based on letter patterns
- Interactive Gameplay:
- Configurable word length
- Adjustable number of guesses
- Visual feedback of guessed letters and current word state
- Input validation
- Generic Vector:
- Dynamic array implementation
- Handles any data type through void pointers
- Includes assignment and destruction callbacks for proper memory management
- Binary Search Tree:
- Used to organize word families during gameplay
- Nodes contain word patterns and vectors of matching words
- String Implementation:
- Dynamic character array
- Automatic resizing
- Common string operations (concatenation, comparison, etc.)
- Reads dictionary file and organizes words by length
-Creates initial word family based on user-selected word length
- For each guess:
1. Divides current word family into sub-families based on letter positions
2. Selects the largest family (making the game as hard as possible)
3. Updates display based on whether the guess was "correct"
- Continues until player wins or loses
- The computer doesn't actually pick a word initially
- Instead, it maintains the largest possible set of words that match all previous guesses
- Only "chooses" a specific word when the player wins or loses
- Clone the repository
- Run make to compile
- Execute the program with
./string_driver
- The program expects a dictionary.txt file in the same directory.
- C compiler (tested with gcc)
- Make utility
- Dictionary file (included in repository)
- generic_vector.c/h: Generic vector implementation
- my_string.c/h: Custom string implementation
- main.c: Game logic and user interface
- status.h: Status codes and boolean type
- generic.h: Generic type definitions
- Makefile: Build configuration
- dictionary.txt: Word list
- Limited error handling for file operations
- No difficulty settings (always uses hardest possible strategy)
- Add graphical interface
- Implement difficulty levels
- Add word definition display at game end
- Support for multiple dictionary formats
Meeps-Underflow
