Paintfuck

From Esolang
Jump to navigation Jump to search

Paintfuck is a borderline-esoteric graphical programming language by User:Whtspc. A derivative from Smallfuck that uses a 2D datagrid instead of 1D.

The commands are:

  • n - Move data pointer north (up).
  • s - Move data pointer south (down).
  • e - Move data pointer east (right).
  • w - Move data pointer west (left).
  • * - Flip current cell.
  • [ - If cell is 0, jump past matching ].
  • ] - Jump to matching [.

The spec stipulates that any letter not among these should be ignored.

The output of the program is the 2D grid itself, best as animation while the program is performing, but possibly a picture of the grid after a certain amount of iterations.

In current implementations the data area and therefore the output canvas is limited, with toroidal (i.e. wrapping) behaviour.

Sample Programs

White screen:

   *[s[e]*]

Fibonacci sequence (by Wouter Visser):

   *
   [[s*en]
   sw[w]enn
   [[e]w*ssss*nnnnw[w]ess[e]*[w]enn]
   ssss[*nnnn*essss]
   nnnnw[w]e
   ss]

Automaton rule 110 (by oklopol):

   ww*ees*
   [
   e*[*
   w
   ss*nnn[ss*s*s*nnnn*]ssss[*nnnn*ssss]nnne
   ss*nnn[ss*s*s*nnnn*]ssss[*nnnn*ssss]nnne
   ss*nnn[ss*s*s*nnnn*]ssss[*nnnn*ssss]nnnw
   sw
   [*e[*es[*nnw*ess]nw]
     s[*en[*nw*es]sw]nw]
   s
   [*en[*n*s]
     s[*en[*nw*es]sw]w]
   n[*]e[*]e[*]s[*]w[*]w[*]
   nne
   e*]s*
   ]

Langton's Ant (by Pedro Gimeno)

   es*nww
   *[*
     ee [*w *[w*s*ne*]w [e*w*]s[wwn*s]       n*[*ees*n]ee    ]
     s  [*nw*[w*s*ne*]w [e*w*]s[*s*se*w]     n*[*nnee*ww]ees ]
     w  [*n  [w*s*ne*]w*[e*w*]s[wwn*s]       n*[*ees*n]es    ]
     w  [*ne*[w*s*ne*]w [e*w*]s[*nnnee*ww*s] n*[*ssse*wn]s   ]n
   *]

Binary counter (by Wouter Visser)

   *[ss*s[*]n[e*s[*]n]*e[*nn[*n*ss*n]sse]ne[*e]*w*[*w*]*]

Squares (by Keymaker), meant to be ran on a large, preferably infinite, grid:

   *es*e*s*w*n[[[e]w[s]e[ee]*e*[ww]es
   [ss]*n[*]*n[nn]w[n]s[w]e*e]sw[n*sw
   ]e[e]w[s]ee[sw[e*ws]en[n]es]w[w]e]

Paintfuck in Paintfuck (by Keymaker), a self-interpreter.

*[[n*e*]n[*]*]
  • To run your own Paintfuck program in it, use this program http://yiap.nfshost.com/esoteric/paintfuck/pfipfpig.py to generate the input data (as Paintfuck doesn't have I/O, the program input must be included in the program code), and replace the code after the commented 'program input' with the output the generator gives you. Remember to leave the large chunk of code after the program input as it were, as it's the core of the interpreter. Both the width and height of the grid PFIPF is using, are 2*n+1, where n is the number of cells set in 'grid dimension(s)'. You can change it, too, for example:
*e*e*e*     9x9 grid
*e*         5x5 grid
*e*e*e*e*e* 13x13 grid
  • The interpreter emulates the given Paintfuck program on a 2D grid where each cell is shown as 3x3 cells (for better viewing!).

Computational class

As it trivially includes Smallfuck, the language is Turing-complete over an infinite grid. If given a finite grid as in the prototype interpreter, it acts like a finite state machine.

See also

External resources

External paintfuck programs