Howdy,
This is sort of my first program that I coded from scrap. I decide to recreate minesweeper but in the terminal because it seems quite challenging to me (and because I didn't have any other inspiration at the moment hehe).
Here's a sneak peak of the code running in the terminal (I'm definitely more proud of it that I should be, but let me have it).
Basically, how it works is I created two grids using nested lists (one to keep track of all the generated values of the game and another one to keep track of user inputs throughout the game), and based on the contents of the grids, it will be printed to the terminal. Each time it is printed, the user will have the options to reveal or flag certain boxes using coordinate inputs or end the game immediately. Once all the non-mines boxes has been opened, the game will share a victory message. Or if the player hits a mine, the game will share a defeat message.
The most challenging part for me was to code a logic that continues to open the boxes until a number box is shown. However, I did manage by running the functions within the same functions to make it work.
If you are interested, you can find my code here at github.
Conclusion:
A code for minesweeper that runs in the terminal, definitely not the cleanest and not the most efficient, but definitely something that I am proud of.
Top comments (0)