programs | ||
src | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
README.md | ||
rustfmt.toml |
marble "programming language"
Source code is ascii art that describes a marble track. Marbles carry one byte of data each and move around interacting with parts of the board. Marbles can be created and destroyed arbitrarily by the various operators.
physics
Marbles (o
) start out moving down (unless emitted by something).
Colliding marbles will start moving in opposite directions. They don't do this if both have the same direction, meaning you can stack marbles up against an obstacle without them bouncing backwards
power
Power is only created by marbles moving over triggers (*
), and then spreads via wires (|-+
). The connections are not symmetric, so diodes can effectively be constructed to separate parts of a circuit.
In the example below, the left input would activate both printers, but the right input would only trigger the right printer.
* *
+-|
P P
symbols
^v<>
Arrows: changes a marbles direction and moves it to the front, as long as there is a free space in the target location (or the marble is already at the target location)\/
Mirrors: reflects marbles like an arrow, but depending on the incoming direction#
Blocks: block marbles from moving further, without changing their direction|-+
Wires: powers adjacent tiles when powered, in the directions indicated*
Trigger: powers all 4 adjacent tiles when a marble moves over itF
Flipper: flips the direction of a wire, arrow and mirror tiles when poweredB
Bag: consumes marbles that move into it, and keeps count of how many marbles it has. When powered, it emits an empty (0) marble moving away from the bag.ASMDR
Math: Add/Subtract/Multiply/Divide/Remainder of the marble on the left and the right relative to the powered direction. Outputs a marble forward as long as at least one input existsLG=!
Logic gates: compare the left and right input (both treated as 0 if absent) and power forward if Left is Less/Greater/Equal/Not Equal with RightP
Print: Prints the value of the front marble when poweredI
Input: Outputs a marble with the next byte from the program input stream, if there are any0123456789
Digits: decimal digits are added to a marbles value after multiplying the marble with 10, this means that a marble passing over123
would contain the number 123 afterwards. Digits are consumed by marbles passing over them.
TODO: rename to something more unique, there are already multiple esolangs called Marble(s)