Tetrahedron

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

Tetrahedron, with hexagony as its inspiration, is a fungeoid created by user:cleverxia that operates on a finite tetrahedron.

Program flow

first, the program is loaded into "program tetrahedron" from top to bottom, up to down, left to write, truncated so that there aren't any all-null layers. for example,

123456789abcdefghijklmnopq

will result in this tetrahedron ($'s are nulls):

    1

   2 3
    4

  5 6 7
   8 9
    a

 b c d e
  f g h
   i j
    k

l m n o p
 q $ $ $
  $ $ $
   $ $
    $

IP starts at the top corner, heading down-west (DW).

 UN
UW UE

 NW NE
W IP  E
 SW SE

DW DE
 DS

when the IP/DP overflows at the DW direction it wraps to the top keeping the same direction. same for DE,DS,UN,UW,UE. when IP overflows at the E direction, it "warps and reflects to the other side" like this:

   $             Z
  3 6           9 5
 0 X 2         $ $ 6
$ 8 5 $       0 1 2 Y

where numbers represent the time that the IP comes there, X contains 1/4/7, Y contains 3/7, Z contains 4/8. essentially the same for W/NW/NE/SW/SE.

The data pointer starts at the top, heading down-west (again).

Before the program starts, all commands in the tetrahedron is changed into the corresponding opcode in numbers with null ($)=0. (Otherwise there are no way for you to manage the data) DP's value is the opcode of the cell pointed by the data pointer

Commands

Caption text
command opcode meaning
-1 APLWSI interpreter
0~9 0~9 also an APLWSI interpreter, useful for initializing data
△▽○◇□☆▲▼●◆■★ -2~-13 go in the specified direction
opcode direction
-2 UN
-3 UW
-4 UE
-5 NW
-6 NE
-7 W
-8 E
-9 SW
-10 SE
-11 DS
-12 DW
-13 DE
▷◁♤♡♢♧▶◀♠♥♦♣ -14~-25 set data pointer direction in the direction specified by the table above and opcode (x+12)
Δ -26 set the IP's delta to the DP's value
δ -27 set DP's delta to DP's value
@ 10 halt
" 11 move the DP in its direction
# 12 skip next instruction
$ 13 swap current DP's value with register. (register starts at 0)
+-*/% 14~18 DP's value [command]= register (integer division, rounds towards zero)
> 19 set register to current cell
o 20 output DP value as ASCII
n 22 output DP value as number
i 21 input ASCII to DP value
& 23 input number to DP value
_ 24 reflect
¤ 25 load a schematic with ID equal to DP value
А-Яа-я 32~97 schematic command, undefined commands interpret APLWSI (also can be used as initializers)
! 26 logical not DP's value

(Want to branch? here's an example (with square topology, 'v' means down, 'R' means right, assuming register stores 1):

!!+Δv$ ΔAAA
     R   BBB

takes the AAA path if DP value!=0, BBB path if DP value=0.)

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