Code Monkey home page Code Monkey logo

mastermind's Introduction

Mastermind

Project Description

Mastermind is a board game for two players. Simply, the first player is trying the guess the secret code given by the other player. The secret code is a sequence of colours, for example 4 colours. There are a number of attempts and with each attempt the player will receive a respond as a hint. There are two kinds of hints. First, right colour in the right position. Second, right colour but in the wrong position. Each hint will be represented as a colour. usually black and white. Black if both the colour and postion are right, on the other hand, white represents only a right colour.

In the project, the players will be the user and the computer. The user shall select the sequence of colours. The application shall check if the sequence is matched. The application shall show the respond as below:

  • If there is any matched colour and position, show a black circle.
  • if there is any matched colour only and position is wrong, show a white circle.
  • If there are no colours matched, show none.

Project Wireframe

Fig. 1: The home page

Fig. 2: The instructions page

Fig. 3: The main game page

Fig. 4: Case-1 when user wins

Fig. 5: The message shown when user wins

Fig. 6: Case-2 when user loses

Fig. 7: The message shown when user loses

Technologies Used

  • Wireframe tool
  • PL: HTML, CSS, JS
  • VS Code editor.
  • Chrome Developer tool.

Approach Taken

First Dealing with the board as arrays:

  • Array for the whole matrix.
  • Arrays for the hints/attempts that being updated depending on the round.

Cmputer shall check the entries for each round, and compare it with the secret code:

  • Compare the colour & postions in a single loop.
  • Compare the existance of the colour in a single loop.
  • Print out the hints if exist.

Then, the computer shall check the conditon of the win:

  • Check if the hints contins 4 blacks, if so, user wins.
  • And if the attempts ends with no 4 blacks gaind, the user loses.

After the game ends either by a win or loss, computer shall show the secret code.

Installation Instructions

$ git clone https://git.generalassemb.ly/manalshehri/Mastermind.git
$ cd Mastermind

Future Suggestion and Inhancment

  • Add levels: easy, normal and hard.
  • Store the user's score.
  • Enhance the user experience.

Resources

  • To understand the game more, check this video
  • You can play the game here

mastermind's People

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.