A python implementation of the hangman game. Complemented with a rule-based NLP system.
- Obtains a list of 5 to 7 letter words MIT's word API
- A word in randonly selected for the list
- User guesses the word, character by character but has length of word + 1 guess
- User can only put guess one letter at the time
- If chacracter is present in chosen word, position is replaced else asterisk remains in the position
- Words are displayed at each step
- Receives a random word
- Narrows down the se of words by length first
- Builds a table of frequencies for each letter
- Provides the most probable word
- If present, all positions where it belongs are revelead all words not containing the word are letter are discarded, even at the position they appear
- The word set are adjusted
- The frequency of each letter are calculated
- Steps 3 - 7 are repeated till the game is done
- Get a larger dictionary of words
- Build a GUI
- Currently the game has a global win/loss ratio of 42.199% / 57.801%
- This low win ratio can be attributed to the fact that we use a very small dictionary (10000 words). I think if you increase the size of the dictionary, the AI's accuracy would increase.
- Also currently, we are not guessinc words wrongly, only incompletely. I think, wrong guesses would also become more prevalent as we increase the dictionary size, especially for words who differ by just a letter, and one of those letters in more prevalent in the English langauge than the other.
-
Clone the repository
-
python -m venv env
-
source env/bin/actiavte (Linux or Mac) | source env/Scripts/activate (Windows)
-
pip install -r requirements.txt
- statistics: python main.py --stats
- ai player: python main.py --ai
- human player: python main.py --human
python -m unittest discover -v