Giter Club home page Giter Club logo

minesweeper's Introduction

Minesweeper

Minesweeper assignment during my C-1 programming course.

Assignment: Minesweeper
A given number of bombs are hidden on an 8 x 8 field. Each field is invisible until you choose and activate it. Choosing the location is always by entering a letter with number or number with letter (both C5 and 5C and c5), the number goes from 1 to 8 and the letter from A to H. If a bomb is hidden there, the game ends and you are lost and show all other bombs. If there is no bomb, the number of bombs in the immediate vicinity is shown (top left, top, top right, left, right, bottom left, bottom and bottom right). If there are no bombs around, it will show all immediate neighbors as they cannot be bombs and repeat this functionality for all neighbors that also have no nearby bombs. The game is over once all the bombs are the only spaces that have not been cleared. You always show the progress in percentage of the game as number of fields unlocked / number of fields to be unlocked (= 8x8 fields - number of bombs) x 100%. It is always possible to save a running game (choose the word "save" when entering the location) and to load it with the help of. 2 hexadecimal numbers (1 bitmask with bomb location and 1 bitmask with unlocked fields).

Flow of the game:
Start the game by welcoming the user and asking for the number of bombs or "loads". During loading, 2 hexadecimal numbers are entered, which together represent both the 8 by 8 field with bombs and the field played. Test whether the entered values are possible, e.g. no bombs in the field, or bombs that have already exploded, or a field that has actually been played out. With the number of bombs, a new 8 by 8 field is filled with the number of bombs at random locations (make sure that the number of bombs is correct and that no bombs are duplicated). In both cases, a visual 2D array is filled or maintained (and loaded) with the correct representation. Then the game is played.

The game is played until a bomb activates or the game is over. As long as that is not the case, a location can be entered as "save". When saved, it shows the 2 64 bit hexadecimal numbers representing the bomb field and current state of cleared fields. A location, on the other hand, can be both a letter with a number and a number with a letter (case insensitive). At that entered location, the field (visual 2D array) is adjusted to show the correct content. This can be a bomb and then the game is over and you show the field with all the bombs. This can be a neighbor of a bomb and then you show the number of number of bombs as a neighbor. This can be a null field and then you flood fill the field from that point. Displays the field and progress as a percentage with 2 decimal places of number of fields shown to total number of good fields. Once the last non-bomb space is marked, congratulate the player.

minesweeper's People

Contributors

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