Element:SEED

From The Powder Toy
Jump to navigation Jump to search
Seed

Seeds. Put on sand and add water to grow a tree.
Properties
Section Powders
Spawn temperature 22°C
Heat Conductivity 12.8%
Relative weight 36
Gravity 0.05
Acid dissolve rate 1.9%
Flammability 0
State Powder
Transitions
High temperature FIRE above 400°C
Misc properties
Allows neutrons to pass through
Source code


Seed is a light particle which allows growing a tree. To do so, one should place a seed on sand, making sure there is at least one pixel of sand directly below the seed, and adding a sufficient amount of water (distilled water, carbonated water and deuterium oxide also work). After some time, a tree will start growing upwards (where the "up" direction is determined by gravity) with branches sprouting in various directions. The tree is composed out of wood and goo for branches and plant for leaves. When the tree stops growing, it produces more seeds.

The size of the resulting tree is controlled by the amount of water the seed absorbed before the tree growth started. One seed particle can drink up to 31 particles of water, 255 particles of deuterium oxide, and 3 particles of distilled or carbonated water. Salty water decreases the water count of seed, so it is harmful for growth.

The shape of the tree and colour of the leaves are controlled by seed's genes, which can be inherited and mutated, producing various types of trees. Two seeds can be interbred together to produce genetically-similar offspring.

Creation

The only way to create seeds in the game is by growing a tree from another seed. The resulting seeds are clones of the original seed and will produce similar trees.

Reactions

When temperature is above 46.85°C and pressure is above 50, seed has a chance to turn into molten wax:

SEEDMWAX

Genetics

Seed uses a variety of bit flags and counters to control its growth, the precise meaning of which can be read in the source code of the game. Here we focus only on inheritable properties, i.e. on genes. There are two types of genes: colour, stored in .ctype, and branches, stored in .tmp, .tmp2, .tmp3, .tmp4.

Colour

The colour scheme of seed very roughly follows the Cyan-Magenta-Yellow system. There are two bits per each basic colour (i.e. 2 bits for cyan, 2 for magenta and 2 for yellow), so 6 bits in total. This info is stored in bits 7-12 of .ctype.

Possible leaves colours

The leaves colour depends only on whether there is at least one bit set in the respective basic colour group, for example, seeds with .ctype 110011'000000 and 010010'000000 will produce leaves of the same colour, since both have cyan and yellow set. In genetical terms that means that colours are dominant genes, and these genes come in pairs, i.e. alleles.

A seed particle itself does not change its colour depending on the genes, but it changes the spectrum of a photon reflected from itself. Namely, bits 26, 16 and 6 of the reflected photon correspond to the cyan, magenta and yellow genes of the seed.

Branches

When a tree grows, the corresponding sprout plant particle can be in one of four states or phases. Trees always start growing from the zero phase, and only the zero phase can produce a thick stem with goo. Branching info for each phase from 0 to 3 is stored in fields .tmp to .tmp4, respectively.

When a branch stops growing, it decides in which directions it should branch and which states these new branches should have. There are 5 possible directions a branch can split into, corresponding to the 90 degrees turn to the left, 45 degrees turn, 0 degrees turn (i.e. continue growing forward), -45 degrees turn and -90 degrees turn. This is stored in the first 5 bits of the corresponding field as a bitmask. The next 2*5 = 10 bits give new phases for the branches, where each phase is encoded in binary using two bits.

For example, if a seed has .tmp set to 10'01'10'11'00111 and it starts growing up, then the resulting vertical branch will split into an up branch, up-right branch and right branch (since the branches bitmask is 00111), and the up branch will have phase 2 (i.e. 10 in binary), up-right branch will have phase 1, and right branch will have phase 2.

Each time a branch splits, the resulting branches become a bit shorter (on average). When a branch can no longer split, it produces a plant particle (a leaf) of the colour, encoded by the colour genes of the original seed. The branch lengths depend on the amount of water a seed particle absorbed, more water generally means larger trees.

Note that although phases are ordered from 0 to 3 and the tree always starts from phase 0, the tree can visit phases during its growth process in any order, for example, a phase 2 branch can split into both a phase 0 and phase 3 branch, if its genes in .tmp2 say so.

Interbreeding

When two seeds are touching and one of them absorbed some water, they will interbreed. This process can happen only once for each seed, and as a result both interacting seeds change their genes. One should think about it as if the parent seeds disappeared and transformed into their (two) offspring.

Colour genes are combined akin to Mendelian genetics: a random allele is chosen from each parent, for each basic colour. For example, if one seed has 11 cyan bits and another seed had 01 cyan bits, the possible bit combinations for cyan are: 11 and 10. If one seed had 10 magenta bits, and another seed had 01 magenta bits, then their offspring may have 11, 01, 10 and 00 in the magenta genes.

For the branching genes, we randomly select a bit from one of the parents, i.e. if the first seed had 1 on 5th position of .tmp and the second seed had 0 there, then their offspring may have 1 or 0 on the 5th position, and it will be determined by random chance. If both parents had 1 on the 5th position, then both offspring will necessarily have 1 on the 5th position as well.

In particular, when breeding clones of the original seed, colours may show some variation but branching patterns will always be the same.

Mutation

When a neutron hits a seed, it flips one of its genes randomly, including colour. If a proton hits a seed, it may swap genes for two random phases, for instance, it may swap .tmp2 and .tmp3, while colour genes will stay the same.

Language: English