To execute DBN programs we need the DBN programming environment, available on the DBN website. It can be downloaded and executed on various platforms because it is written in Java. Even more simply, the environment can be run directly from the website as a Java applet, within a web browser. I use the applet instead of the downloadable version, because the latter freezes occasionally on my machine, maybe due to the fact that it is shipped with an old Java runtime engine.

The DBN environment has three panes: you write the program on the right pane, press the play button on the top pane, watch the output on the left pane, and press the stop button on the top pane to stop the execution. That’s all!

When the play button is pressed, the DBN environment checks if the program we wrote has some spelling, syntactic or grammar error. If so, the line in the program with the error is highlighted and an error message appears over the right pane. Unfortunately, the message is not always clear about what the error is, and the message only appears if the mouse cursor was left over the play button after pressing it. A slight nuisance…

This tutorial will show side by side the programs and their resulting output. As said in the previous post, just click on the empty square next to the program’s code to start running it. Feel free to copy and paste the programs into the DBN environment to further tinker with them and produce your own variations. The downloadable DBN environment has buttons to open and save DBN programs, but if you’re using the applet on the DBN website, to save your changes just select and copy the program as you would do with any other text in your particular browser, and paste it into some text editor, where you can save it to a file.

Without any further ado, here’s again the program shown in the previous post, now with its code.

// attached
// version 1, 9 Nov 2008, Michel Wermelinger
// cursor is attached to origin

forever
{
   set x <mouse 1>
   set y <mouse 2>
   paper x
   pen (100-x)
   line 0 0 x y
}

The program will only make sense after a few of these tutorial lessons, but for the moment let’s use it to try out the environment. Paste the above code into the right edit pane of the environment, run the code to make sure everything’s fine, and then stop execution. Then change the two zeros to two y’s, so that it reads

line y y x y

Run the program again. You should obtain the following (click within the square):

The program’s title hasn’t been changed. This begs the question: what is the mouse cursor now attached to? It may not be immediately apparent, but part of the appeal of interactive computational art is exactly the trial and error exploration to formulate a hypothesis about the program’s logic. After a while, it should dawn on everyone that the cursor is ‘attached’ to the diagonal that goes from the bottom left corner to the top right corner.

In the next lesson we’ll look more closely at the line command that appears in the program above.

3 Comments to “DBN tutorial: Getting started”

  1. Leon De la Rosa says:

    Hi, I wrote to you a few weeks ago, now I bother you again with a new question. We’re trying to set up a gallery of pieces created in DBN for a class project, but the programs run super slow in the web… DO you know if there is anything we can do to alleviate this? all the codes do have “fast” in them.
    here’s an example of what we’re uploading:

    http://leondelarosa.org/dbn/rizos.html

    Thanks

    Suerte
    Leon

  2. Leon De la Rosa says:

    Thanks for the QR Michel, I tried including the fast within the forever loop, and DBN just ignores it… Ia also went into the preferences file and included the “slowdown=false” line in it, and nothing really changed. I did try what you mentioned on the online DBN about commenting out one of the loops and it worked wonderfully, that’s the reaction speed we’re trying to get at… I guess I’m gonna try to load the whole editor applet in the gallery and see if that helps any… I don’t even know if we’ll be able to do that, but we’ll try and I’ll let you know…

    Thanks
    Leon

  3. mw says:

    Hi Leon,

    I opened the page you mention and the speed seems fine to me. Note that it takes some time for the lines to appear from the top right to the bottom left because most of the lines (the A and B loops) are drawn outside the 100×100 square. Just to be sure, I copied the code into the online DBN editor at MIT, and after I commented out one of the loops and commented in again, then suddenly the speed increased phenomenally. It seems the ‘fast’ directive is ignored the first time the program is loaded. I don’t know how to work around this apparent DBN bug: maybe put the directive within the forever loop so that the interpreter is forced to take notice of it? Let me know if it worked.

    Michel

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free