canvas_ant {aRtsy}R Documentation

Draw Langton's Ant

Description

This function draws Langton's Ant on a canvas. Langton's Ant is a two-dimensional cellular automaton that is named after its creator, Chris Langton. See the Details section for more specific information about the algorithm used in this function.

Usage

canvas_ant(
  colors,
  background = "#fafafa",
  iterations = 1000000,
  resolution = 500
)

Arguments

colors

a character (vector) specifying the color(s) used for the artwork.

background

a character specifying the color used for the background.

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.

Details

The algorithm for Langton's Ant involves the following steps:

Value

A ggplot object containing the artwork.

Author(s)

Koen Derks, koen-derks@hotmail.com

References

https://en.wikipedia.org/wiki/Langtons_ant

See Also

colorPalette

Examples


set.seed(1)

# Simple example
canvas_ant(colors = colorPalette("house"))



[Package aRtsy version 0.2.4 Index]