Minigame Monday: Get it out!

 Get it out!

  • The concept:

This week, I was given the suggestion of doing some kind of sliding block puzzle. One approach to this would have been to build up a framework, and then create a few positions and allow the player to play through them as seperate levels. That wasn't the route I went down; instead I decided to create a game that would automatically generate its own positions for the player to solve.

  • The challenge:

The big challenge here is of course finding a way of generating puzzle positions, but first I needed to decide on a format for the game, and build up a framework. I decided the puzzle would involve a grid containing a number of balls that would all move together on a key press, and the player would have to work out how to move the balls in such a way that they will only enter allowed cells, while trying to move all of the balls out of the grid through holes in the edge. While setting this up, I made sure to work on variable grid sizes, to allow the size of the grid to be configured later. I also used blocks of the background colour to create the doors. I've coloured them in a different colour in the image below to show how that worked:

Showing using blocks of colour to create doors
 

With the framework in place, it was time to write the algorithm to set up puzzle positions. My solution of this was to do the puzzle in reverse. To start with, I would have one ball, sitting in front of one of the exits (I chose the exit locations at random around the edges). I'd then make a move with the ball; if it didn't go off the edges, the move was valid, and I'd move on. At random, I'd try moves to enter another ball into the puzzle: I'd take the next exit in the list, and see if moving a ball in from that exit was a valid move. If it was, I'd move the balls accordingly, and add the new ball to the list of ball positions. I then simply repeated this process for a given number of steps. I also added a check so that if there was a position where the balls couldn't be moved at all, the generation would restart, rather than hang forever. I'm not certain such a position could actually happen, but I wanted to remove the risk. 

  • The result:

I had a number of bugs to fix with the generation, but I managed to get it so it worked. There is still one thing which slipped through; you can leave the grid from any cell that has a door adjacent from it, so you can actually leave corners in two directions. It can look like there are imposible positions until you know that. Because of the way that the generation works, many moves are repeats, so there will be a number of positions generated which are quite simple and easy to solve, however there are also more difficult ones that will be generated. I think to build on this, I'd add a timer, and make the game more about solving the positions in the smallest amount of time or smallest amount of moves. See what you think for yourself at https://reddragonmakesgames.itch.io/get-it-out, and the code is availabe on github.


 

Comments

Popular posts from this blog

Armageddump (Boss Rush Jam 2023)

Introducing: Minigame Monday! (3D Minesweeper)

Minigame Monday: Covert Behaviour