Live data from Hacker News

Google Blockly - a visual programming language

code.google.com

1–10 of 129 posts

Re: Google Blockly - a visual programming language

#6

I can't seem to find the end condition for the Maze demo. There is no 'goal_reached?'

When I solved it, the program just stopped running.

My browser crashes presumably because I use 'while true'. Chrome Version 19.0.1084.52

Re: Google Blockly - a visual programming language

#7

The UI for this reminds me a lot of Scratch from MIT.

Indeed. I wrote a similar framework in Actionscript / Flex a few years ago, actually with a lot of input from the Scratch team. I've been thinking about porting it to JS recently. Glad to see someone beat me to it :)

Edit: Here's my old Actionscript library in case anyone is interested. https://github.com/trun/flashblocks

Re: Google Blockly - a visual programming language

#8
post #4

Can this program be made any shorter? http://www.dodaj.rs/f/1K/vW/2gLz63rl/blockly.png

An "else" would help; you can add one by hitting the + symbol on the if. With the else, you can get the shortest program that'll solve the maze (transcribing using approximate notation in lieu of a screenshot):

    while True:
        if wall(AHEAD):
            turn(LEFT)
        else:
            move(FORWARD)
            turn(RIGHT)
However, the addition of one more if makes the solution much faster and look more sensible, by not turning to the right and immediately back to the left:

    while True:
        if wall(AHEAD):
            turn(LEFT)
        else:
            move(FORWARD)
            if not wall(RIGHT):
                turn(RIGHT)
Post reply on HN