# Creating a Simple Puzzle resolution 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.

Thank you!

• Does the ball only bounce in 90 degrees? Mar 30, 2017 at 9:51
• @Bálint Yes! But sometimes I add a new mechanism: a "plate" which gives the ability to the ball to bounce back (it only changes the direction of the ball, eg: from left -> right to right -> left) Mar 30, 2017 at 9:58
• but if a ball hits a plane, then it will go back to the start position no matter what Mar 30, 2017 at 10:48
• @Bálint yes, indeed. Do you have a start of solution to generate the levels? Mar 30, 2017 at 10:56