Home Puzzles algorithm – Maze Solving Robot

algorithm – Maze Solving Robot

0
algorithm – Maze Solving Robot

[ad_1]

Following is a straightforward and detailed clarification of xnor’s reply.

Let’s say that there are a complete of solely 2 doable maze configurations. Let’s additionally assume that we’re given how the robotic is oriented firstly . So, for instance, within the 3*3 case

1 2 3

4 5 6

7 8 9

we’d have been advised that the robotic is dropped at place 7 and is going through north i.e it’s going through 4.

Let’s name the two configurations , configuration 1 and configuration 2. Let’s say that the robotic was dropped with a sequence, sequence A. Sequence A was written to ensure that if the maze is in configuration 1, then the robotic would have visited each sq. not less than as soon as.

Now, if the maze was certainly in configuration 1, we’d have visited the ultimate sq. and we might be finished. But, if it was in configuration 2 as a substitute then it’s doable that by the tip of sequence A, not all of the squares had been visited and by extension, it’s doable that we didn’t go to the ultimate sq. by the tip of sequence A.

How will we treatment this ? The treatment is to drop the robotic with sequence A+B as a substitute of simply A.

This is how A+B helps. If after sequence A has completed and the robotic has nonetheless not visited the ultimate sq. then which means the robotic was in configuration 2 all alongside. Since we now know for positive that the robotic has been in configuration 2 all alongside, we additionally very properly know which sq. and in what orientation the robotic is in, after sequence A has ended. Sequence B would now get executed and can ensure that the robotic has visited each sq. by the point sequence B ends.

Thus, we now have discovered an answer for the case the place the maze can solely be in certainly one of 2 doable configurations and the place the orientation of the robotic is understood initially.

Let’s now proceed this logic to the case the place there are 3 doable maze configurations and the place the orientation of the robotic is understood to us initially. We will ship the robotic now with the sequence A+B+C. If the sequence A+B fails to make the robotic go to the ultimate sq., then it could imply that the robotic was in maze configuration 3 all alongside. Since we all know for a proven fact that the robotic was in configuration 3 all alongside, we additionally would know which sq. and during which orientation the robotic could be in after sequence A+B. We can thus have a sequence C that can make the robotic go to each sq. of configuration 3, from the sq. the robotic is in after the sequence A+B has ended.
Hence solved.

This logic might be prolonged to the case the place there are n doable maze configurations and the place the preliminary orientation of the robotic is understood.

It can be simple to increase this logic to the case the place there are n doable maze configurations and the place the preliminary orientation of the robotic isn’t recognized.

P.S.

The above puzzle jogs my memory of this puzzle : Why does this resolution assure that the prince knocks on the best door to seek out the princess?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here