Tile
Tile is a two-dimensional language made by User:Dtp09. The language's programs consist of a grid of "tiles" that each contain four smaller "subtiles", and each of those subtiles being either black or white to represent binary data. The data in the tiles represent commands that are executed as the program runs. The program counter starts on a start tile (determined by a completely black tile somewhere the program) and follows a path, executing commands as it follows said path. If the program counter has too many possible places it could go, it encounters a dead end, or a few other things happen, the program will terminate.
Tile uses unsigned 8-bit integer storage. It uses an unlimited stack, a memory with 2^16 cells, an ASCII input that can be read up to 2^16 character, and an ASCII output.
Commands
Below is a list of every combination that a tile on the grid could have. Stack values will be referred to by s1, s2, and s3, meaning top stack value, 2nd top stack value, and 3rd top stack value respectively. If there is no value in the stack position, it will assume 0.
Tile | Name | Description |
---|---|---|
Empty | Negative space. | |
░░ | No-op | No operation. Mostly used for routing a path for the program counter. |
░▄ | Write | Writes s3 to 16-bit memory location 0x[s2][s1]. |
▄░ | Subtract | Pops s1 and s2, pushes s2 - s1. |
▄▄ | Jump | The program counter will "jump" over the next tile. Useful for entering loops, joining two paths, or for other scenarios. |
░▀ | Read | Pops s1 and s2, pushes value from 16-bit memory location 0x[s2][s1] to the stack. |
░█ | Input | Pushes the ASCII code of an input character in an index determined by 16-bit value 0x[s2][s1]. |
▄▀ | Multiply | Pops s1 and s2, pushes s2 * s1. |
▄█ | Greater | if s2 is greater than s1, move the program counter to the right path. Else, move to the left path. |
▀░ | Push | Push a value to the stack, using the relative sides of the tile as binary data. |
▀▄ | Random | Program counter randomly moves in any of the 3 available directions. |
█░ | Add | Pops s1 and s2, pushes s2 + s1. |
█▄ | Less | if s2 is less than s1, move the program counter to the right path. Else, move to the left path. |
▀▀ | Output | Outputs s1 as an ASCII charater then pops it. |
▀█ | Equals | If s2 is equal to s1, move the program counter to the right path. Else, move to the left path. |
█▀ | Divide | Pops s1 and s2, pushes quotient of s2 / s1, then pushes remainder. |
██ | Start/Debug | This is where the program counter will start. During execution, it will act as a debug, printing exection info to the interpreter console. |
Explanations
Which Tile is the Start Tile
You can have multiple start tiles (██) in a single program. The program counter will begin at the one furthest to the left, then the one furthest up.
Push
The Push command (▀░) reads the binary data from the tiles to the sides relative to the rotation of the program counter (the direction it is moving in). Binary data is read with the uppermost/leftmost tile as the upper four bits, and the bottommost/rightmost tile as the lower four bits. If there is only one (non-empty) tile on the relative side of the Push tile, it will assume a byte with the upper four bits unset. A push command with no (non-empty) tiles to its relative side will push 0.
Push commands cannot lead paths to the left or right. They can only continue in the direction they are going in.
Random
Random (▀▄) will have the program counter take any of the available paths it could take and picks a random one to travel. You can also use 2 paths and it will refuse to take the one with an empty tile. You can even allow it a singular path, which would be equivalent to a no-op.
No-op vs Empty
It is important to know the difference between No-op (░░) and Empty ( ). No-op is shown with the subtile divider, and empty has nothing in it. Empty is treated as negative space, there is nothing there, but No-op can be used in paths or in push values and is not negative space and not empty.
Execution End
Execution will end if any of the following happens:
- Division by 0
- Program counter has too many possible places it can go (depends on current tile)
- Attempt to move program counter out of bounds
- Attempt to move program counter onto an empty tile
Why are your programs padded with empty tiles
I think it makes it look nicer, but it is never required.
Code Examples
Truth Machine
Just to warn you, inputing 1 will crash the site. That is the nature of an infinite loop.
Hello, World!
Nope.
Cat
Textile
Textile is an attempt at a written form of tile. It uses an assembly-like syntax and has many of the same functionalities as Tile. Its information can be found here.
Interpreter
An interpreter was created in HTML+Javascript and is hosted here.
Save Code Format
A Save Code is a code that can be used to save and load grid data. Save Codes have been implemented since version 1.1. They take the contents of the grid, put it in text form, then encode it to Base-64 text.
Decoded from Base-64, the code is stored like this:
(width);(height);(grid data)
The "grid data" refers to the tiles themselves. Each tile is stored in one byte with its contents in the lower four bits. The exception to this is Empty, which is stored as 10000, and no-op which is stored as 10001, as a zero-byte character wouldn't encode for some reason. Every tile is stored in order, filling the grid from top left to right then down a row.
Update Log
The interpreter update log is located at Tile/Update Log