Stones

From Esolang
Jump to: navigation, search

The stones esoteric programming language is a language in which colored stones are moved around a hypothetical field, created by User:Zackh in late 2016 to early 2017.

Operations in stones are carried out by specifying which stone to move where by how much, e.g.;

red up two
red down three
yellow left

Specification

Comments in stones are defined as anything not in the following list of keywords:

  • red
  • orange
  • yellow
  • green
  • blue
  • purple
  • up
  • down
  • left
  • right
  • one
  • two
  • three

Statements

Statements in stones follow the following structure:

color direction [one, two, or three]

A magnitude will only be supplied if color is orange or red.

Instructions

stones instructions are executed according to the following table:

Color Purpose Up Down Left Right
Red x 1 Numbers/booleans 0 1 2 3
Red x 2 4 5 6 7
Red x 3 8 9 true false
Orange x 1 Array ops, boolean [ ] , nth
Orange x 2 == < >
Yellow Math operators * + - /
Green Stack operations roll dup drop not
Blue Input/output print input printc dup
Purple Control flow if else while end

When a stones program is initiated, the field is arranged in a 6x12 grid paddern:

blue-- ------ ------ ------ ------ ------ orange ------ ------ ------ ------ ------
------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
------ ------ red--- ------ ------ ------ ------ ------ green- ------ ------ ------
------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
------ ------ ------ ------ yellow ------ ------ ------ ------ ------ purple ------
------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------

After a command is executed, for example red down one, the field is updated with the new position of red.

blue-- ------ ------ ------ ------ ------ orange ------ ------ ------ ------ ------
------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
------ ------ ------ ------ ------ ------ ------ ------ green- ------ ------ ------
------ ------ red--- ------ ------ ------ ------ ------ ------ ------ ------ ------
------ ------ ------ ------ yellow ------ ------ ------ ------ ------ purple ------
------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------

In stones, stones routinely run in to each other. This can produce different effects. If the stone that it runs into is heavier than that stone, the instruction of the stone movement will not occur. If the stone it runs into is lighter than that stone, the stone it runs into will be moved out of the way, its instruction will be executed, and then the first stone will be moved and its instruction executed.

In the table above, the stones colors are ranked from lightest to heaviest, with red being the lightest and purple being the heaviest.

Examples

A Truth-machine in stones:

blue down                get user input
green down               duplicate input
red up one               push zero
orange up two            check if equal
purple up                if true
    red up one
    blue up              output 0 and terminate
purple down              otherwise
    red up one           move Red to another row
    green left           drop result
    red left three       push true
    purple left          while true
        red down one     push one
        blue up          print one
        red left three   push true
        red right three  move Red out of the way
        red up one
        green left       drop results
        green left
    purple right        end while
purple right            end if

This small program produces the following output for 1:

11111111111111111111111...

Turing-completeness

Ignoring the stack size limitations and side effects of stones running in to each other is (probably) enough to prove Turing-completeness.

However, due to the side effects of stones running in to each other, Turing-completeness of stones is unknown.

Interpreter

An interpreter can be found at the following pages: