Page 1 of 1

Bugged by automatic maze navigation

Posted: Sun May 26, 2019 7:00 pm
by richmond62
I am trying to get a "bug" through a maze automatically:
but it jerks around all over the place and crosses walls when it shouldn't.
-
BigBigMaze.jpg

Re: Bugged by automatic maze navigation

Posted: Mon May 27, 2019 5:57 am
by dunbarx
Richmond.

I did not look at your stack, but isn't this a matter of brute-force decision making? There is comfort in the fact that the size of each corridor is constant. That way we can move freely along a corridor, and only hear an alarm when we are about to collide with a line.

So we move a pixel or two at a time, and test to see if there is a line a certain distance in front from an arbitrary hotSpot in the bug itself. For example, a horizontal line has a top, but its left and its right are different. So we know when we are, say, 20 pixels below or above such a line. We can examine any line in the entire maze that way, and know at any given point which lines are near us, and which way they are oriented.
Pseudo:

Code: Select all

repeat until the bug is out
  advance the bug until its hotSpot approaches too close to a line in the line database of the maze
  see which of two possible directions there is NOT a nearby line -- left or right of the current direction
  rotate the bug toward the "open" space
end repeat
Your maze has no two-way forks. The process would be more complicated if it did, but would not change in character. You would just have nested repeats as per the above.

This likely sounds easier that it is.

Craig

Re: Bugged by automatic maze navigation

Posted: Mon May 27, 2019 6:03 am
by richmond62
MY code is what fusses me. 8)

Re: Bugged by automatic maze navigation

Posted: Mon May 27, 2019 8:44 am
by richmond62
Stupid Richmond missed a 'break' inside his 'switch' loop.

Re: Bugged by automatic maze navigation

Posted: Mon May 27, 2019 9:42 am
by richmond62
What I need to do next is to introduce some 'learning' so the bug does
not keep bashing its head against walls, and does not keep going
back the way it has come . . .

Re: Bugged by automatic maze navigation

Posted: Mon May 27, 2019 10:04 am
by [-hh]
TMHO a good summary of solving algorithms:
http://www.astrolog.org/labyrnth/algrithm.htm#solve

Re: Bugged by automatic maze navigation

Posted: Mon May 27, 2019 1:46 pm
by richmond62
Truly Monstrous Hairy Orangutans?

Re: Bugged by automatic maze navigation

Posted: Tue May 28, 2019 2:05 am
by mwieder
Teresa May Topples Over?
Too Many Trade-Offs?

Additionally, the random(n) function returns an integer between 1 and n, not zero and n.

Re: Bugged by automatic maze navigation

Posted: Tue May 28, 2019 7:58 am
by richmond62
Additionally, the random(n) function
indeed, and fixed in newer recension . . . 8)

Re: Bugged by automatic maze navigation

Posted: Tue May 28, 2019 2:30 pm
by dunbarx
Mark.

You seem to be stuck in a "TMTO" loop.

Craig