Paintfuck

From Esolang
Revision as of 12:45, 1 December 2008 by Pgimeno (talk | contribs) (→‎Sample Programs: Replace Langton's ant with shorter version (also fix oklopol's nick))
Jump to navigation Jump to search

A borderline-esoteric graphical programming language by Wouter Visser. 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]

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.

External resources