Skip to content

maxgodfrey2004/mines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.