Bugged by automatic maze navigation
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Bugged by automatic maze navigation
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.
-
but it jerks around all over the place and crosses walls when it shouldn't.
-
- Attachments
-
- BBUG MAZE.livecode.zip
- Here's the stack.
- (166.25 KiB) Downloaded 220 times
Re: Bugged by automatic maze navigation
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:
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
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
This likely sounds easier that it is.
Craig
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Bugged by automatic maze navigation
MY code is what fusses me. 

-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Bugged by automatic maze navigation
Stupid Richmond missed a 'break' inside his 'switch' loop.
- Attachments
-
- BBUG MAZE.livecode.zip
- Here's a working version.
- (165.68 KiB) Downloaded 238 times
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Bugged by automatic maze navigation
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 . . .
not keep bashing its head against walls, and does not keep going
back the way it has come . . .
Re: Bugged by automatic maze navigation
TMHO a good summary of solving algorithms:
http://www.astrolog.org/labyrnth/algrithm.htm#solve
http://www.astrolog.org/labyrnth/algrithm.htm#solve
shiftLock happens
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Bugged by automatic maze navigation
Truly Monstrous Hairy Orangutans?
Re: Bugged by automatic maze navigation
Teresa May Topples Over?
Too Many Trade-Offs?
Additionally, the random(n) function returns an integer between 1 and n, not zero and n.
Too Many Trade-Offs?
Additionally, the random(n) function returns an integer between 1 and n, not zero and n.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Bugged by automatic maze navigation
indeed, and fixed in newer recension . . .Additionally, the random(n) function

Re: Bugged by automatic maze navigation
Mark.
You seem to be stuck in a "TMTO" loop.
Craig
You seem to be stuck in a "TMTO" loop.
Craig