# Minesweeper A console Minesweeper for the terminal, built on .NET 10. The rules live in a UI-free engine, so the same board can be driven by the console client or by tests. ``` 9x9 mines left 10 flags 0/10 time 12s Reveal every cell that is not a mine. A B C D E F G H I 1 # # 1 · · 1 # # # 2 1 1 1 · · 1 1 2 1 3 · · · · · · · · · 4 2 2 1 · · · · · · 5 # # 1 · · · · · · 6 # # 2 1 2 1 1 · · 7 # # # # # # 2 2 2 8 # # # # # # # # # 9 # # # # # # # # # type " " to reveal, f to flag, ? for help, q to quit > ``` ## Play it ```bash dotnet run --project src/Minesweeper.Cli ``` | Option | Meaning | | --- | --- | | `-d, --difficulty ` | board preset (default: beginner) | | `-b`, `-i`, `-e` | shorthand for the three presets | | `-k, --keys` | arrow-key play instead of typed commands | | `--seed ` | deterministic mines, for reproducible games | | `-h, --help` | usage, command list, and legend | Beginner is 9x9 with 10 mines, intermediate 16x16 with 40, expert 30x16 with 99. ## Commands Rows are numbered `1..N` down the left, columns are lettered `A..Z` (then `AA..`) across the top. | Command | Does | | --- | --- | | ` ` or `reveal ` | open a cell (`r`, `open` are aliases) | | `flag ` | place or remove a flag (`f`, `mark`) | | `chord ` | open the neighbours of a number once its flags match (`c`) | | `go ` | move the cursor without opening anything (`goto`) | | `difficulty ` | switch preset, by name or `1`/`2`/`3` | | `new` | restart at the current difficulty | | `help` / `?` | list the commands | | `quit` / `q` | leave | In `--keys` mode: arrows move, `Enter`/`Space` reveals, `F` flags, `C` chords, `1`/`2`/`3` change difficulty, `N` starts a new board, `Q` or `Esc` quits. Colours are on when writing to a terminal and off when the output is redirected; set `NO_COLOR` to force them off. The process exits `0` after a win, `1` otherwise. ## Rules - The first click is always safe. On boards with room, the eight cells around it are safe too. - Opening a cell with no adjacent mines cascades outward until it hits numbers. - Chording a number whose surrounding flag count matches opens the rest of its neighbours — so a mistaken flag costs you the game. - You win by opening every cell that is not a mine; remaining mines are flagged for you. ## Layout ``` src/Minesweeper.Core rules and board state, no console calls src/Minesweeper.Cli command parsing, ANSI rendering, the game loop tests/ xUnit tests for the engine, parser, session, and renderer ``` ```bash dotnet build # compiles all three projects dotnet test # runs the suite ```