thedave.dev

hax0r theme? really Dave?

I wrote a version of MineSweeper in batch. It’s not the most efficient or the most user-friendly, but it works. It’s a fun little project that I thought I’d share.

Where to get it?

thedaveCA/stupid-batch-tricks. Just grab everything, it requires some stuff from the _helpers directory as well, so either clone the whole repo or download the .zip.

It has only been tested on Windows 11, under both Windows Terminal and the Command Prompt. An early prototype worked fine on Windows 10 as well, but I have not tested the final release. It should work on Windows 10 >= 1909, but I make no guarantees.

Controls

Command Action Command Action
w s Move around the board a d Move around the board
x Flag as safe/mine z Reveal if we found a mine!
r Draw the board R Clear and refresh the screen
0 New game with: No mines 1 New game with: ALL THE MINES! 100% mines
2 New game with: A lot of mines 3 New game with: A few mines
c Clear the board q Quit
shift-C DEBUG: Enable cheat mode shift-V DEBUG: Display variables

The controls are… A bit janky, but they work. I can’t trivially use arrow keys batch, so I had to use w, a, s, and d for movement.

Weird/fun implementation details

Should you play this game?

No.

Should you look at the code?

Also no.

Why does it exist?

I guess I didn’t have a headache one day and said to myself, wouldn’t I like to have a headache?

And I was doing some other stuff in batch that would benefit from some column alignment and this seemed like one way to play around. I have some basic functions in _helpers and _snippets that will pad strings, align columns, and other goodies.

Colours and other ANSI-escape codes are used extensively, and require a _helper script to load. This is entirely essential, there is no way to display the board without it. Okay, you could rewrite it, but it would mean clearing the screen which causes an unacceptable amount of flicker.

It is “batch” but not MS-DOS compatible batch, it uses various Windows-specific features that were added to more modern versions of Windows.

What’s next?

Hopefully not batch.

Okay, but what else could be added?


Site built: 2024-12-09 23:43:57 -0700