Pipefuck

From Esolang
Jump to: navigation, search

Pipefuck or Pipef*** is an esoteric programming language created by User:WolfgangTS. It is a Two-dimensional version of Brainfuck, and therefore is turing complete.

Concepts

The tape

Just like brainfuck, Pipefuck has a tape, and a pointer. There are no variables. So the tape serves that purpose. (In depth explanation)

The map

In pipefuck, every program is a map, or a maze, and the cursor navigates it. There are two directional operations

Operations

In pipefuck, every character is an operation. When the cursor moves over it, it is executed.

Operation Result
- Same as Brainfuck, decreases tape[ptr]
+ Same as Brainfuck, increases tape[ptr]
> Same as Brainfuck, increases ptr
< Same as Brainfuck, decreases ptr
/ Will act as a direction modifier, just like a mirror would turn the light -90 degrees. e.g. if you are heading west, you will now be heading south.
\ Will act as a direction modifier, just like a mirror would turn the light 90 degrees. e.g. if you are heading west, you will now be heading north.
~ Skips next character, keeps going in the same direction.
* Skips next character if tape[ptr] == 0, keeps going in the same direction.
, Same as Brainfuck, sets tape[ptr] to the ASCII value of an input character
. Same as Brainfuck, stdout.writes the ASCII chaaracter at tape[ptr]
| and = Acts as a path for the 'light', is required for the program to work. Note that they are interchangeable.
@ Will stop the program, regardless of position or direction.
any other character This will 'teleport' to another equal character, if there are multiple, it will pick one randomly.

Computational Class

Pipefuck is turing complete. You can translate any Brainfuck program to Pipefuck, thus making it turing complete. Here is the translation of a simple addition program in Brainfuck and then in pipefuck:

  ++++ 4 at t0
  >+++ 3 at t1 
  <[
    >+
    <-
  ]


The result will be a tape like so: [0, 7]. The same result is achievable in pipefuck this way:

  =++++\ 4 at t0
  /+++>/ 3 at t1
  <
  \~/>+=\
   @\*-</

Comments

Comments are very easy to achieve, any code that is unreachable, will never be executed, so you can write to your hearts content. There is an issue however, if you are using 'portals', your program might start teleporting all over the place.

Example programs

Cat program

  ,~$.,*$

Note, $ is used as a portal.

Multiplication program

\
\++++\
/++++/ EIGHT
>
\+++++\
/+++++/ TEN
<
| MULTIPLY
| IN [x], y
\=~/>~/>+>+<<-*\\
   |  \========/>
/  \*-<</*->+<\~/
|       \=====/
>
\~/-\
/>\*/
>
\~/<+=\ SHIFTL
/<\*->/
\~/<+=\ SHIFTL
/<\*->/ 
\~/<+=\ SHIFTL
/<\*->/ 
@

Will take [8, 10] and change it to [80, 0, 0]. Note the trailing 0 is a memory cell it used.

Implementation

A quick and messy implementation without I/O by User:WolfgangTS: Gist here