-
Notifications
You must be signed in to change notification settings - Fork 3
ckloote/Mastermind
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Mastermind This is an implementation of the classic board game "Mastermind", in Java/Swing. Compilation: javac Mastermind/*.java Jar Creation: jar cfm Mastermind.jar Mainfest.txt Mastermind/*.class Jar Execution: java -jar Mastermind.jar 1) On load, the game asks the player if they would like to play as the codebreaker, trying to guess a code generated by the computer, or the codemaker, creating a code which the computer will then try to guess. 2) Codebreaker: The computer randomly selects a sequence of four colors, randomly chosen from six possibilities: Red, blue, green, yellow, orange, and purple. (This means the number of possible codes are 6^4, or 1296). The player gets 10 attempts to guess the code, working from the bottom of the board to the top. Clicking a circle will cause it to change colors, cycling through the six possibilities. Once the player has selected their initial guess, clicking "Enter" will submit it to the computer. The computer will then provide the player with clues telling them how close the are to the actual code. For each player selection that is the correct color in the correct place, the computer will activate a black circle to the left of the code guess. For each selection which is a correct color in the wrong place, a white circle will be activated. For example: Key: Red-Blue-Green-Yellow Guess: Blue-Purple-Orange-Yellow The blue matches color, but in the wrong location, and will be scored white. The yellow matches both color and location, and will be scored black. Purple and orange are completely wrong guesses, and will not be scored at all. If the player matches the key in 10 guesses, it's a win. If not, a loss. 3) Codemaker: Instead of entering a guess, the player enters a code at the top of the screen in the same fashion. After pressing enter, the computer will attempt to guess the code as the player did, with the guesses being scored the same way and the computer using this information to formulate its future guesses. Note that the computer is very efficient at guessing and should always guess the code in at most five guesses. 4) After a completed game, the player is given the option to play again. If "no" is selected, the program ends. If "yes" is selected, the game restarts from the beginning, asking the user to choose codemaker or codebreaker again.
About
Implementation of Mastermind game in Java/Swing
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published