Viruses
How a bot copies one of its genes into a virus, incubates it and shoots it, where the gene lands in the victim's DNA, how genes are deleted, and what it all costs.
A virus is a gene packaged into a shot. The bot copies one of its genes, incubates it for a few cycles and shoots it; if the shot hits another bot, the gene is inserted into its DNA and from the next cycle on it runs like any other of its genes. It's the only way to put code into another bot, and the only way, along with mutations, for a DNA to grow during life.
Four cells are involved: .mkvirus, .vtimer, .vshoot and .delgene. They are grouped in DNA and viruses; this page explains the complete cycle.
The life cycle of a virus
.mkvirus ──► incubation ──► ready ──► .vshoot ──► flight ──► infection
(gene N) .vtimer drops .vtimer (strength) random the gene enters
by 1 stays at 1 direction the victim
- Make. You write the number of one of your genes into
.mkvirus. The engine copies it whole, from itscond(or itsstart) to itsstop. - Incubate.
.vtimerstarts at twice the number of words of the copied gene and drops by 1 per cycle. When it reaches 1 it stops: the virus is ready. - Shoot. With the virus ready and a number other than 0 in
.vshoot, the virus goes out. If you wrote.vshootearlier, the command waits and the virus goes out as soon as the incubation ends. - Infect. If it hits another bot during its flight, it inserts the gene into it.
Making and shooting happen in the movement phase, after the DNA has run; the virus that was shot starts flying in the shots phase of the next cycle, like any other shot.
Making
Rules for making:
- One virus at a time. While one is incubating or waiting to be shot, writing to
.mkvirusagain does nothing. - The command isn't cleared on making, but on shooting: while the virus incubates, the cell keeps the gene number.
- A gene number that doesn't exist makes nothing. The numbering is the one in Genes: cond, start, else and stop.
- Viruses and photosynthesis don't mix. If the bot has chloroplasts, the command doesn't make the virus and takes all the chloroplasts away from it. Since the command stays written, the virus is made in the next cycle.
The copy costs energy according to the gene's length: the DNA copy cost (DNA copy) for each word. A long gene is expensive to copy and also takes longer to incubate: a 12-word gene incubates for 24 cycles.
Shooting
The number you write into .vshoot is the shot's strength. A negative counts as 1. Three things come out of the strength:
| With strength F | |
|---|---|
| Energy the virus carries | 20 × F (cap 32000) |
| Cycles it flies | 11 + F/2 |
| What the bot pays | F (at most 1600) plus the shot cost (Shoot) |
The virus advances about 40 units per cycle (plus the speed the bot had), so with strength 30 it flies 26 cycles and travels more than 1000 units: much farther than an ordinary shot. As it ages it loses energy, like any shot (see Shots).
What you don't choose is the direction: it goes out toward a random side. Neither .aim nor .aimshoot has any influence. That's why bots that live off viruses don't aim: they shoot when someone is nearby, or all the time.
After the shot, the engine sets .vshoot, .mkvirus and .vtimer to 0, and the bot is free to make another.
The infection
When the virus hits a bot, this happens:
- Corpses can't be infected. The virus is lost.
- Slime defends. The virus has a power that comes from the energy it has left and how far it has flown. If the bot's slime (
.slime) is enough to stop it, the virus is absorbed and the slime is used up a little. If it isn't enough, the virus gets through and the slime is used up entirely. - The gene is inserted in a random place. With a DNA of N genes there are N + 1 possible places, all equally likely: before the first gene or right after any of them. It never ends up in the middle of a gene.
- The victim's DNA really changes.
.genesand.dnalenare updated on the spot, the infection counts as a mutation and the bot becomes a new subspecies (see Species and lineage). What its children inherit already includes the gene.
A virus's power is always less than 1, and each unit of power is stopped by 20 of slime. In practice, about 20 of slime stops any virus, whatever its strength; with less, the strongest ones get through, and so do those that hit right after being shot. More about slime in Defenses.
The virus doesn't tell species apart: it infects any bot it touches, including bots of the shooter's own species; the only one it never touches is the shooter itself. A DNA can't go past 32000 words: if the gene doesn't fit, the infection doesn't happen.
Since the gene goes in anywhere, the genes that came after it shift by one number. If the victim uses fixed gene numbers (in .delgene or .mkvirus), after an infection they may point to a different gene.
A virus that spreads by itself
The trick for the victim to infect others too is for the gene to package itself with .thisgene, which holds the number of the gene that's running. That way it doesn't matter where in the foreign DNA it lands:
' A gene that packages itself: whoever receives it infects others too
cond
*.vtimer 0 =
start
*.thisgene .mkvirus store
30 .vshoot store
stopTested against a two-gene bot, the victim starts making and shooting its own viruses as soon as it's hit, and in 400 cycles it ends up with several copies of the gene: each new infection adds another. The energy of each shot is paid by the victim. Bestiary bots such as Lazy One or Coexistence viral plant (evolved) carry *.thisgene .mkvirus store in their genes.
What the virus does depends on what the gene carries. BodySnatcher (k0zm0, 2005), when it sees another bot, shoots it copies of its genes 3 and 4, the ones that convert energy into body and back, so that the victim handles its body the way it does.
Deleting genes
.delgene deletes from the bot's own DNA the gene with that number, whole, in the movement phase of the same cycle. It costs no energy, and from that moment the gene doesn't run, doesn't pay upkeep and isn't passed to the children. A number that doesn't correspond to any gene does nothing. The classic use is a startup gene that deletes itself with *.thisgene .delgene store (see the .delgene page).
Combined with a virus it makes a weapon: a gene that, in the victim, makes it delete its own genes. So that the same doesn't happen to its maker, the gene checks a mark that only the maker has:
' Virus that makes the victim delete its genes
' Gene 1: its own mark and the virus with gene 2
cond
*.vtimer 0 =
start
1 90 store
2 .mkvirus store
20 .vshoot store
stop
' Gene 2: in whoever lacks the mark, deletes the first gene
cond
*90 0 =
start
1 .delgene store
stopIn the victim, gene 2 deletes one gene per cycle, starting with the first. When it has already deleted all the ones before it, it becomes gene 1 itself and deletes itself. The genes that were after the point where it landed are safe: if it landed at the end, the victim loses everything; if it landed first, it only deletes itself. Tested against a two-gene bot, the first infection deleted one gene; the second landed in front and did nothing to it; the third took the one that was left, and the victim ended up with no genes at all: a bot that doesn't think.
No shot can write another bot's .delgene: memory shots skip it and venom can't target it. But a tied bot can, with .tieloc (see Ties and multicellular bots).
Costs and tournament rules
| Action | Cost |
|---|---|
| Make | DNA copy per word of the copied gene |
| Shoot | The strength plus Shoot |
| Infect | Nothing for the victim, except the slime it uses up |
| Delete a gene | Nothing |
Both parameters are multiplied by the simulation's cost multiplier, like all of them; the strength you pay when shooting is not. Otherwise, the gene that gets in weighs on the victim like any other: more DNA means more cost per cycle (see Execution and costs).
In tournaments, the disqualification option (Disqualification) can forbid viruses and gene deletion; what each level forbids is in that option.