News for hackers. Stuff that matters.
Re:Google Blockly - a visual programming language by saurik on Friday June 01, 2012 @03:22AM (#4052371)
If you started off facing a wall your code would just not do anything. You can both simplify it and fix this bug by reorganizing the loop.

    while true:
        turn left
        while wall(AHEAD):
            turn right
        move forward
However, while this algorithm happens to work on this maze, it will not work against other mazes (if you care).

Imagine a 5x5 square race track, with spokes coming from the outside of the wheel to the center, where there was a flag. Your algorithm (and my modified one) would just spin clockwise around the track without ever realizing it should take a right towards the center.

There are no comments on this comment yet.