Games to Play (Part 2)

Game Bank


I’m currently writing this from a plane. It’s not very relevent, but I figured it’s still pretty cool.

Anyway, here’s a rundown of the other games in the game bank (gamebank.netlify.app):

Minesweeper

Again, a simple game that a surprising amount of people have never heard of or don’t know how to play. The game starts by clicking any square on, in this case, an 8 by 8 grid. This is guaranteed to be a safe square. The number displayed in the number of bombs, or mines, surrounding that individual square, including diagonals. So, for example, if a square has the number 2 on it, that means there are two bombs either to the left, right, up, down, or diagonal to that square. From there, the user needs to right click to flag the bombs. The game ends when the user has either uncovered all the safe squares (they win), or when they uncover a bomb (they lose).

Making the game was pretty straightforward. I just did a bit of random placement on the two-dimensional array, and basically just styled the rest.

2048

The last game in the current state of the game bank is a 2048 game. It’s a well-known game where the user presses their arrow keys (up, right, down, left) to combine two of the same numbers. The resulting number is a merged number that is twice the value of the previous square used in combination. For example, in the image above, the user could press the right arrow key, and a single 4 square would be on the right. With each move, a new number is added to a random open space on the 4 by 4 grid. For the way I made the game, 9 out of 10 times this number will be a 2, and 1 out of 10 times this number will be a 4. The game ends when the user has not more possible moves left, or in other words when the grid is filled up, or when the user reaches 2048.

Also, the scoring with this game is a bit different. As it is more uncommon to beat the game, the score presented on the leaderboard is the user’s highest score. This is calculated based on a total number system, where each individual number – present and past – will be totaled in the score.

Sudoku


I have been into Sudoku for a while now. I enjoyed doing the puzzles during my free period when I had nothing else to do. But recently, after receiving a physical packet and starting to work on that, I have a need for a solver algorithm to check my work. So, I decided to just make one, because I figured it would be cool anyways.

In the end, it was not a very hard project to make. The program uses a heuristic search to choose the cell with the fewest valid options, and then checks the current board configuration to prioritize numbers that fit with the least conflicts in the current board. What I also encountered when making the program was that it would frequently time out due to faulty board inputs or sheer difficulty. So, I moved it oa separate thread to mangage potential timeouts (if it takes longer than 5 seconds).

I’m happy with the final product, as not only does it work, but it conveniently fits on my MacBook screen alongside another program or such.

The final code is available here, if you want to try it out for yourself.

Subscriptions


I also used this weekend to perform some much-needed updates to the blog. To start, I added a subscription feature, so people can be notified when I make a new post. I made a new page for it, put it as an option whenever someone leaves a comment, and also made it a big blue button in the top right of the page.

Apart from a welcome and confirmation email, the email system only sends a letter whenever there is a new post available. I’m thinking of sending the same email, with the last few blog posts, at the end of each month, since that is how many posts I generally write in a month.

Join Now

Sign up to receive notifications about new posts and other updates!

By signing up, you agree to the privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *