User:Kiken/Construction Site/Descriptions/Train

From Esolang
Jump to navigation Jump to search

This page is a draft for my esolang, Train.

Not to be confused with TRAIN!.

Train is a two-dimensional esoteric programming language created by User:kiken.

Overview

Train consists of a single train (the instruction pointer) that is moving across a track. It is constantly moving forwards, and once the train is no longer on the track, it is derailed and the program halts - note that if a train comes across a 90° turn, then it won't turn and will also be derailed. The trail begins at the top-left corner of the program.

Memory in Train is an two-dimensional grid of bits that is unbounded in the up and right direction. At the bottom of the memory grid, there is an eight-bit-long tape named smoke chamber that is used for output. The memory pointer by default, the pointer is at the bottom left of the memory grid, in the smoke chamber.

Carriages

A carriage in Train is represented with a single ~ and can hold a single unbounded number. A carriage comes at the start of a program and signifies that the train should have a carriage (a train can only hold one carriage).

Stations

Stations in Train consist of squares and appear to the side of the track. If the train encounters a station, the station will be executed. Stations look like this when the adjacent rail is horizonal:

[ code ]

and this when the adjacent rail is vertical:

^

code, but vertical

v

The code in the stations are read from left to right and can be unbounded. The instructions depend on the train's direction.

Instructions when train facing left

Instruction Description
! Flip the bit at the memory pointer
# Move the memory pointer according to the train's direction

Instructions when train facing right

Instruction Description
! Set the cell at the memory pointer to the OR gate of this cell and the one above it
# Output the smoke chamber as ASCII

Instructions when train facing up

Instruction Description
! Output the smoke chamber as decimal
# Set the cell at the pointer to the AND gate of this cell and the one above it

Instructions when train facing down

Instruction Description
! Output the number on the train's carriage as ASCII
# Increment the number on the train's carriage if the cell at the pointer is 0, else decrement.

Rail

Self-explanatory.

Rails in Train consists of the following:

Rail type Description
- Horizontal
Vertical
/ Turn (also acts as a diagonal track)
\ Turn (also acts as a diagonal track)
+ Junction - if cell at pointer is 0, then train goes vertical, else go horizontal

There is also a special rail - ^ - which gets input and places it's ASCII value in the carriage.

Examples

Infinite loop

-------\
  /    |
  |    |
  \----/

This example also shows how a diagonal track can merge onto a horizontal or vertical track.

Cat program

--^---\
 /    |^
 |    |
 |    |!
 |    |
 |    |v
 \----/