Element · placement

scatter

More than one of a thing. A scatter says how many and where; its children say what. Rocks, stones, boulders, pebbles, flowers, trees and a let whose body is one thing can all be scattered.

lib:tiles/cliffs/2x1-cliff.dtile: stones and boulders scattered against the cliff, pebbles scattered in the dirt.
lib:tiles/cliffs/2x1-cliff.dtile: stones and boulders scattered against the cliff, pebbles scattered in the dirt.

Writing it

dirt { scatter perSquare=40 { pebble } }                       // inside a surface: lands on it
scatter at=pool count=2 { rock size="6dmm .. 10dmm" }            // two rocks in the pool
scatter at="foot(cliff)" perSquare=55 reach="4dmm" { stone }      // scree at the cliff's foot
scatter perSquare=3 { stone weight=3; boulder }                // a mix, three stones to a boulder
scatter perSquare=3 { rock size="4dmm .. 8dmm" weight=3; flower; tree top="$bottom + [22dmm .. 30dmm]" weight=1 }   // a glade

A scatter needs exactly one of count and perSquare. reach needs at=foot(…). A scatter holds rocks, flowers and trees, alone or mixed, and a let whose body is one such thing written bare (scatter count=3 { boulder size="7dmm .. 10dmm" }: the child's properties are the definition's params, a tree's top= is its height, weight= is its share, and a place word on the child is dt::place; see demo/scatter-definition.dtile). With several children, each child's weight= is its share of the mix (default: equal), whatever the kind. A mix is placed with one gap between every two things (default: the first child's own: 1.5dmm for a rock, 1dmm for a tree, 0.5dmm for a flower), the things that stand alike together and the largest first: trees (laid out together; an error names how many fit when not all do), then rocks clear of the crowns, then flowers on dry ground clear of both. A mix is not gathered at a foot; at= a region or a line works as for any scatter. A scatter is built where it is listed: a dirt listed after it lies on its rocks and banks against its trunks, and grass listed after it grows round it. Every scattered thing keeps inside the tile and clear of other solids: it is nudged inward, never clipped.

How the places fall

pattern says how a scatter's places fall; count or perSquare says how many; the same placement and the same things follow whichever it is.

spaced
The default. Things keep gap and the room each takes between them, the largest first.
clumped
The things gather in clumps (to a square, a range): each clump draws how far it reaches (spread, a range) and its places fade from the middle outward. Things are kept apart within a clump, as in a spaced scatter; ask for more perSquare than the clumps hold and the rest are left out, never crowded.
cover
A dense cover for thousands of things a square. Nothing is checked among the things, so they touch and overlap, but they fall evenly: each place is the next point of an evenly spreading sequence (shifted by the seed), so every patch of the square holds its share and nothing heaps up or leaves wide bare ground; ask for pattern=clumped to heap them. Each keeps clear of what already stands only by gap, which under a cover is 0 unless written, measured from the real outline of what stands (the footprint near reads, not a disc round its bounds): the things lie against a rock, a wall or a trunk on every side, touching it and never in it, and a place that falls where nothing could stand (in a rock, off the area) is not lost but thrown again at the next point of the sequence, so the count holds (a spaced or clumped scatter keeps the disc of each rock) (a spaced scatter's gap is the thing's own, 1.5dmm for a rock). Write gap= to leave a bare band, or thin in a near block to make a bare ring. The cost grows with the number of things, not with the square of it.

cover is the share of places that keep a thing ("85%"); clearings (to a square, a range) are round patches left bare, clearingWidth wide each. Both mean what they mean on grass, and work with every pattern. perSquare is the density where there are things: a cover of 85% with clearings leaves less than perSquare on the whole square.

dharmatiles version="1.0.0"

tile size="1x1" seed=5 {
    stack {
        base
        dirt
        rock at="(0.5sq, 0.5sq)" size="9dmm"
        scatter perSquare=300 pattern=cover cover="85%" clearings=3 clearingWidth="6dmm .. 9dmm" {
            pebble size="1.2dmm .. 2.2dmm"
            near of=rock reach="4dmm .. 9dmm" height="1.3 .. 1.6" thin="30%"
        }
    }
}

Things that answer to what is near

A near block changes the things of a scatter that stand within reach of something already in the tile. of names what: rock, wall, tree, cliff, standing (those four) or water (the water's edge); a name that is none of them is refused at the line. The scatter measures each thing's distance to the nearest of it, from the solids of that kind the stack built before the scatter (the footprint where each meets the ground, so earlier scatters' items count, while the dirt's own clods and pebbles, which are the ground, and this scatter's own things do not); the thing is changed when that distance is under its reach, which each thing draws from the range, so a range is a soft edge: reach="6dmm .. 12dmm" changes every thing within 6dmm, none beyond 12dmm and a fading share between.

What changes is height (a range, how many times taller the thing stands: only things that can grow taller take it, which are rocks and flowers) and thin (the share of things within reach left out). One scatter has one near: two behaviours, say taller by a rock and bare by water, are two scatters over the same area. A scatter at=foot(…) gathers its own way and takes no pattern, cover, clearings or near.

dharmatiles version="1.0.0"

tile size="1x1" seed=3 {
    stack {
        base
        dirt
        rock at="(0.7sq, 0.3sq)" size="8dmm"
        scatter perSquare=24 pattern=clumped clumps="2 .. 3" spread="5dmm .. 8dmm" {
            flower size="4dmm .. 6dmm" petals=5 centre="1.2dmm" stem="1dmm" dome="1dmm" petal="0.5dmm"
            near of=rock reach="6dmm .. 12dmm" height="1.3 .. 1.6"
        }
    }
}

Variants: built once, copied

Left alone, every thing a scatter places is its own draw: its own size and its own shape, each built once. A cover of two thousand pebbles is two thousand builds. variants=K says the things are drawn as one of K variants instead: each placement picks a variant, each variant is built once, and every placement of it is that body copied, turned about its own axis and set down where it stands. The pebbles still fall as the pattern says and still turn every which way; there are only K shapes among them, so the build makes K bodies and copies the rest.

What it saves
The work of building. A copy costs a turn and a move, so a cover with variants=12 builds twelve pebbles however many it places. The final union still holds every copy and the gate still checks the whole mesh, so the size of the result and the time of the union do not change. The build record says how many bodies a build made, copied and read (things).
What a variant is
One draw of the thing, from a stream of its own keyed by the thing and the variant's number, so every copy of a variant is the same draw, and asking for more variants moves none of the first. A rock's variant is its placement (a stone, or a cluster of stones), each stone grained from the variant's seed; a flower's is its size and petals.
What a copy cannot do
A rock a near block stands taller, or that has a top=, is another shape and is built as its own. Only rocks are copied. Flowers are built where they stand (a flower built at the origin and moved is the same flower to a hair's breadth, and that hair moved the repair counts of a meadow's union), and trees are grown where they stand (their sink into the ground, their footing and their top= read the tile): variants on either still draws only that many shapes, but builds each placement where it stands.
Unset
Every placement is its own draw, as before; a tile that does not write variants builds the same bytes.
dharmatiles version="1.0.0"

tile size="1x1" seed=5 {
    stack {
        base
        dirt
        scatter perSquare=300 pattern=cover variants=12 {
            pebble size="1.2dmm .. 2.2dmm"
        }
    }
}

Reference

Kind
a layer, a scatter: many things, placed; its children say what
Place
at= region, line, foot(…)
Built
yes

Controls

ControlTakesDefaultWhat it does
countcount, 0 to 10000, or a range, or a weighted rangenot counted: perSquare says how manyhow many, in total
perSquareper square, a number, a range or a weighted range—how many per square of the area, or of length along a line
patternwordspacedhow the places fall: kept apart, in clumps, or a dense cover
spaced
things kept apart, the room each takes between them
clumped
things gathered in clumps, kept apart within each
cover
a dense cover: no spacing among things, as many as the density says
clumpsper square, 0 to 200, or a range, or a weighted range3with pattern=clumped: how many clumps to a square
spreadlength (dmm), over 0, or a range, or a weighted range3dmm .. 8dmmwith pattern=clumped: how far from its middle a clump reaches, drawn for each clump
reachlength (dmm)where the rocks stand: a foot's or a line's ownwith at=foot(…): how far out from the foot; with at= a line: how far either side of it
coverpercent, 0% to 100%100%share of the places that keep a thing
clearingsper square, 0 to 20, or a range, or a weighted range0round patches left bare, to a square
clearingWidthlength (dmm), over 0, or a range, or a weighted range6dmm .. 14dmmhow wide a clearing is, drawn for each
variantscount, 1 to 256every placement is its own drawdraw each thing as one of this many variants, each built once and copied turned and placed
neargroup—things that answer to what is already in the tile: taller, or fewer, within reach of it
near ofword—what the things answer to Required.
rock
rocks, stones, boulders and pebbles
wall
walls
tree
tree trunks
cliff
cliffs
standing
rocks, walls, trunks and cliffs
water
the water's edge
near reachlength (dmm), over 0, or a range, or a weighted range6dmm .. 12dmmhow far out from it a thing is changed, drawn for each: a range is a soft edge
near heightnumber, over 0, or a range, or a weighted range1how many times taller a thing within reach stands
near thinpercent, 0% to 100%0%the share of things within reach that are left out
gaplength (dmm)—least space between neighbours

In the library

Generated from dharmatiles elements scatter by cargo xtask docs.

Notes

at=foot(cliff)
Gathers at the foot of that kind of thing: cliff, wall, rock or tree. Scattered at a cliff's foot, rocks take the cliff's rock: that is scree.
at=line
Spreads along a drawn line, an edge or an edge path, within reach either side of it (default 5dmm), to the ends of the line rounded. perSquare counts the line's length in squares. It builds for rocks, flowers and trees alike: scatter at=road count=3 reach="3dmm" { tree top="$bottom + [26dmm .. 32dmm]" }. A single thing at a line is refused (a line has no one place on it); a scatter is how several stand along one.
trees
A scatter of trees places every crown clear of the others (centres at least both crown radii and gap apart, default 1dmm), each trunk a crown radius in from the tile edge and clear of what already stands, then grows them one after another, each from its own seed. A tree is a heavy build: ask for few. If the crowns cannot all fit it is an error naming how many do, never fewer trees without a word.
count, perSquare
Take a weighted range (of plain numbers): perSquare="low(2..8, 3)". Each whole number of a range is as likely as any other. See weighted ranges.
inside a surface
A scatter written inside dirt or grass is placed on that surface, in its area.

A scatter is a region of its own, its at= area (or the tile), and the things it places are its children: a tree in a scatter has the scatter, then the tile, as parents. A single thing never takes a count: tree count=3 is an error whose help says to use a scatter. See placement in the language guide.

Seen from the language

The guide pages that use scatter: The stack, Placement and scatter, Values and ranges, Weighted ranges, Names, Seeds, Things and layers, Worked tiles.