GithubHelp home page GithubHelp logo

minesweeper-cli's Introduction

minesweeper-CLI

This is a command line version of the well known Minesweeper game.

At the start the user gives the number of rows and cols and the level of difficulty.

The board is created and filled with mines and warning bells in the neighboring cells.

There are four levels of difficulty. At the first level we place at the board a number of mines equal to 1/8 * (number of squares), at the second 1/7 * (number of squares), at the third 1/6 * (number of squares) and at the fourth 1/5 * (number of squares).

At first all squares are closed and the player makes his first move. The player can enter 's' followed by a square position to open a square, 'm' to mark a square, 'h' to ask the game for help, 'w' to ask the game for wisdom and 'x' to exit the game.

If with the command 's' the player opens an empty square, all neighboring empty squares are opened recursively.

If with the command 'm' the player successfully marks a square with a mine, then the total amount of mines decreases.

The command 'h' shows a square that doesn't contain a mine.

The command 'w' shows the square that has the most empty neighboring cells.

If the player marks successfully all mine squares or if he opens all empty squares or bell squares except the ones with the mines, then he wins and a new game is started with both board dimensions increased by one. This will happen until the max dimensions are reached to which point the player has won and the game ends.

EXAMPLE of playing with 8x8 board and level 2 of difficulty(medium)

      --- Welcome! ---
      This is a command line version of the well known game minesweeper
      Enter the board dimensions
      The number of rows can't be less than 6
      and more than 50
      The number of cols can't be less than 6
      and more than 50
      Enter the number of rows:8
      Enter the number of cols:8
      Choose a level of difficulty:
      1.Easy
      2.Medium
      3.Hard
      4.Really Hard
      Enter an integer(1,2,3,4):2

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  #  #  #  #  #
      2 |  #  #  #  #  #  #  #  #
      3 |  #  #  #  #  #  #  #  #
      4 |  #  #  #  #  #  #  #  #
      5 |  #  #  #  #  #  #  #  #
      6 |  #  #  #  #  #  #  #  #
      7 |  #  #  #  #  #  #  #  #
      8 |  #  #  #  #  #  #  #  #

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 3,4
      
           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  #  #  #  #  #
      2 |  #  #  #  #  #  #  #  #
      3 |  #  #  #  2  #  #  #  #
      4 |  #  #  #  #  #  #  #  #
      5 |  #  #  #  #  #  #  #  #
      6 |  #  #  #  #  #  #  #  #
      7 |  #  #  #  #  #  #  #  #
      8 |  #  #  #  #  #  #  #  #

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 5,4

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  #  #  #  #  #
      2 |  #  #  #  #  #  #  #  #
      3 |  #  #  #  2  #  #  #  #
      4 |  #  #  #  #  #  #  #  #
      5 |  #  #  #  2  #  #  #  #
      6 |  #  #  #  #  #  #  #  #
      7 |  #  #  #  #  #  #  #  #
      8 |  #  #  #  #  #  #  #  #

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: h
      Try to open square 6,6 
      Make your move: s 6,6

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  #  #  #  #  #
      2 |  #  #  #  #  #  #  #  #
      3 |  #  #  #  2  #  #  #  #
      4 |  #  #  #  #  #  #  #  #
      5 |  #  #  #  2  #  #  #  #
      6 |  #  #  #  #  #  1  #  #
      7 |  #  #  #  #  #  #  #  #
      8 |  #  #  #  #  #  #  #  #

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: w

      Best square is 7,7
      Make your move: s 7,7

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  #  #  #  1  .
      2 |  #  #  #  #  #  #  1  .
      3 |  #  #  #  2  #  #  1  .
      4 |  #  #  #  #  #  #  1  .
      5 |  #  3  2  2  #  2  1  .
      6 |  #  1  .  1  #  1  .  .
      7 |  #  2  .  1  1  1  .  .
      8 |  #  1  .  .  .  .  .  .

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 2,2

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  #  #  #  1  .
      2 |  #  2  #  #  #  #  1  .
      3 |  #  #  #  2  #  #  1  .
      4 |  #  #  #  #  #  #  1  .
      5 |  #  3  2  2  #  2  1  .
      6 |  #  1  .  1  #  1  .  .
      7 |  #  2  .  1  1  1  .  .
      8 |  #  1  .  .  .  .  .  .

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 4,1

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  #  #  #  1  .
      2 |  #  2  #  #  #  #  1  .
      3 |  #  #  #  2  #  #  1  .
      4 |  1  #  #  #  #  #  1  .
      5 |  #  3  2  2  #  2  1  .
      6 |  #  1  .  1  #  1  .  .
      7 |  #  2  .  1  1  1  .  .
      8 |  #  1  .  .  .  .  .  .

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 1,4

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  1  #  #  1  .
      2 |  #  2  #  #  #  #  1  .
      3 |  #  #  #  2  #  #  1  .
      4 |  1  #  #  #  #  #  1  .
      5 |  #  3  2  2  #  2  1  .
      6 |  #  1  .  1  #  1  .  .
      7 |  #  2  .  1  1  1  .  .
      8 |  #  1  .  .  .  .  .  .

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 5,5

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  1  #  #  1  .
      2 |  #  2  #  #  #  #  1  .
      3 |  #  #  #  2  #  #  1  .
      4 |  1  #  #  #  #  #  1  .
      5 |  #  3  2  2  2  2  1  .
      6 |  #  1  .  1  #  1  .  .
      7 |  #  2  .  1  1  1  .  .
      8 |  #  1  .  .  .  .  .  .

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 4,5

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  1  #  #  1  .
      2 |  #  2  #  #  #  #  1  .
      3 |  #  #  #  2  #  #  1  .
      4 |  1  #  #  #  1  #  1  .
      5 |  #  3  2  2  2  2  1  .
      6 |  #  1  .  1  #  1  .  .
      7 |  #  2  .  1  1  1  .  .
      8 |  #  1  .  .  .  .  .  .

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 4,4

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  1  #  #  1  .
      2 |  #  2  #  #  #  #  1  .
      3 |  #  #  #  2  #  #  1  .
      4 |  1  #  #  1  1  #  1  .
      5 |  #  3  2  2  2  2  1  .
      6 |  #  1  .  1  #  1  .  .
      7 |  #  2  .  1  1  1  .  .
      8 |  #  1  .  .  .  .  .  .

      Level: 1
      Difficulty: medium
      Uncovered mines: 9
      Make your move: s 4,6

           1  2  3  4  5  6  7  8
      ---------------------------
      1 |  #  #  #  1  #  #  1  .
      2 |  #  2  #  #  #  #  1  .
      3 |  #  #  #  2  #  #  1  .
      4 |  1  #  #  1  1  @  1  .
      5 |  #  3  2  2  2  2  1  .
      6 |  #  1  .  1  #  1  .  .
      7 |  #  2  .  1  1  1  .  .
      8 |  #  1  .  .  .  .  .  .

      Level: 1
      Difficulty: medium
      Uncovered mines: 9

      You were blown by a mine!
      GAME OVER!
      Better luck next time!

minesweeper-cli's People

Contributors

xbis7 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.