GRID1
From On-signal: Projects & Research
GRID1 is a special-purpose computer language for describing pixel interactions in a low-res grid.
The language's purpose is to bridge the gap between visualization and code, by providing simple code and a simple visualisation structure (the grid). visualizations and its underlying code.
Contents |
Target architecture
A low-resolution grid of n x m binary pixels. The program language is interpreted, and limited in size to the size of the grid (so, max n x m bytes).
The interface is dualistic: at the same time as it serves as the structure for the visualization of the algorithm, it serves as the visual view (and editor) for the code.
Mode of operation
Although the program is formatted in a 2D grid, it is read as a one-dimensional sequence of instructions. The program cycles infinitely from the start of the program until it reaches the end of the code, starting over again.
The instruction set is built around the idea of the "blip": a kind of drawing pen which can be put down (in "writing mode") and up (in "moving mode"), kind of similar to LOGO.
4 movement operators control the movement of the blip, in the four directions. When a the blip is moved and the blip is on, the state of the current grid pixel is inverted when the blip passes over it.
Blip movement
The shape of the grid is structured in such a way that advancing off the east side of the grid will let the blip re-appear on the west side, but one grid row lower. When proceeding on the last row, the blip is moved to the first row instead.
The same goes for north/south movement.
For the writing behaviour of the blip, one should always keep in mind that only movement operators can write, and on movement, they write the pixel the blip is currently on, and DO NOT write the pixel that is being moved to. So, NORTH 1 always writes 1 pixel.
Operators
- BLIP
- NOBLIP
- NORTH/WEST/EAST/SOUTH N
- WAIT N
Example
An example GRID1 program follows.
BLIP ; NORTH 1; NOBLIP; NORTH 1;
This will fill the grid with a simple checker board pixel pattern (when using a grid with an uneven row count).
NOBLIP; EAST 1; BLIP; EAST 1; NOBLIP; WEST 2; SOUTH 1; BLIP; EAST 1; NOBLIP; EAST 1; BLIP; EAST 1; NOBLIP; WEST 3; SOUTH 1; BLIP; EAST 3; NOBLIP; WEST 3; SOUTH 1; BLIP; EAST 1; NOBLIP; EAST 1; BLIP; EAST 1; NOBLIP; WEST 3; SOUTH 1; BLIP; EAST 1; NOBLIP; EAST 1; BLIP; EAST 1; NOBLIP; WEST 3; NORTH 4;
This will write the letter 'A' in a pixel pattern:
.X. X.X XXX X.X X.X
Note the resetting of the blip position to the top left in order to maintain a stable pixel pattern.
