bricklayer-lite

Bricklayer-lite is a web app that provides a block-based coding environment for creating Bricklayer programs. Bricklayer-lite runs on any web browser and can be accessed from any device such as a smart phone, tablet (e.g., iPad), or laptop.

bricklayer-lite version Comment
Level 1 Before creating a program, complete Vitruvia concepts 5 - 7.
Level 2 Before creating a program, complete Vitruvia concepts 10 - 13.
Level 3 Before creating a program, complete Vitruvia concepts 14 - 15.

A web app, called Vitruvia, provides an understanding of the constructs used to create bricklayer-lite programs. Through interactive self-guided exercises, Vitruvia developes an understanding of coordinate systems as well as the syntax and semantics of Bricklayer functions (e.g., putting a LEGO brick of a particular size and color at a given coordinate). Vitruvia exercises also develop a basic understanding of various constructs of the functional programming language SML - the language in which bricklayer-lite (and Bricklayer) programs are written.

Bricklayer-lite programs are pictoral in nature and are constructed by fitting together blocks. Depending on the technology used (e.g., laptop, smart phone), blocks can be selected via mouse-clicks or by touch. Some, through very little, typing (i.e., data entry) is required when constructing a bricklayer-lite program. For example, to place a brick at a specific location requires entering, via a keyboard, the coordinates of that location.

Bricklayer-lite programs can be executed by selecting the run button. They can be saved to the cloud and retrieved at a later time or from another device. To save a program, simply select the save button. Important: when saving, be sure to record (e.g., copy and paste) the resulting URL displayed on your browser. Entering this URL to a browser will retrieve your bricklayer-lite program from the cloud.

The execution of a well-formed program produces a graphical artifact that is displayed in the canvas adjacent to the editor. After execution, the text of the corresponding Bricklayer program will be displayed in the pane below the editor. This text can be copied and pasted into a text editor (e.g., notepad++) and the resulting program can be saved (with a dot-bl extension) and executed using the Bricklayer system with results displayed in LEGO Digital Designer (or in Minecraft). Below is an example of an artifact created by a bricklayer-lite program. The bricklayer-lite code for this example as well as other coding examples can be found here.

Constructing Bricklayer-lite Programs

All bricklayer-lite programs begin with an open block and end with a show block. These two block pieces must be completed by a semicolon block as shown below. All bricklayer-lite programs must also contain a build block which also must be completed by a semicolon block.

The open block provides access to a set of functions and language constructs which can be used to construct bricklayer-lite programs. The build block declares the size of the (square) canvas in which one can build an artifact. A drop-down menu, in the build block lets the programmer select the size of the canvas (e.g., (2,2), (4,4), (8,8) and so on) upon which the artifact is to be created.

The execution (through the selection of the run button) of a bricklayer-lite program creates a graphical artifact. The show block displays, on the canvas declared by the build block, the artifact created by the program.

The Comment Block

The comment block provides a mechanism for inserting human-readable text into a program. Comment blocks are available in all levels and are ignored during execution. They can be placed anywhere they fit. A comment block is shown below. Comments initially consist of a row of equal symbols. However, these symbols can be replaced with text entered from a keyboard.

Due to the way comments are treated by compilers, bricklayer-lite considers comment blocks to be a form of symbol. For this reason they are grouped with other symbol blocks like the semicolon block.

Constructing Bricklayer-lite Level_1 Programs

In addition to the open, build, show, semicolon, and comment blocks, bricklayer-lite Level_1 provides a variety of "put blocks" for constructing artifacts. In Level_1, each put block must also be completed by a semicolon block. When executed, these blocks place 2D approximations of LEGO bricks, having certain shapes and colors, at coordinates input by the programmer.

In Level_1, only a small number of brick shapes and colors are available. The figure below is a bricklayer-lite program fragment illustrating the kinds of put blocks that are available. Note that coordinate values in these blocks (e.g., (0,0), (1,0), and (3,0)) need to be input by the programmer using a keyboard.

In Level_1, put blocks may only occur between the build block and the show block. Below is an example of a Level_1 program adjacent to the artifact it creates. The code for this program can be found here.

The put blocks in Level_1 are instances of a languge construct known as a function call. These put functions are declared within bricklayer-lite and made available for use through corresponding blocks.

Constructing Bricklayer-lite Level_2 Programs

The blocks that can be used to construct Level_2 programs are a strict superset of the blocks used to construct Level_1 programs (e.g., all blocks that are available in Level_1 are also available in Level_2). New blocks include: (1) blocks for declaraing and calling user-defined functions, (2) blocks for altering coordinates through offsets, and (3) blocks for creating circles and rings.

Vitruvia concepts 10 and 12 introduce user-defined function declarations and function calls. The bricklayer-lite blocks corresponding to these language constructs are shown below.

In Level_2, only two kinds of user-defined function declarations are possible. The first form of declaration is used to declare a nullary function - a function that has the unit value () as its only parameter. The second form of declaration is a function that accepts an 2D coordinate as its input. In order to be well-formed, a function declaration block must be completed by semicolon block.

In Level_2, the body of a function declaration (nullary or otherwise) consists (exclusively) of a list of semicolon separated function calls. Function calls include calls to put functions (declared by bricklayer-lite) as well as calls to user-defined functions. Important: the block corresponding to the last function call in the body of a function declaration must be completed by the empty block symbol shown below.

When called, nullary functions always produce the same artifact. As such, their primary use is a language mechanism for conceptually grouping function calls. An example of a nullary function declaration that, when called, creates the flag of Denmark is shown below. Note that the user-defined function is called flagOfDenmark and that the last function call block in its body is completed by the empty symbol. The code for this example can be found here.

Offsets

Vitruvia concept 11 introduces Bricklayer functions for manipulating offsets. Offset functions can be called to shift the origin of the coordinate space. When combined with user-defined nullary functions, offsets can be a very powerful mechanism for creating patterns. The offset blocks, corresponding to offset function calls, provided by bricklayer-lite are shown below.

In the example below, a nullary function named flag is declared which, when called, will create a flag of Denmark whose lower left corner is at the coordinate (0,0). The function setOffset2D is then called to shift the origin (i.e., (0,0)) to the postion (0,8). The call to the function flag that follows this call to the function setOffset2D will create a flag of Denmark whose lower left corner is at the coordinate (0,8). The code for this example can be found here.

Bricklayer-lite Programs Containing Errors

It is possible to construct an ill-formed program in bricklayer-lite. In this case, an error message will be displayed in the pane below the editor.