Note that there are some explanatory texts on larger screens.

plurals
  1. POcomputing the shortest distance of a maze with the boe-bot in Pbasic
    primarykey
    data
    text
    <p>I'm working on a project with a robot called the boe-bot. </p> <p>My goal is to traverse through a maze twice. On the first run, my boe-bot transverses through the maze storing the paths taken in memory. On the second run, it has all the paths stored in memory and deletes the bad paths that lead to dead ends -- so the boe-bot can take the shortest path to the end of the maze. </p> <p>In order to do this, I need to create replacement rules to parse out bad routes that lead to dead ends. </p> <p>I created a code in pbasic but my code gets errors. Is there anyone out there that can help me out with this? </p> <pre><code>' {$STAMP BS2} ' {$PBASIC 2.5} ' -----[ Variables ]---------------------------------------------------------- turn VAR Word turns VAR Word pointer VAR Byte ptr VAR pointer 'create an alias for pointer ' -----[ Main Routine ]------------------------------------------------------- DO ' Begin main routine ptr = 0 'Points TO the NEXT available position in the array. turns(ptr) = turn 'This puts an L in the first position of the array or left turn in array ptr = ptr + 1 'Add one TO the pointer so the NEXT letter goes in the NEXT position in the array. IF (turns &lt; 3)THEN 'Array needs at least three characters for this algorithm to work RETURN IF (turns(3)(ptr) - 1 &lt;&gt; "U")THEN 'EXIT IF the NEXT-TO-last turn is NOT a U-Turn RETURN IF (turns(3) = "LUL") 'Look at the right three characters in the array Left U-Turn Left ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(ptr) = "S" 'The turn we should have taken (AND will take NEXT time. ptr = ptr + 1 'set up the pointer TO point TO the NEXT character in the array. IF (turns(3) == "LUR") 'Look at the right three characters in the array Left U-Turn Right ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(ptr) = "U" 'The turn we should have taken (AND will take NEXT time. ptr = ptr + 1 'set up the pointer TO point TO the NEXT character in the array. IF (turns(3) == "LUS") 'Look at the right three characters in the array Left U-turn Straight ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(ptr) = "R" 'The turn we should have taken (AND will take NEXT time. ptr = ptr + 1 'set up the pointer TO point TO the NEXT character in the array. ' Increment/decrement routine only changes pulse durations by 2 at a time. IF (turns(3) == "RUL") 'Look at the right three characters in the array Right U-turn Left ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(ptr) = "U" 'The turn we should have taken (AND will take NEXT time. ptr = ptr + 1 'set up the pointer TO point TO the NEXT character in the array. IF (turns(3) == "RUR") 'Look at the right three characters in the array Right U-turn Right ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(ptr) = "L" 'The turn we should have taken (AND will take NEXT time. ptr = ptr + 1 'set up the pointer TO point TO the NEXT character in the array. IF (turns(3) == "RUS") 'Look at the right three characters in the array Right U-turn Straight ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(ptr) = "L" 'The turn we should have taken (AND will take NEXT time. ptr = ptr + 1 'set up the pointer to point to the NEXT character in the array. IF (turns(3) == "SUL") 'Look at the right three characters in the array Straight U-turn Left ptr = ptr - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(ptr) = "R" 'The turn we should have taken (AND will take NEXT time. ptr = ptr + 1 'set up the pointer TO point TO the NEXT character in the array. IF (turns(3) == "SUR") 'Look at the right three characters in the array Straight U-turn Right pointer = pointer - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(pointer) = "L" 'The turn we should have taken (AND will take NEXT time. pointer = pointer + 1 'set up the pointer TO point TO the NEXT character in the array. IF (turns(3) == "SUS") 'Look at the right three characters in the array Straight U-turn Straight pointer = pointer - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S turns(pointer) = "U" 'The turn we should have taken (AND will take NEXT time. pointer = pointer + 1 'set up the pointer TO point TO the NEXT character in the array. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload