Chronos

From Esolang
Jump to navigation Jump to search

Chronos is a two dimensional esoteric programming language based off of Befunge, with the ability to time travel.

Time Travel

Chronos offers the ability for instruction pointers (cursors) to time travel. The language does not track actual time; rather, each execution is thought of as advancing time by one moment. Time starts at moment t = 0.

Chronos uses the branching timelines framework when dealing with time travel. When a cursor travels to a different point in time, a new timeline is created, with its own local cursor. Every cursor contains a local stack, so there may be multiple independent stacks at a given moment. The only output, if any, which is displayed is that which is generated by the finally constructed timeline.

Cursor intersection is permitted, but when two cursors attempt to execute instructions with interfere with one another, the cursor which has most recently time travelled will take priority. This is motivated by the idea that a time traveller goes back in time to correct a prior action, and thus they take priority.

Instructions

> Set cursor orientation to RIGHT.
< Set cursor orientation to LEFT.
^ Set cursor orientation to UP.
v Set cursor orientation to DOWN.
0-9 Push number to stack.
+ Pop a, b, push a + b to stack.
- Pop a, b, push b - a to stack.
* Pop a, b, push a * b to stack.
/ Pop a, b, push b / a (integer division) to stack.
% Pop a, b, push b mod a to stack.
? Pop a, skip the next character if a ≠ 0.
! Pop a, push 0 if a ≠ 0, push 1 if a = 0.
g Pop y, x, push program character at (x,y) to stack.
p Pop v, y, x, place character v at (x,y) in program.
: Duplicate the top stack element.
\ Swap the top two stack elements.
" Toggle string mode.
, Pop a, output character a.
. Pop a, output value a.
i Read input, push to stack.
t Pop a, time travel to time t = a.
@ Stop cursor.

Examples

Hello, World!

>               v
v"Hello World!"0<
>:?v,v
^    <
   @

Back in Time

Travels back in time (placing an "@" end command to prevent an infinite loop of travelling back in time).

>              0t"@"90p@

Bello, World!

Outputs "Hello, World!" in timeline 1 (not displayed), then time travels to timeline 2 and alters character "H" to "B", causing the timeline 2-native cursor to print "Bello, World!".

>                v
v"Hello, World!"0<
>,:?vv
^    <
    >0t"B"21p"@"64p@

Always Wrong

Asks for user input. Then, if necessary, travels back in time so that it asked for the input which the user did not provide.

>                                                             v
v"I have chosen the number 0. Try and input the same number."0<
>,:?vv
^    <
    >i22223****\-     ?vv
v+19"You chose wrong!"0 <
>,:?vv                 >0t"1"999++1p"v"997++6p@
^    <                  ^<
    @

Interpreter

chronos.py

The official interpreter, available at https://github.com/Zasharan2/chronos.