DNA and viruses
The sysvars that let a bot look at its own DNA, delete genes from it, and make and shoot viruses that inject a gene into other bots.
| Address | Sysvar | Kind | Summary |
|---|---|---|---|
| 335 | .mkvirus | Command | Copies the gene with that number into a virus and starts incubating it; it is fired later with .vshoot. |
| 336 | .dnalen | Internal | The length of the bot's DNA in words, counting the final end; upkeep and the cost of copying it depend on it. |
| 337 | .vtimer | Internal | The countdown of the incubating virus: 0 if there is no virus, it drops by 1 per cycle and stops at 1 until the shot. |
| 338 | .vshoot | Command | Fires the incubated virus: the number is the strength of the shot, which determines how far it reaches and how much it costs. |
| 339 | .genes | Internal | How many genes the bot's DNA has; it changes if it mutates, if a gene is deleted or if a virus inserts one. |
| 340 | .delgene | Command | Deletes the gene with that number from the bot's own DNA; the classic use is a gene that deletes itself after running. |
| 341 | .thisgene | Internal | The number of the gene that is running right now; it changes at every cond, start, else or stop. |
This group brings together two things that work on the DNA itself, not on memory.
Looking at your own DNA. .dnalen tells you how many words the DNA has, .genes how many genes, and .thisgene the number of the gene that is currently running. The engine maintains all three, and they change when the DNA changes: through a mutation, a virus that got in, or a deleted gene. Gene numbering is covered in Genes: cond, start, else and stop.
Changing it. .delgene deletes a gene from the bot's own DNA. The best-known trick is a gene that deletes itself after running once, using .thisgene.
Viruses. A bot can copy one of its genes into a virus and shoot it. The full cycle is:
- You write the gene number to
.mkvirus. The engine copies the gene (charging energy for its length) and starts incubating it. .vtimercounts the incubation down: it lasts twice as many words as the gene has. When it reaches 1, the virus waits.- You write the shot strength to
.vshoot. With the virus ready, it goes out in a random direction. - If it hits another bot, the gene is inserted between two of its genes, chosen at random, and from the next cycle on it runs like any other of its genes.
A gene that makes the victim also make and shoot viruses spreads like an epidemic. Slime (.slime) stops weak viruses, and corpses don't get infected. A bot with chloroplasts can't make viruses: if it tries, it loses its chloroplasts. The full detail is in Viruses.
' Makes a virus from gene 3 and shoots it as soon as it's ready
cond
*.vtimer 0 =
start
3 .mkvirus store
stop
cond
*.vtimer 1 =
start
50 .vshoot store
stop
' Gene 3: what the victim will run
cond
start
314 .aimdx store
stop