Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Puzzle Algorithm

I develop a (really) simple puzzle game that asks you to join a point A to a B (enter/exit) using a ball and mechanisms that you can rotate to give the correct direction to the ball in order to join the exit.

Here is screenshots of a simple level, showing clearly the purpose of the game:

1) New level started, the mechanisms are rotated in a random way

2) Level is completed, all the mechanisms are rotated properly to give the ball the right path to join the exit

Question:

How can I create an algorithm allowing me to automatically generate levels by taking into account the rotations and leaving only one possibility for the player to complete the level?

I'd also like to add more complexity by adding more mechanisms (to create creating difficulty levels).


I don't think it's necessary to talk about tech, but I'm using C# and Unity.

Let me know if you need more information.

Thank you!

like image 438
Hadrien Avatar asked Mar 30 '17 08:03

Hadrien


People also ask

How A * algorithm solves the 8-puzzle problem?

The puzzle can be solved by moving the tiles one by one in the single empty space and thus achieving the Goal configuration. Fig 1. Start and Goal configurations of an 8-Puzzle. The tiles in the initial(start) state can be moved in the empty space in a particular order and thus achieve the goal state.

What is the 8-puzzle problem?

The 8-puzzle problem is a puzzle invented and popularized by Noyes Palmer Chapman in the 1870s. It is played on a 3-by-3 grid with 8 square blocks labeled 1 through 8 and a blank square. Your goal is to rearrange the blocks so that they are in order.

Which algorithm is used in 8-puzzle problem?

A* Algorithm is one of the best and popular techniques used for path finding and graph traversals.


1 Answers

If you look at the second image, the game solution is the broken line starting at "ENTER" and ending at "EXIT".

You can create a new level by creating such a line (randomize the number of 'breaks' and their direction). Then you turn each corner into a rotating mechanism thingy. There will only be one legal solution since you will have to rotate the thingies just the right way.

like image 193
zmbq Avatar answered Sep 23 '22 20:09

zmbq