esolang

Chronos

Befunge, except a cursor can go back in time and fix what went wrong.

2024 · Turing complete: unknown · ●●● hard · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello World!

The idea

Chronos is a two dimensional language after Befunge, from 2024. A cursor walks over the program, turning at arrows and working on its own stack. Its one new command is t. It pops a number and sends the cursor back to that moment.

Read the story

Each round in which every cursor takes one step is a moment, and time starts at 0. A trip back starts a new timeline. The program, the cursors and the output go back to how they were at that moment, and the traveller joins them, keeping its stack. So the timeline now has two cursors, the one that was always there and the one from the future. Only the output of the last timeline is shown.

A trip would loop forever if nothing changed, since the cursor that was always there walks to the same t again. So a traveller uses p to change the program before its earlier self gets there.

The machine

CharDoes
> < ^ vPoint the cursor right, left, up or down
0 to 9Push a digit
+ - * / %Pop a, then b, push b op a; / and % round down
?Pop a, skip the next cell if a is not 0
!Pop a, push 1 if a is 0, else 0
g pPop y, x and push the character there; pop y, x, v and put v there
: \Duplicate; swap
"Toggle string mode, which pushes every character
, .Print a character; print a number
iRead a character
tPop a, travel to moment a
@Stop this cursor

The run ends when every cursor in the last timeline has stopped. In each moment the cursors act in the order they arrived, so the latest traveller acts last. An empty stack gives 0 and the program wraps at its edges. A new timeline reads its input from where it stood at the moment it went back to.

Example

Hello World.

Hello World. The second row pushes the text backwards, and the loop prints until it reaches the 0.

The Bello, World. The first timeline prints Hello, World!, then travels to moment 0. There the traveller changes the H into a B and puts an @ where the t was, long before the cursor that was always there reaches either. The second timeline's output is the one shown.

Expected: Bello, World!

Always Wrong asks for the number it has chosen. If the answer is right, it travels back to moment 0 and changes its choice to 1 and its own t into a v, so the second time round it can only say wrong.

Expected: I have chosen the number 1. Try and input the same number. You chose wrong!

Patterns it teaches

Further

Two-dimensional languages

Stack-based

Write your own in Run Convert a program from Chronos

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: chronos.

Command line

shib run chronos -e '>              0t"@"90p@'
shib manual chronos

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/chronos.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org