This function paints a turmite. A turmite is a Turing machine which has an orientation in addition to a current state and a "tape" that consists of a two-dimensional grid of cells.

canvas_turmite(
  colors,
  background = "#fafafa",
  p = 0,
  iterations = 1000000,
  resolution = 500,
  noise = FALSE
)

Arguments

colors

a character specifying the color used for the artwork. The number of colors determines the number of turmites.

background

a character specifying the color used for the background.

p

a value specifying the probability of a state switch within the turmite.

iterations

a positive integer specifying the number of iterations of the algorithm.

resolution

resolution of the artwork in pixels per row/column. Increasing the resolution increases the quality of the artwork but also increases the computation time exponentially.

noise

logical. Whether to add k-nn noise to the artwork. Note that adding noise increases computation time significantly in large dimensions.

Value

A ggplot object containing the artwork.

Details

The turmite algorithm consists of the following steps: 1) turn on the spot (left, right, up, down) 2) change the color of the square 3) move forward one square.

See also

colorPalette

Author

Koen Derks, koen-derks@hotmail.com

Examples

# \donttest{
set.seed(1)

# Simple example
canvas_turmite(colors = colorPalette("dark2"))

# }