Unlock level generator?

Rather, a specific question: does anyone know the existing code snippet on how to create solvable levels for the game, unlock me? Or what would be the best approach to writing my own? As a rule, how are you going to write an algorithm for checking and generating solvability, etc.

+4
source share
2 answers

Well, I code for these problems, just rudely forcing it. create a way to enter what the panel looks like (where the rectangles are and their orientation), then write a recursive function that goes into all possible movements. Not difficult, theoretically;) Note that the board is 6x6, and do not forget to make a way for the program to output every move. Maximum EDIT: After thinking about this for a while, you should figure out which block keeps the red block from moving to the right, and then figure out which direction it should go (there can only be a vertical block). If it is high 3, the block should lower, otherwise create a fork in the recursive function and check what happens if the block moves in any direction. Then find out which block blocks the last block until nothing is blocked. This is an opportunity.

+2
source

I did it once.

I started with a red block at the exit and other blocks in random non-overlapping positions, then applied the minimum number of random possible steps (1,000,000). If the red color is far enough from the exit, and it cannot be moved there (usually in the case), you are done, otherwise repeat.

+4
source

All Articles