DarwinBotsManual
Open the app EspañolES

.thisgene

The number of the gene that is running right now; it changes at every cond, start, else or stop.

Facts

Address
341
Name
.thisgene
Kind
Internal: the engine rewrites it; writing it has no lasting effect
Group
DNA and viruses
Written by
The engine, while the DNA runs, every time it passes a cond, start, else or stop.
Cleared
No: the engine overwrites it at the next gene marker.
Range
0 up to the number of genes in the bot.
Mutations
picked as a read (*)

While the DNA runs, the engine updates .thisgene every time it passes a gene marker (cond, start, else, stop), even if the gene doesn't run. Read inside a gene, it gives that gene's number; read at the end of the cycle, it gives the number of the last one. The numbering is in Genes: cond, start, else and stop.

It lets a gene refer to itself without knowing its number in advance, which can change if a mutation or a virus adds or removes genes before it. The typical case is the gene that deletes itself after running once:

cond
start
 *.thisgene 50 store
stop
cond
 *.robage 0 =
start
 *.thisgene .delgene store
stop

In the first cycle, cell 50 ends up at 1 and the second gene, which is gene 2, deletes itself with .delgene. It is also used with .mkvirus, so that a gene copies itself into a virus.

Writing to .thisgene has no effect: the engine overwrites it at the next marker.