Course:CPSC312-2021/Minesweeper with Assistant

From UBC Wiki

By: Brendan Woodward, David Liu, Jack Heidal


What is the problem?

We would like to develop a game of minesweeper in Haskell (see game rules here). This would involve including random variation and allow the user to pick and mark locations on the board at any given time.

What is the something extra?

For our project we wanted to build it from the ground up, and not use anyone else's minesweeper code. We therefore build our own data structures and conceptualized how to make the game on our own. This required us to implement randomization as well. I addition, we made an interactive IO terminal console for the game, where the player can input moves and do all things minesweeper, while also getting feedback on each move they make. Lastly, we developed a few "assistants" for the game to aid the player and help them win. One will make a move for the player that reveals an empty spot, another that will tell the player if their flags are in the correct location, and also one that will remove flags the player has placed that invalid. In addition to this we added a solver that can solve the current game in the fewest in moves, and return the list of moves done to win. Furthermore, if you click a bomb, the computer will solve the game for you and tell you how you could have won. We considered making a GUI, however, after building the terminal game and building minesweeper from the ground up, we felt it became outside the scope of our abilities and that we could lose some interaction with the player.

What did we learn from doing this?

We got to apply a lot of what we learned in class to make this game. We started our game by developing data and type definitions for things we wanted to include, and got to solidify how building those works. We decided to make our board a list of list of cells, and therefore we got very comfortable iterating through lists and specifically, list of lists. One challenging part at first was implementing the randomness of minesweeper. One part that made this additionally challenging was that when you get a random generator the function returns a type IO (unless you make you own generator, but then it would be the same "random numbers" each time). Implementing this, and the console taught us a lot about IO and interacting with the player. Overall, we got to apply many things we learned in class about games, data, types, IO, and defining concise functions, and apply it to our own personal project.

Links to code?

https://github.com/MrEvildoom/312Minesweeper