emit

From Esolang
Jump to navigation Jump to search
Note that emit is typically lowercased except, often, at the start of a sentence.

emit, created by User:iddi01, has nothing to do with emission. It is named so because

"emit" is a reversal of
"time".

A program is an array of cells containing bits. Data is stored in an accumulator and a stack.

Emit has only one instruction, and is thus an OISC. That instruction is very complex:

t refers to time in seconds since the program started. Read the bit the pointer is on and invert it. If the bit is 1, move the pointer back t (rounded up) cells, if the pointer is then negative, pop the stack items one by one and add them to the accumulator, then output the 
accumulator as a number and terminate the program. Else invert the bit it's on, and push t onto the stack. If the bit is 0, move the pointer forward t (rounded up) cells. Regardless of the bit read, then move the pointer forward one cell, if the pointer is then out of 
bounds, move the pointer to the last cell.

Since the popping operation at the end can use any end of the stack, it is equally valid to consider it as a stack, queue, or deque.

Behavior

The behavior of emit is fairly complex and unpredictable, just like gnillevart-emit. This section lists some of the predictable behaviors (note that FIO refers to the final output):

  • With faster interpreters and computers, the FIO tends to be larger, since t is pushed more frequently.
  • The FIO can only be around certain values, called stages. That's due to periodic configurations being the only way to survive a whole second, and that they're broken when a new second arrives. Interestingly, a single program can have a FIO with at least two different stages.
  • The FIO obviously scales with program length, but sometimes a huge increase in length are required to jump to the next stage, like the 3-second stage to the 4-second stage. Other stages require certain program forms to even appear. For example, compare the output of the three below:
00010101100111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000101011001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001

Computational class

Emit is provably total, since any periodic configuration involves reading a '1' bit, and t will eventually be larger than the length of the program.

Emit is most likely a linear bounded automaton, since the length of the program cannot change, but otherwise would theoretically be able to do complex computation.

Implementation

yp.emit (or emit.py in case of technical issues)

This is a Python implementation of emit, one with low FIO resulting from programs (which means it's one of the slowest):

import time, math
program = input("Program: ")
initime = time.time()
stk = []
accumulator = 0
ind = 0
while ind >= 0:
   try:
       bit = int(program[ind])
       if bit:
           program = program[:ind] + ('0' if int(program[ind]) else '1') + program[ind+1:]
           ind -= math.ceil(time.time() - initime)
           if ind < 0: break
           program = program[:ind] + ('0' if int(program[ind]) else '1') + program[ind+1:]
           stk.append(time.time() - initime)
       else:
           program = program[:ind] + ('0' if int(program[ind]) else '1') + program[ind+1:]
           ind += math.ceil(time.time() - initime)
       ind += 1
   except IndexError: ind -= 1
accumulator += sum(stk)
print(accumulator)

The real impressive part