Self-modifying Puzzlang

From Esolang
Jump to: navigation, search

Self-modifying Puzzlang is a variation on Puzzlang. You could shorten the name to S-m Puzzlang, this variation is invented by User:Zzo38

The program code does not wrap around and it is read from left to right on each line. Each symbol can be a digit 0 to 9 or any other symbol. A non-digit is no operation. A digit will be either on or off depending on the other state of the program (see below).

If a symbol is on, the operation depends on how many symbols are on adjacent (in the Moore neighborhood), from zero to eight. The numbers 1 to 8 correspond to brainfuck codes, 0 does something else, as described below. The corresponding codes are:


Operation is then in the order of bytes in the program file; left to right on first line, and then second line and so on. The loop points is according to the current meaning of the symbols in the program, meaning the position of loops can be changed. In some cases it can lead to executing mismatched brackets; the program is terminated in such case if trying to do [ when cell is currently zero or if trying to do ] when cell is currently nonzero; other cases are allow to execute mismatched brackets acting like no operation and the program can continue.

Each cell on the tape can store a number 00 to 99, and it wraps. A symbol is on iff the current cell on the tape includes that digit either the tens place or ones place or both.

Input/output is by bits so the number on the tape will be either 0 or 1 when doing input (or 99 for EOF), and output uses even numbers to 0 bit and odd numbers to 1 bit, EOF is only when the program ends).

The command 0 adjacent on cells means a self-modifying command. It changes the digit in the current position of the code to the value at the current cell modulo ten.


    111     22333            111
0 0  01 0 0 22 31 234567891  111
 000011 0 0 220330  0  0  0 1111
9 7 77 7 7 2      3 3 0 0 0000000