Giter Site home page Giter Site logo

mastermind's Introduction

Mastermind

Classical Mastermind code braking game, where one player, the code keeper, creates a secret code and the other player, the code breaker, tries to guess the code based on feedback from the code keeper on each guess.

The code is composed of 4 pegs. Each peg can have 6 colors.

The code keepers gives feedback using black and white pegs. One black peg for each guess peg that has the correct color at the correct place. One white peg is given for each remaining guess peg with the right color but in the wrong place.

The code has been broken when the code keeper feedback is 4 black pegs.

For exaple:

code = cybm

guess = rrgg => blacks = 0, whites = 0
guess = bbcc => clacks = 0, whites = 2
guess = ccyy => blacks = 1, whites = 1
guess = cybm => blacks = 4

Use - CLI

This implementation has 4 game modes:

Role Mode 1 Mode 2 Mode 3 Mode 4
Code breaker computer computer human human
Code keeper computer human computer human

The default is Mode 1 - a non-iteractive automatic solver using Donald Knuth's algorithm.

To play the game iteractivelly, use the argument options -k to play as code keeer, and -b to play as code breaker. Note that passing both -k -b will lead to a game where the user has to input both the guesses and give feedback - in this case, wouldn't it be more fun to play on a piece of paper?

Use - GUI

A graphical interface, a very ugly and simple one at that, is implemented for the game.

This interface has 3 game modes: Auto, Breaker, Keeper. Just press A-B-K to switch between modes.

In Breaker mode, use the mouse to switch between colors for each peg. When you're happy with your guess, press P to play that round and get feedback on your guess.

In Auto mode, the computer will do the guess and give feedback, just press P to move on to new round.

The Keeper mode is not implemented.

Press R anytime to reset the board.

GUI

TODO

CLI

  • Implement game modes
  • Add command line arguments

GUI

  • Input code to be broken, for Auto and Breaker modes.
  • Show messages in the GUI rather than in the prompt.
  • Highlight active row
  • Implement use feedback

mastermind's People

Contributors

haphaeu avatar

Watchers

 avatar  avatar

Forkers

jesper-norgaard

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.