Giter VIP home page Giter VIP logo

mines's Introduction

mines Build Status Go Report Card

A terminal-based implementation of Minesweeper in Go.

mines_demo_better

An example of a medium level game

Contents

  1. Building and Installing
  2. Controls
  3. Game Reference
  4. License

Building and Installing

Installing

mines has a fairly minimal set of dependencies:

  • Go 1.10
  • termbox-go (github.com/nsf/termbox-go)

To install the application, run the following command:

go get -u github.com/maxgodfrey2004/mines

Building

In future, a Makefile will be added here so that building the project is easier. However, in the meantime, you will have to run the build commands manually.

  1. Change your working directory to the repository root (this will be located somewhere in your GOPATH). If you are not sure where your GOPATH is, just execute:
go env GOPATH
  1. Build the project by running the following:
go build -o mines main.go

Running

Now you can run your new binary. If you require any assistance pertinent to the usage of the binary, invoke it with the --help flag for more information.

A brief note concerning command line arguments

Passing flags to the binary is syntactically easier than you may expect. The Go flag package allows for many different ways to pass command line argments.

All of the following are valid:

./mines -difficulty medium
./mines -difficulty=medium
./mines --difficulty medium
./mines --difficulty=medium

You can also put quotes around the argument's value if you are that way inclined.

Controls

Key Functionality
Arrow Up, W, w Moves the selected cell up by one.
Arrow Down, S, s Moves the selected cell down by one.
Arrow Left, A, a Moves the selected cell left by one.
Arrow Right, D, d Moves the selected cell right by one.
F, f Flags the selected cell as a mine.
Q, q Quits the application.
Return Selects the current cell and displays its contents.

Game Reference

How to play

Minesweeper is played on a grid. There are two different types of grid cell, these being numbered cells and mines. If you select a mine, you lose and the game is over.

The number in a numbered cell represents the amount of mines directly adjacent to that cell. For an example of adjacent cells, have a look at the following grid - cells marked A are considered adjacent to the cell marked X.

..........
..........
.....AAA..
.....AXA..
.....AAA..
..........

You start off with an empty grid, where the value of every cell is hidden. The goal is to find the location of every mine on the grid (thus "sweeping" the grid of mines, hence the name of the game) without actually selecting a mine. Given the information presented to you by various numbered cells, it is possible to make informed decisions as to where mines are.

If there is a cell you are adamant contains a mine, do not select it (if you do, then you lose the game and all your progress!). Instead, flag it. Note that you are not able to select a cell which you have already flagged. This stops you from accidentally selecting that cell and losing the game.

Game modes

mines can be played in three modes: "Easy", "Medium" and "Hard".

The difficulty of each game can be set through command line flags when the application is invoked. If the difficulty of a game is not set, then the application defaults to medium difficulty.

The specifications for each game mode are as follows:

Grid Width Grid Height Mines
Easy 8 cells 8 cells 10
Medium 16 cells 16 cells 40
Hard 30 cells 16 cells 99

License

This project is licensed under the Apache License 2.0. For more information, read the LICENCE file in the project's root directory. Alternatively, you can read it on Github.

mines's People

Contributors

maxgodfrey2004 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

fossabot

mines's Issues

Possibility of a loss on the user's first turn

It is currently possible for the user to lose the game on their first turn. An example of this occurring is shown below (screenshot taken on Windows 10 - the game level was medium).

image

It seems rather unfair for the player to lose on their first turn.

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.