Bugged by automatic maze navigation

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Bugged by automatic maze navigation

Post by richmond62 » Sun May 26, 2019 7:00 pm

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
Attachments
BBUG MAZE.livecode.zip
Here's the stack.
(166.25 KiB) Downloaded 220 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Bugged by automatic maze navigation

Post by dunbarx » Mon May 27, 2019 5:57 am

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Bugged by automatic maze navigation

Post by richmond62 » Mon May 27, 2019 6:03 am

MY code is what fusses me. 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Bugged by automatic maze navigation

Post by richmond62 » Mon May 27, 2019 8:44 am

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Bugged by automatic maze navigation

Post by richmond62 » Mon May 27, 2019 9:42 am

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 . . .

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Bugged by automatic maze navigation

Post by [-hh] » Mon May 27, 2019 10:04 am

TMHO a good summary of solving algorithms:
http://www.astrolog.org/labyrnth/algrithm.htm#solve
shiftLock happens

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Bugged by automatic maze navigation

Post by richmond62 » Mon May 27, 2019 1:46 pm

Truly Monstrous Hairy Orangutans?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Bugged by automatic maze navigation

Post by mwieder » Tue May 28, 2019 2:05 am

Teresa May Topples Over?
Too Many Trade-Offs?

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Bugged by automatic maze navigation

Post by richmond62 » Tue May 28, 2019 7:58 am

Additionally, the random(n) function
indeed, and fixed in newer recension . . . 8)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Bugged by automatic maze navigation

Post by dunbarx » Tue May 28, 2019 2:30 pm

Mark.

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

Craig

Post Reply