Spacefish

From Esolang
Jump to navigation Jump to search

Spacefish

Note: This is merely an idea. Nothing concrete has been worked out yet. Spacefish is based on a 2-dimensional storage grid. Initially there's only one storage cell available but through use of that initial cell one can "expand space" to get more storage cells.

Storage

Once a storage cell contains an active value it expands the space in all 8 directions by log2 of the active cell's value. However, every active cell distorts the values in other cells (halfed for every cell).

* Are active cells
Numbers indicate how much is added to a cell if it were active. 

0 -> put 8 in it


22222
24442
24*42   * = 8. Surrounding Cells are distorted (log2)
24442
22222

So, if you happen to place 1 into the upper left Corner you get

111
1*3222  * = 1 + 2 = 3
135442
 24*42  * = 8
 24442
 22222

Instructions

Instruction Description
>           Move to the cell to the left
<           Move to the cell to the right
^           Move to the cell above
v           Move to the cell below
+           Increment value in the current cell
-           Decrement value in the current cell
*           Multiply value in the current cell by two
/           Divide value in the current cell by two
[ ... ]     Loop: While current cell value is not zero
I           Read character from stdin
O           Write character to stdout
( ... )     If: If current cell value is zero
{ ... }     If: If current cell value is not zero

A cell is 8bit (Values 0 .. 255). If a value would reach 256 (or bigger) it wraps around. If you would move to a non existing cell it also wraps around.

Computational Class

Yet unknown. Storage can be expanded by placing values in it so it should be possible to achieve "infinite memory". I'm just not sure if one can achieve an arbitrary effect at an arbitrary point.

Spacefish 1D

Spacefish 1D is going to be a version of Spacefish with only 1D Storage.

Incomplete code to demonstrate "distortion" (Python):

import math

space = [0]*11
j = 0
while j < 11:
  space[j] = [0,0]
  j += 1

prog = "++++>++>>+"
p = 0
ptr = 5
while p < len(prog):
  c = prog[p]

  # Instruction handling
  if(c == '+'):
    space[ptr][0] += 1

    j = 0
    while j < len(space):
      space[j][1] = 0
      j += 1

    j = 0
    while j < len(space):
      i = space[j][0] / 2
      d = 1
      while i >= 1:
        space[j + d][1] += i
        space[j - d][1] += i
        d += 1
        i /= 2
      j += 1

  elif(c == '>'):
    ptr += 1
    ptr %= 10
    while( (ptr != 5) and (space[ptr][1] == 0)):
      ptr += 1
      ptr %= 10
  
  print space

  p += 1

print map(sum,space)