Manual


"Train" is a completely visual programming language.

App instructions

The Train App has two modes: "Freeplay" and "Levels".

Freeplay

Freeplay allows users to make whatever Tracks they want simply by drawing them on the screen. To draw Tracks, click on the track button and then draw on the carpet. Tracks are made when a user draws completely across one square based on where the drawing entered and left the square. To make wyes and crosses, draw over an existing track. Tracks can be straight, 90 degree turn, or 45 degree turn.

Stations are made by clicking on a track and choosing from the popup menu. Stations can only be added to straight tracks

Wyes are made by drawing over a track in another direction. Spring wyes are default and can be altered in direction by swiping. Other types of wyes can be chosen by clicking on the wye and choosing from the popup menu.

Engines and cars can be drawn on the tracks by clicking on the button and then drawing a short segment on one track. Adjacent cars and egines are automatically connected. A train can only have one engine but unlimited cars.

Tracks can be deleted by clicking on the delete button and rubbing over tracks. All tracks can be cleared by pushing the trash button.

An advanced button bar is available by clicking on the Gear Icon on the Home page and then on the double wide menu bar button. The advanced menu offers save and load bins for storing and retreiving Tracks. It also allows Tracks to be imported and exported as text. The lock button allows a track to be protected from being altered.

The canvas can be zoomed by pinching on a tablet or option-click on computer. It can be panned by a two-finger drag on tablet or shift-click on a computer

Levels

Levels mode offers a series of 8 levels with 10 tracks each. Each track is locked until the previous one is solved. The levels get progressively more challenging.

Language specification

Engines

Engines represent threads in Train. They pull cars. Each train can have only one engine but unlimited cars. Engines can be anywhere in a train as long as the engine and all cars are connected. Engines have adjustable speed and can go forward and backward. If a train crashes, its engine and all of its cars disappear.

Cars

Cars represent memory in Train. Each car can hold one cargo of any type.

Cargo

Cargo represent the values stored in memory (i.e. on train cars). There are several data types in Train.

Blocks

Numbers

Lowercase

Uppercase

Colors

Dinosaurs

Binary

StuffedAnimals

Wyes

Wyes are when the track forks or branches. They can be used to connect or branch different parts of the track and to add logic. There are several types of wyes

Sprung Wyes

Sprung wyes are the default. They always cause the train to move in the direction shown by the arrow. This direction can be altered by swiping the lever.

Lazy Wyes

Lazy wyes turn the train in the direction shown by the arrow if entering in the diverging direction, but if the train enters in the converging direction it will switch the direction of the wye to the direction the train came from.

Prompt Wyes

Prompt wyes ask the user what direction to go each time the train enters

Random Wyes

Random wyes turn the train left or right randomly each time

Alternate Wyes

Alternate wyes switch in direction each time a train passes.

Equal Wyes

Equal wyes turn the train left if the cargo adjacent to the wye is equal to the first instance of that type of cargo on the train, otherwise right. If no cargo exists on the wye then it is added from the train. If there is not a type match then it goes in the default position shown by the arrow.

Lesser Wyes

Same as above except less than or equal to goes left

Greater Wyes

Same as above except greater than or equal goes left

Stations

Stations allow actions to be performed on cargo. Stations are generally type specific (they will ignore cargo of different types). Stations generally only act once per train each time it passes.

Supply

A supply station will add a copy of its cargo to the first empty car on a train. If there is no cargo on the supply station, then the first cargo from the train will be added.

Dump

A dump station will delete the first instance of a cargo on the train of the same type as on the station. If there is no cargo or no associated station, it will be cargo type independent and thus delete the first cargo on the train.

PickDrop

If there is cargo on a PickDrop station, it will be transfered to the first empty car. If there is no cargo on a PickDrop station, then the first cargo on the train will be transfered to the station.

Increment

An Increment station will increase the value of the first cargo on a train of the same type as on the station. If there is no associated cargo with the station, then the first cargo on the train will be incremented.

Decrement

A Decrement station will decrease the value of the first cargo on a train of the same type as on the station. If there is no associated cargo with the station, then the first cargo on the train will be decremented.

Add

If there is cargo on an Add station, then the station will replace the cargo on a train with the sum of the train's cargo and the station's cargo. If there is no cargo on the Add station then the first cargo from the train will be transfered to the station. Only the 1's place of the value is kept (i.e. the modulus is taken).

Subtract

If there is cargo on a Subtract station, then the station will replace the cargo on a train with the difference of the train's cargo and the station's cargo. If there is no cargo on the Subtract station then the first cargo from the train will be transfered to the station. Only the 1's place of the value is kept (i.e. the modulus is taken).

Multiply

If there is cargo on a Multiply station, then the station will replace the cargo on a train with the product of the train's cargo and the station's cargo. If there is no cargo on the Multiply station then the first cargo from the train will be transfered to the station. Only the 1's place of the value is kept (i.e. the modulus is taken).

Divide

If there is cargo on a Divide station, then the station will replace the cargo on a train with the quotient of the train's cargo and the station's cargo. If there is no cargo on the Divide station then the first cargo from the train will be transfered to the station. Only the 1's place of the value is kept (i.e. the modulus is taken). If the divisor is zero, then the result is "i" (infinity).

Slingshot

A Slingshot station pushes the first cargo on a train of the same type one space away from the station.

Catapult

If there is cargo on a Catapult station, then the first cargo of the same type on the train will be moved a number of squares corresponding to the value on the station. If there is no cargo on the station then the first cargo will be transfered.

Home

The Home station is used in Levels mode as the destination for delivering the stuffed bear.

Magic Tunnels

When a train enters a Magic Tunnel, it is transported to the same color tunnel that is farthest away where it exits in the same direction with respect to the arrow on the tunnel as it entered. When it re-enters the tunnel it is transported back. Tunnels act as goto or function statements in Train.

Please send comments to: comments@train-hub.org


Home