Giter Site home page Giter Site logo

mastermind's Introduction

Mastermind

Mastermind is a game in which the player tries to guess a secret combination of colors. The combination is a sequence of four pegs; each peg can be one of six different colors. (It is possible that some of the pegs could be the same color). The player must guess the correct colors in the correct order in order to win.

Every time the player guesses, they are told two numbers: the number of pegs that are correct where they are, and the number of pegs that could be correct if they were moved to a different position. For instance, the picture below there is one peg in the right place and two in the wrong place. The remaining peg does not belong in the combination

Screen Shot 2022-06-10 at 12 56 07 AM

Notice each peg can only be paired with one other. Thus, in the picture below only one blue peg could be moved into a correct position, not both. Similarly the red peg could only be moved into one correct position, not both. This guess should be marked as having two pegs in the wrong place.

Screen Shot 2022-06-10 at 12 57 44 AM

The user continues to guess until he gets the correct combination. The goal is to get the correct combination in as few guesses as possible.

Mastermind Program

This C++ program allows the user to play Mastermind using numbers to represent colors. For instance, given 7 colors, then the numbers will 1 - 7.

Workflow

  • How many pegs must be between 2 and 8.
  • How many colors must be between 6 and 20.
  • If the user enters something out of bounds, the program will simply replace with the minimum value if too small or the maximum value if too large.

Demo

mastermind-demo

mastermind's People

Contributors

nestoralfaro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.