๐พ Archived View for gemi.dev โบ gemlog โบ 2023-01-08-minesweeper.gmi captured on 2023-09-28 at 15:54:39. Gemini links have been rewritten to link to archived content
โฌ ๏ธ Previous capture (2023-01-29)
-=-=-=-=-=-=-
2023-01-08 | #cgi #games | @Acidus
Over vacation I built a complete Minesweeper game on my capsule. I implemented flags, chording, different difficulties, and even custom games. You can play it here!
"Minesweeper (video game)" via Gemipedia
I had a lot of fun building Where in the World, a geography game in Gemini last fall. This was the first game I had written just for fun in 20+ years.
๐บ Where In the World? A geography game
The constraints of Gemini created some challenges that were fun to solve:
I knew I wanted to try make another game, and started thinking about different options in the back of my mind when I had a few moments between life and work. I was thinking about more traditional games and an idea that kept coming up was Battleship.
I liked a traditional board game like Battleship for a few reasons:
However as I thought about it more I ran into some issues:
Taking ideas from the good parts and bad parts, I decided I needed a game that:
Which lead me to think of Minesweeper!
Minesweeper is actually one of the first games I made as a teenager, written in TI-BASIC on a graphing calculator, instead of paying attention in school. Fundamentally, you have a 2D matrix, representing all the tiles of the game. You place mines at random coordinates, then, for all the tiles without a mine, you fill it with the count of mines on adjacent tiles. With some clever bitmasking you can use the same matrix to also keep track of track what tiles have been revealed, or have flags.
The first version of the game looked something like this:
Flags: 6 Total Mines: 10 ABCDEFGHIJKLMNO A 112โ A B 111 1โ 2โ B C 12ยท1 1121 C D 1ยท21 D E 222 111 E F 12โ 1 1111โ . F G โ 211 1..... G H 11 12..... H I 1...... I ABCDEFGHIJKLMNO
The '*' is a flag, and '.' is an area you still need to explore. This is really similar to how my our TI-BASIC game looked, since that used text characters and didn't have access to the extended ASCII characters. While a promising start, I wasn't a fan of this. The board was too dense. Characters are taller than they are wide, so the board felt cramped and it was hard to moves your eyes up to figure out the column you wanted to select.
Luckily, I solved this be accident when I started to use emoji. I knew emoji could create richer graphics since there is an emoji for a flag, and for a bomb, and even blocks and other things. But the challenge is some emoji have a "screen width" of more than 1 character. This messed up the columns as your can see below:
Flags: 6 Total Mines: 10 ABCDEFGHIJKLMNO A 112๐ฉ A B 111 1๐ฉ2๐ฉ B C 12ยท1 1121 C D 1ยท21 D E 222 111 E F 12๐ฉ1 1111๐ฉ. F G ๐ฉ211 1..... G H 11 12..... H I 1...... I ABCDEFGHIJKLMNO
The solution was to make columns 2 characters wide, with some blank space, so the emoji would fit, but it also solved the "cramped" and "dense" feeling of the board:
A B C D E F G H I J K L M N O a 1 ๐ฉ1 1 ยท ยท ยท ยท a b 1 1 1 1 1 2 1 1 ยท ยท b c 1 1 1 1 ๐ฉ1 1 ยท ยท c d 1 ๐ฉ2 1 1 1 1 1 1 ยท ยท d e 1 1 1 1 2 ๐ฉ1 1 1 1 e f ๐ฉ2 2 1 1 2 2 2 f g ยท ยท ยท ยท ยท ยท ยท 1 1 1 1 g h ยท ยท ยท ยท ยท ยท ยท 2 1 1 ยท 1 h i ยท ยท ยท ยท ยท ยท ยท ๐ฉ1 1 ยท 1 i A B C D E F G H I J K L M N O
CGI Variable "PATH_INFO" incorrectly removing runs of slash characters causing errors in CGI scripts
As a whole, I think my Gemini version of Minesweeper turned out just OK. So while I'm playing minesweeper, especially at night before I go to bed, its not as exciting to me as I would have hoped. That could just be me. I hope you all like it.
The reason I feel this implementation isn't excellent all comes down to the "think-move-look" loop. Minesweeper is a pretty fast game. A typical game involves dozens and dozens of moves. Often as you uncover more of the board, you immediately see several tiles that you need to click or where you want to put flags. Only now you have to do the tedious process of making multiple moves really quickly to implement those moves. That's the bottleneck. In short minesweeper has a low "thinking to moves" ratio.
This leads me to think that a game with a higher "thinking to moves" ratio would be better suited for Gemini. And the board game that comes to mind that has a high "thinking to moves" ratio is chess. Specifically chess against a computer opponent. I'm not sure when I'll do this, but I think that will be my next game.
Of course, I really don't want to implement a chess engine, but there are open source chess engines of various skills. Even better these chess engines are decoupled from the user interface. This means I can write a Gemini interface which displays the board and gets the user's input for their move, and pass it to the chess engine for the computer to make a move!
Universal Chess Interface via Gemipedia
Can you think of another game I should build? Drop me an email or ping me on Station