https://github.com/sleekpanther/mastermind-game
Command line implementation of the board game Mastermind for a Software Engineering class
https://github.com/sleekpanther/mastermind-game
knuth knuth-algorithm mastermind mastermind-board-game mastermind-game noah noah-patullo noahpatullo pattullo pattulo patullo patulo software-engineering
Last synced: about 2 months ago
JSON representation
Command line implementation of the board game Mastermind for a Software Engineering class
- Host: GitHub
- URL: https://github.com/sleekpanther/mastermind-game
- Owner: SleekPanther
- Created: 2018-01-24T14:40:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-13T23:15:28.000Z (about 7 years ago)
- Last Synced: 2025-01-23T18:19:38.270Z (3 months ago)
- Topics: knuth, knuth-algorithm, mastermind, mastermind-board-game, mastermind-game, noah, noah-patullo, noahpatullo, pattullo, pattulo, patullo, patulo, software-engineering
- Language: Java
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mastermind
Command line implementation of the board game Mastermind for a Software Engineering class## Algorithm
An adaptation of the [Knuth Algorithm](https://en.wikipedia.org/wiki/Mastermind_(board_game)#Algorithms)1. The computer generates all possible 4-character code of unique colors
2. Picks a random code from these possibilities & calls an evaluation function feedback
3. It then loops over all remaining possibilities, calls the evaluation function & compares the new feedback to the feedback from the 1st guess eliminating all possibilities that give different feedback. (e.g. if the evaluation function returns "2 correct color & location" and "1 correct color, incorrect location" it removes all codes that don't give the feedback 2 & 1).
4. Go back to step 2, pick another code from remaining possibilities & evaluate all other possibilities eliminating the ones that score the same. This continues until it's the correct code or the game runs out of guesses.