{"id":26821588,"url":"https://github.com/mattlean/hangman-game-solver","last_synced_at":"2026-04-16T18:31:44.233Z","repository":{"id":71582770,"uuid":"237542525","full_name":"mattlean/hangman-game-solver","owner":"mattlean","description":"Hangman for command line with bruteforce solver bot","archived":false,"fork":false,"pushed_at":"2020-02-03T06:28:27.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T07:31:56.657Z","etag":null,"topics":["bot","es2015","game","javascript","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattlean.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-01T01:02:13.000Z","updated_at":"2020-05-30T06:30:02.000Z","dependencies_parsed_at":"2023-05-18T05:15:53.406Z","dependency_job_id":null,"html_url":"https://github.com/mattlean/hangman-game-solver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mattlean/hangman-game-solver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fhangman-game-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fhangman-game-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fhangman-game-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fhangman-game-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattlean","download_url":"https://codeload.github.com/mattlean/hangman-game-solver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fhangman-game-solver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266287824,"owners_count":23905461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","es2015","game","javascript","nodejs"],"created_at":"2025-03-30T07:31:26.196Z","updated_at":"2026-04-16T18:31:39.200Z","avatar_url":"https://github.com/mattlean.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hangman Game \u0026 Solver\n## About\nThis project is a Hangman game played through the command-line alongside a solver bot.\n\nThis was inspired by an [assignment from Stanford's CS 106A: Programming Methodologies class](https://web.stanford.edu/class/archive/cs/cs106a/cs106a.1124/handouts/200%20Assignment%204.pdf) and a [challenge from Code Golf Stack Exchange](https://codegolf.stackexchange.com/questions/25496/write-a-hangman-solver). The main differences are that the project is coded in JavaScript instead of Java, there are no graphics, and the solver does not actually use the game program code supplied by the Code Golf Stack Exchange post although it does still roughly follow the same rules.\n\n## Playing the Game\nThis is the command for running the game:\n```\nnode hangman [-dhr] [lexicon_text_file ...]\n```\n\nSo a simple example of this is:\n```\nnode hangman lexiconA.txt\n```\n\n### Rules\nThe game follows the following rules:\n- By default, the game will give the player 8 tries to guess the word.\n- Each word is randomly selected from a pool of words determined in the lexicon text file.\n- Guessing an incorrect letter will decrement the amount of remaining guesses by 1.\n- Guessing a new correct letter will not change the amount of remaining guesses.\n- Guessing an already found correct letter will also not change the amount of remaining guesses.\n- Only 1 character can be guessed at a game.\n- The game ends when all letters in the answer are correctly guessed or when 0 guesses remain.\n\n### Lexicon\nA valid lexicon file must have the following properties:\n- Must be a text file.\n- Each line must contain only one word.\n- Words can only be comprised of alphabetical characters.\n\nThe project comes with two premade lexicon files:\n- [lexiconA.txt](./lexiconA.txt): Taken from the CS 106A assignment. Contains 10 words.\n- [lexiconB.txt](./lexiconB.txt): Taken from the Code Golf Stack Exchange challenge. Contains 4096 words.\n\n### Options\n| Character | Description                                                                   |\n|-----------|-------------------------------------------------------------------------------|\n| **d**     | Activate debug mode. Logs extra information to the terminal.                  |\n| **h**     | Activate hard mode. Reduces the amount of guesses from 8 to 6.                |\n| **r**     | Activate rush mode. Play through a randomized sequence of the entire lexicon. |\n\n## Running the Solver\nThis is the command for running the solver bot:\n```\nnode hangmanSolver [-d] [lexicon_text_file ...]\n```\n\nSo a simple example of this is:\n```\nnode hangmanSolver lexiconB.txt\n```\n\n### How It Works\nThe solver bot runs the Hangman game in hard and rush mode, so it will need to solve all of the words in the given lexicon and only have 6 tries per word.\n\nTo prevent cheating, the solver does not read the lexicon, it is not allowed to know what the answer is, and the order of played words from the lexicon is randomized.\n\nThe algorithm uses a very rudimentary bruteforce strategy where for the first 2 guesses it will always guess a vowel (A, E, I, O, U, and never Y \\*sadface\\*). After that it will guess any letter from A to Z. It will never guess a letter that has already been tried.\n\nAfter the entire lexicon is played, a score showing the amount of correctly guessed words over the total amount of words played will show.\n\n### Options\n| Character | Description                                                                   |\n|-----------|-------------------------------------------------------------------------------|\n| **d**     | Activate debug mode. Logs extra information to the terminal.                  |\n\n## Code Structure\n- [hangman.js](./hangman.js): Main file which creates `HangmanGame` instance.\n- [HangmanGame.js](./HangmanGame.js): `HangmanGame` class that runs the game logic.\n- [HangmanLexicon.js](./HangmanLexicon.js): `HangmanLexicon` class that handles lexicon file parsing and selecting words for `HangmanGame` to use as answers.\n- [hangmanSolver.js](./HangmanSolver.js): Contains all Hangman solver bot code.\n- [SimpleCLIOptionMan.js](./SimpleCLIOptionMan.js): `SimpleCLIOptionMan` class which is a simple CLI option manager.\n- [util.js](./util.js): Some miscellaneous utility functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattlean%2Fhangman-game-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattlean%2Fhangman-game-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattlean%2Fhangman-game-solver/lists"}