Git Product home page Git Product logo

minesweeper's Introduction

Minesweeper

Running the program

Windows

  1. Download the entire repository.
  2. Run mines.exe file by double-clicking on file.

Game screen should show up immediately.

Linux/MacOS

  1. Download the entire repository.
  2. Open repo in Terminal and run the following commands
 $ make
 $ ./mines

Game screen should show up immediately.

Screenshots

Below are some in-game screenshots:

Instructions

Play this game like your standard Minesweeper game. Right-click to flag tiles that you think have bombs underneath. Do this before time runs out.

Customizability

Variables in mines.cpp

The following are variables that can be edited in file:

  • WIDTHand HEIGHT - number of tiles in the Minesweeper board
Variable Configuration Screenshot
WIDTH = 20; HEIGHT = 10;
WIDTH = 25; HEIGHT = 15;
  • BOMBS - number of bombs planted into the game
  • TS - tile size in your screen
  • char * SKINTYPE - source file name for Minesweeper skin
  • sTS - Tile size of source image in pixels

Here are some available skins:

File Name Tile Source tile size
minesweeper2.bmp alt text 24px
minesweeper.bmp 200px

Implementation (Data structures)

Program makes use of three 2D std::vectors to store the following information:

  • Number of neighbouring bombs (any number >=9 signifies bomb within itself)
  • Boolean cover (whether or not the tile has been revealed)
  • Tile icon (whether the tile has been flagged/marked)

Implementation (Algorithms)

I considered two algorithms for implementing this:

Breadth-first search (Current implementation)

How it works:

  • The program will only begin to look for adjacent tiles to open once user has clicked on a tile.
  • In the function, openBox, we breadth-first search algorithm to look for all the tile nearby until numbered tiles are found.

Pros:

  • Simple to implement

Cons:

  • Might take a while to load when there is a large number of tiles to be opened.

Union-find (Alternative implementation)

How it works:

  • Identify tiles within the same “island” (group of tiles surrounded by numbered tiles to be opened during a single tile click) before game starts
  • Use union-find algorithm to find all these tiles
  • Not possible to implement simply as certain numbered tiles could belong to different islands depending on how the user clicks on the tiles during the game.

Technologies used

The following were used to create this game:

  • C++
  • Simple and Fast Multimedia Library (SFML)

Future Development

  • Function calls to be made recursive and elegant

Credits

Developed by: Tiffany Chong

SFML tutorial: Coding Made Easy (https://www.youtube.com/channel/UCas000yWtwjvFzD2zB9Nzmw)

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.