Baggins-1.0: Tools for self-assembly

Safe HaskellNone

Math.SelfAssembly.Baggins

Contents

Synopsis

Documentation

data Tile Source

The tile datatype

Instances

runProgram :: Program a -> (a, [(Int, Int, Int)], Map Int Tile)Source

Run the program, returning its return value, along with the produced tileset.

execProgram :: Program () -> ([(Int, Int, Int)], Map Int Tile)Source

Run the program, returning the produced tileset.

simulate :: Int -> Int -> [(Int, Int, Int)] -> [(Int, Int)] -> Map Int Tile -> IO (Int, Int, Int, Int, Map Position Int)Source

simulate file margin w h showGlues seeds tiles simulates the given tileset, with seeds at the given positions (x,y,type), and returns the maximal manhattan distance reached. The showGlues argument indicates whether glues should be written in the output file (results in bigger files).

Initialization

seed :: Int -> Int -> Program ()Source

Adds a new seed to the program, at the given position. There may be several seeds, and they will all be placed before anything else is grown.

Basic moves

movex :: Int -> Program ()Source

Move by 1 tile along the x-axis

movey :: Int -> Program ()Source

Move by 1 tile along the y-axis

discreteVect :: Int -> Int -> Program ()Source

Approximates a discrete vector, by walking as close as possible to the corresponding straight line.

Combinators

repete :: Int -> Program () -> Program ()Source

Repeat a program a given number of times. If the original program produces n tile types, then repeating it t times produces mt tile types.

pump :: Program () -> Program ()Source

Pump a given program, that is, allowing its first tile to attach to its last tile. It is up to the user to check that this is possible; the assembly is likely to stop else.

Rembering specific tile types - equivalents to formal let.

newtype Cur Source

Constructors

Cur Int 

currentTile :: Program CurSource

Get the last tile placed (raises error if no tile has been placed).

nextTile :: Cur -> Program CurSource

Get the tile immediately following a given tile in program order.

prevTile :: Cur -> Program CurSource

Get the tile immediately following a given tile in program order.

Editing and branching - equivalents to the formal bind and from.

data Dir Source

Directions, or sides of tiles

Constructors

N 
S 
O 
E 

bind :: Dir -> Cur -> Program ()Source

Binds the given tile to the given side of the current tile. This function modifies the given tile if and only if the complementary side was not used. This modification can result in unwanted assemblies.

rewindBy :: Int -> Program ()Source

Go back by the given amount of tile types.

rewindTo :: Cur -> Program ()Source

Go back to a specific tile.

eraseAfter :: Cur -> Program ()Source

Delete every tile produced after the given tile. Mostly useful in combination with currentTile.

Coloring tiles - tile decorations

type Color = (Double, Double, Double)Source

Tile colors

setColor :: Color -> Program ()Source

Set the current color

Debugging and output

plot :: FilePath -> PlotOptions -> Map Int Tile -> Map Position Int -> IO ()Source

traceTile :: MonadState St m => Cur -> m ()Source

tikzPlot :: FilePath -> PlotOptions -> Map Int Tile -> Map Position Int -> IO ()Source