GitXplorerGitXplorer
s

minesweeper

public
9 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
0d1ed94c50b1ecdacc7af3858565940a6648ae16

Add Dockerfile

kkabirbaidhya committed 5 years ago
Unverified
ec4b80c1fb0911db8cdb3e5d232a23fff33c3578

Compile with static linking of ncurses

kkabirbaidhya committed 5 years ago
Unverified
923476125165d4adb8560293cb22673e1fca35d0

Rename test_main -> runner

kkabirbaidhya committed 5 years ago
Unverified
2e625f21bcb9790f7b5770e9533429adade2add5

Update Makefile

kkabirbaidhya committed 5 years ago
Unverified
6f5ef2db371b0fee4086d189aba0c1e49a57d31b

Add tests for utils/array

kkabirbaidhya committed 5 years ago
Unverified
9b7a8d7c7eafdfb4ee5cdd0d696995be44beae30

Configure travis for running tests

kkabirbaidhya committed 5 years ago

README

The README file for this repository.

minesweeper Build Status

A simple implementation of the classic Minesweeper in your terminal.

┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
│ │ │ │1│1│3│#│2│ │ │ │ │1│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│ │ │ │1│#│3│#│2│ │ │ │ │1│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│ │ │ │1│1│2│2│2│1│ │ │ │1│3│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│ │ │ │ │ │ │1│#│1│ │ │ │ │2│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│ │ │1│2│2│1│1│1│1│ │ │ │ │1│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│1│1│1│#│#│1│ │ │ │ │ │ │ │1│1│1│1│2│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│1│ │ │ │ │1│1│1│ │ │ │ │2│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│1│ │ │ │ │1│#│1│ │ │ │ │3│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│3│1│2│1│1│1│1│1│ │1│1│2│3│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│1│ │1│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│3│1│2│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│▒│
└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘

Motivation

Just wanted a simple project to practice C.

How to Play

  • to move the cursor around.
  • SPACE to flag a cell. Flagged cells are represented with a #.
  • ENTER to reveal a cell. Bomb cells are represented with a .
  • q to exit at any time.

Architecture

You should find the code self-explanatory.

window.c manages the view layer of the game. It decides how the game is printed and how user input is taken. We use ncurses to print the game and take user input.

libminesweeper manages the game state and game logic.

Build

Use make to build the project.

$ make build

You may sometimes need to clean previous build artifacts:

$ make clean

For a debug-ready build:

$ make debug

I need help improving the Makefile. Any contributions welcome.

I am developing the project on MacOS with the default build chain installed by XCode. That means even though I say gcc in the Makefile, I am actually building with Clang. They aim to be source compatible with the original gcc.

My current "gcc" version = 4.2.1

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin