User:Dragoneater67/wipwipwip/He, wrd!

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.

He, wrd! is an esolang made by User:Dragoneater67 based on Lottery scheduling.

Overview

Execution

The program is structured like this:

N I_0 I_1 I_2 ... I_n

Where N is the amount of tickets the line has, and I_n are the instructions on that line where n is the ID of that instruction. Each line has its own independent instruction pointer. The execution starts with choosing a random ticket, and executing the instruction that the instruction pointer points to at the corresponding line, then the instruction pointer is moved right (it wraps around if the end is reached), this process repeats until every line has been halted.

Memory

The memory is a weighted graph where each vertex stores a single uint8 value. The weight represents the amount of tickets the connected vertex has. The graph is empty by default and the first vertex has ID 0. Any attempt at operation on an empty graph is ignored.

Instructions

Here is an overview of instructions:

Instructions
Instruction Description
. Creates a vertex with an ID that is the successor of the previous one.
|x:y:z Adds a directional edge that connects vertex x to vertex y with weight z. If that edge already exists, it is overwritten.
^ Chooses a random ticket from all of the edges that connect the current vertex to an another vertex, and move to the corresponding vertex. (Does not move when there is no connection to other vertices)
-x:y Decrements the value at the current vertex by x and jumps to instruction ID y if the value is not 0. (IP does not move after jump)
+x Increments the value at the current vertex by x.
> Inputs into the current vertex as an ASCII character.
< Outputs the current vertex as an ASCII character.
&x:y Copies line x and places it after line y
*x:y Sets amount of tickets at line x to y
; Halts the current line.

Magic

The language has a few magic symbols. They can substitute parameters in commands. They can be written as standalone characters like x. If it is written with a number at the front (xn), it equals to x + n, if the number is at the back (nx), it equals to x - n. Here is a list of magic numbers:

  • # equals to the ID of the most recently created vertex, equals to -1 if there are no vertices.
  • ? equals to a random number from 0 to 256.
  • $ equals to the current instruction ID.
  • @ equals to the ID of the current vertex, equals to -1 if there are no vertices.
  • % equals to the current line number.
  • / equals to the last line number.
  • \ equals to the amount of tickets at the current line.

Examples

Hello, World!

1 . +72 < +29 < +7 < < +3 < -67 < -12 < +55 < +24 < +3 < -6 < -8 < -67 < -23 < ;

Cat program

1 . > < -0:1 ;

XKCD Random Number

1 . +52 < ;

Computational class

This is still a work in progress. It may be changed in the future.

He, wrd! is probably Turing-complete, but that has not been proven yet.

See also

External resources

This is still a work in progress. It may be changed in the future.