{"id":17109077,"url":"https://github.com/dtanglr/mindsweeper","last_synced_at":"2025-09-11T07:34:50.814Z","repository":{"id":243726811,"uuid":"795759628","full_name":"dtanglr/MindSweeper","owner":"dtanglr","description":"Mind Sweeper is a C# game developed to provide an example of how a .NET CLI application can be configured, built and run using dependency injection, SOLID principles, clean and testable code that implements the new .NET Command Line API - https://github.com/dotnet/command-line-api.","archived":false,"fork":false,"pushed_at":"2024-11-09T01:07:40.000Z","size":302141,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T04:43:26.718Z","etag":null,"topics":["clean-architecture","clean-code","command-line-api","commandline","console-app","mediatr","minesweeper","solid-principles","system-commandline","system-commandline-hosting"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtanglr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-04T01:34:31.000Z","updated_at":"2024-11-21T00:45:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"0db68469-f7bd-4a18-8437-9021ae7c10d7","html_url":"https://github.com/dtanglr/MindSweeper","commit_stats":null,"previous_names":["dtanglr/mindsweeper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtanglr%2FMindSweeper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtanglr%2FMindSweeper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtanglr%2FMindSweeper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtanglr%2FMindSweeper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtanglr","download_url":"https://codeload.github.com/dtanglr/MindSweeper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245170286,"owners_count":20572040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","clean-code","command-line-api","commandline","console-app","mediatr","minesweeper","solid-principles","system-commandline","system-commandline-hosting"],"created_at":"2024-10-14T16:22:01.553Z","updated_at":"2025-03-23T21:23:33.505Z","avatar_url":"https://github.com/dtanglr.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Mind Sweeper](docs/images/logo-190x190.jpg)\n\n## Introduction\n\n`Mind Sweeper` is a game written in C# using .NET 8.0. It's a CLI console application played by issuing commands on a terminal and operating system of your choosing.\n\nAs a game, it's not going to set the world on fire by any means whatsoever!\n\nHowever, as a .NET engineer, this project may hopefully provide an excellent `experimental playground` for developers wishing to learn about writing modern .NET CLI applications using the new .NET [Command Line API](https://github.com/dotnet/command-line-api).\n\nBeing able to use the host builder to configure and run the CLI console app in just the same way as one does for web and web API projects has been a transformative experience. It makes it a real possibility to be able to easily add a CLI to an existing .NET app as well as developing them right from the get-go on green-field projects.\n\nAs a result of all this, I thought I would share this project to share the love for the good old `black screen white text`! Nb. other colour variations are available :-)\n\nTo read more about why I developed this code. See the [motivations for this project](#motivation-for-this-project).\n\n## Quick Start\n\nThe *artifacts* folder in the root of this repository contains some `self-contained` executables of the game that target win-x64, osx-x64 and linux-x64. Download one and then open a terminal in the same folder and type `mindsweeper` (cmd) or `./mindsweeper` (pwsh, linux, MacOS). This will display the help screen with further instructions on how to play.\n\n![quick-start-anim](docs/images/quick-start-anim-01.gif)\n\n## How to play\n\n### Rules\n\nThe game is played on a grid of squares similar to a chess board. Unlike chess though, the player can only move one square at a time.\n\nThe player can move up, down, left, right, but not diagonally.\n\nTo win, the player must move from a square on the bottom row to any square on the top row, without stepping on too many bombs.\n\nStepping on a bomb loses the player a life. Losing all their lives means they lose the game.\n\nThe playing field defaults to 8 rows by 8 columns, 64 squares and 21 bombs (i.e. 1 in 3 squares will explode!).  The player gets 3 lives. All these values are configurable via options for the `start` command. See the [Commands](#commands) section below for further information.\n\nJust like a chess board, each row on the playing field is numbered from 1 to 8 and each column is lettered from A to H, so each square is labelled according to its row and column e.g. A1 to H1 and A1 to A8 etc.\n\nGood luck!\n\n### Commands\n\n| Command | Description |\n| :------ | :---------- |\n| mindsweeper | Display welcome screen and help. |\n| mindsweeper start [-r\\|--rows] \\\u003crows\\\u003e [-c\\|--columns] \\\u003ccolumns\\\u003e [-b\\|--bombs] \\\u003cbombs\\\u003e [-l\\|--lives] \\\u003clives\\\u003e | Start a new game with the optionally given number of rows [default: 8], columns [default: 8], bombs [default: 21], lives [default: 3] |\n| mindsweeper move \\\u003cdirection\\\u003e up \\| down \\| left \\| right | Move from the current square in the given direction to another square. |\n| mindsweeper status | Get the status of the current game. |\n| mindsweeper end | End the current game. |\n\nNb. To display help on any of the above commands. Use one of the following options: -? | -h | --help\n\n## Motivation for this project\nIn April 2024, a recruiter approached me on behalf of a company called [Schneider Electric](https://www.se.com/) who were looking for a C# developer.\n\nThey required that candidates undertake a technical test to create a console application, similar to Mine Sweeper, using best practices such as SOLID principles, unit testing and clean code etc.  The specification for the technical test is here: [Download](docs/Developer%20Coding%20Test%20-%20Minefield%20Game%20-%20Sept%202021.docx).\n\nIt was recommended that the test be completed within 2 hours.  For me personally, I felt that this was an unrealistic time frame to complete the test and do it justice. \n\nDespite this, I decided to create a similar game in my own time. I felt inspired by the challenge and wanted to see if I could create a CLI version of the game rather than a simple console application that has a while loop listening for key inputs from the user.\n\nFor many years I have developed API and web applications that have a clear separation of concerns with the host sending commands and requests along a pipeline to an application layer containing CQRS behaviours, pre- and post-request processors and handlers thanks to the wonderful [Mediatr](https://github.com/jbogard/MediatR) package.\n\nI wanted to prove I could build a CLI host application using a similar approach. It would also mean that in the future I could potentially build other host implementations, such as an API or Blazor front end, without any changes to the game logic.\n\nTo achieve this I looked at various command line parsers but settled on using the new dotnet [Command Line API](https://github.com/dotnet/command-line-api). Despite this still being in a pre-release state I was convinced it was viable due to its wide adoption and integration with the dotnet host builder for dependency injection, logging, settings etc.  This was a crucial factor for me as it's essential to be able to create other host application flavours using the same game logic.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtanglr%2Fmindsweeper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtanglr%2Fmindsweeper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtanglr%2Fmindsweeper/lists"}