Learn to Draw in LindenMASM! 08-19-2015, 02:47 PM
#1
Syntax();
Learn to Draw in LindenMASM!
Learn to Draw in LindenMASM!
Table of Contents
- Introduction
- Syntax
- Commands
- Examples
Chapter 1: Introduction
LindenMASM is an esoteric programming language I designed for the purposes of drawing Lindenmayer systems. It uses an Assembly-like syntax, hence the name LindenMASM. The original reason I made the language was for a code-golf challenge, which was to create a LindenMASM interpreter in the fewest bytes possible. Since this was too similar to a challenge that had already been made, I scrapped the idea, but held on to the interpreter.
The interpreter was written in Python 3.4, and does all of the drawing using a Turtle object. You can download the interpreter here.
Chapter 2: Syntax
There are only a few functional keywords in LindenMASM, 8 to be exact.
- STT - Begins every LindenMASM file.
- AXI $ - Sets the axiom (initial state) of the system.
- $ is a series of commands/variables/constants, ranging from the built-ins plus any user-defined functions.
- $ is a series of commands/variables/constants, ranging from the built-ins plus any user-defined functions.
- DEG $ - Sets the degree of which all turns will follow, default is 90.
- MOV $ - Sets the move distance of which all position adjustments will follow, default is 10.
- INC $ - Sets the number of iterations the generation should go through, default is 0.
- SET $ # - Sets a constant $ to a specified command #.
- $ should be a character that is not one of []+-.
- # will either be a 0 or a 1, where a 0 corresponds to the constant being one that draws forward, and a 1 corresponds to the constant being one that moves fowards.
- $ should be a character that is not one of []+-.
- RPL $ # - On every iteration, variable/constant $ will be replaced with the command/variable/constant string #.
- $ should be a character that is not one of []+-. It does not need to be SET to be replaced.
- # is a string of commands/variables/constants that $ should be replaced with.
- $ should be a character that is not one of []+-. It does not need to be SET to be replaced.
- END - Ends every LindenMASM file.
Each keyword should be placed on a new line. Every file should start with STT and end with END.
Chapter 3: Commands
There are only four built-in commands, however with these you can do a bunch of stuff!
- + - Rotates the pointer to the right DEG degrees.
- - - Rotates the pointer to the left DEG degrees.
- [ - Saves the pointer's coordinates and heading to a list.
- ] - Pops the last value of a list and sets the pointer's coordinates and heading to that.
Chapter 4: Examples
Dragon Curve, n = 12
Code:
STT
INC 12
AXI FX
SET F 0
RPL X X+YF+
RPL Y -FX-Y
ENDThis will draw something like this:
Fractal Tree, n = 6
Code:
STT
AXI X
DEG 25
MOV 2
INC 6
SET F 0
RPL X F-[[X]+X]+F[+FX]-X
RPL F FF
ENDThis will draw something like this:
Thanks for reading! The language isn't expansive or anything, but it's fun to play around with!
![[Image: CDUAq9d.png]](http://i.imgur.com/CDUAq9d.png)





![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)