Streetcode

From Esolang
Jump to navigation Jump to search

Streetcode is a two-dimensional esolang by User:PythonshellDebugwindow. Its syntax resembles a network of streets.

The car

The car, which works like an instruction pointer, navigates through the streets.

Memory

Streetcode uses unbounded signed integer cells and a cell pointer, referred to as CP which starts at 0 like all of the cells. The CP is unsigned and right-unbounded.

Streets

All streets are two-way. They are two characters wide. The car always drives on the right-hand side. The characters the car pass over while driving are instructions.

Character Effect
^ Increment CPth cell
~ Decrement CPth cell
= Increment CP
_ Decrement CP
; Halt the program
I Set Nth register to user input character
O Output Nth register as character
U Turn the car around
space Nop

Therefore this:

+----+
|    |
|CIO;|
+----+

would drive on the whole right-hand side of the street, stopping only when the semicolon (halt command) is reached, and copying a user input character to output along the way. The C character represents where the car starts; exactly one of these must appear in each program.

This is an infinite cat:

+----+
|UOI |
|CIOU|
+----+

The Us can be replaced with spaces in this case.

Dead ends

If the car reaches a dead end, it will turn around.

Ambiguous turns

If a street has more than one possible turn (e.g., it's at an intersection), the leftmost road will be driven down if the CPth cell is equal to zero otherwise the second-leftmost one will be. Leftmostness is relative to the direction the car is driving, treated here as down.

Examples

Infinite loop

+-------+
|       |
|C      |
++  ++  |
 |  ++  |
 |      |
 |      |
 +------+

Infinite cat for single characters

+--------+
|        |
|C^      |
+-+IO++  |
  |OI++  |
  |      |
  |      |
  +------+

Why wouldn't this be a cat?

Turing-completeness proof

Streetcode is Turing-complete, as ambiguous turns provide control flow and it has unbounded memory through < and >.