Bots and Simulations > The Gene depository
Antivirus
Shasta:
I'm not sure if anyone has done this yet, I didn't see anything (although I didn't look very hard.)
Here is an antivirus that works with the random virus gene placement. I made it work in animal minimals as it was short and practically everyone has seen it, so you can notice the changes. This will work in any bot, it will just take quite a bit of writing for longer ones. I heavily commented the antivirus gene, an un-commented version is attached below.
--- Code: ---'Animal_Minimalis
'By: Nums
'Good for mutation sims and for
'newbies to see how a basic bot works.
'Contains everything necessary for it
'to survive and reproduce.
def g1num 71
def g2num 72
def g3num 73
def g4num 74
def g5num 75
' Gene 1 Food Finder
cond
start
*.eye5 0 >
*.refeye *.myeye != and
*.refveldx .dx store
*.refvelup 30 add .up store
true
*.thisgene .g1num store 'Always Store the gene # for later
stop
' Gene 2 Eat Food
cond
start
*.eye5 50 >
*.refeye *.myeye != and
-1 .shoot store
*.refvelup .up store
true
*.thisgene .g2num store 'Always Store the gene # for later
stop
' Gene 3 Avoiding Family
cond
start
*.eye5 0 =
*.refeye *.myeye = or
314 rnd .aimdx store
true
*.thisgene .g3num store 'Always Store the gene # for later
stop
' Gene 4 Reproduce
cond
start
*.nrg 20000 >
10 .repro store
true
*.thisgene .g4num store 'Always Store the gene # for later
stop
' Gene 5 AntiVirus
cond
start
'Always Store the gene # for later
*.thisgene .g5num store
'Make Sure My Gene #s get A chance to record (if not here good genes get delted
*.robage 1 !=
'Check If first gene is still first
*.g1num 1 !=
'If Not, get rid of genes above it
*.g1num 1 sub .delgene store clearbool
'Check the distance between gene 1 and 2
*.g2num *.g1num sub 1 !=
'Delete the Genes below 2 if distance is > than 1
*.g2num 1 sub .delgene store clearbool
'Check the distance between gene 2 and 3
*.g3num *.g2num sub 1 !=
'Delete the Genes below 3 if distance is > than 1
*.g3num 1 sub .delgene store clearbool
'Check the distance between gene 3 and 4
*.g4num *.g3num sub 1 !=
'Delete the Genes below 4 if distance is > than 1
*.g4num 1 sub .delgene store clearbool
'Check the distance between gene 4 and 5
*.g5num *.g4num sub 1 !=
'Delete the Genes below 5 if distance is > than 1
*.g5num 1 sub .delgene store clearbool
'Check if gene 5 is last
*.genes *.g5num !=
'Delete the Genes above 5 if not
*.g5num 1 add .delgene store clearbool
stop
end
--- End code ---
[attachment=763:attachment]
On another note, once I finished this tonight during testing I noticed something strange. When virus gets deleted, if it already submitted a .mkvirus call, it WILL shoot, no matter what. So even though there is nothing to copy into a virus in the bot, it still does with the full original virus. I wasn't sure if this is a bug or not.
Not really sure if I worded that very well, but if you run a sim with self-replicating viruses and this bot you will see what I am talking about.
Well, there you go!
Peter:
Well, it seems like the anti-virus from furiae. Further I can tell it isn't completely virus-proof. It let the virus run for 1 cycle. It will delete it, but the virus can be harmful in the one cycle, but that is for every anti-virus system like that.
Shasta:
So what is the theory on deleting the virus before it can run? According to the order of actions here .delgene runs before positions are updated (I'm presuming this is were the virus infection happens), I know I'm thinking wrong somewhere.
I would have thought that this:
--- Code: --- *.genes 1 !=
*.thisgene 1 != and
*.thisgene 1 sub .delgene store clearbool
*.genes 1 !=
*.thisgene 1 = and
*.thisgene 1 add .delgene store
--- End code ---
would work for single gene bots, but it too deletes the virus after letting it run for one cycle
Peter:
I am no DB-coder, so I am not that sure.
But, what does the execution order to do with the running of the virus one cycle. If I am right the DNA will be executed. After that the memory locations have changed. And then will the execution order you linked to be executed.
Short said, all the genes will execute, becouse the memory locations have already been changed before this order begins. It means you do delete it, but what it has changed in memory will be executed. I am not even sure if mkvirus will make the original virus or the new gene that comes to his place after delgene.
And, also an anti-virus system like this or like furiae is pretty strict and strong. A virus can't normally do much damage. The only other case is that if the virus is injected in the last gene, it can in that gene overwrite any delgenes and keep in the dna.
Therefore inside a bot with more genes, you can make a better antivirus-system then a bot with less genes, my idea of a antivirus-system also includes some memory-overwriting of some locations in the last gene to make sure it can't do much what is harmful.
I can tell your anim. mini. has got a pretty good-antivirus, what virus could uterly destroy a bot within one cycle.
EricL:
I haven't had coffee yet, but I think it is possible to 'blindly' delete a virus before it has a chance to run even a single cycle.
A virus is DNA, it gets inserted as part of shot processsing, which happens in the order of execution before any robot actions are taken (including delgene) but after robot DNA has been executed and memory values have been changed by DNA. Thus, by the time delgene is 'executed', the virus in in the DNA, but it has not 'run' that cycle. The bot's memory that cycle does not reflect any stores performed by the virus code.
If the bot's DNA 'blindly' stored a value to delgene that cycle - on the cycle the virus shot hits the bot - then the DNA at the time delgene is executed will include the virus. (I say blindly because the bot has to store to .delgene on the cycle the infection occurs but there is no way for the bot to actually know a virus infection has occurred until the next cycle and thus no way for it to know it has been infected without the virus executing.) Gene numbers and such are calculated at the time .delgene is processed, so they will refelct the infection, so it is quite possible for .delgene to refer to the virus code before it has had a chance to execute.
So, bottom line, a bot can theoretically delete a virus before it runs, but it has to do so blindly. It can't know it's infected until the cycle after the infection, which means it can't know without letting the virus run at least one cycle.
Navigation
[0] Message Index
[#] Next page
Go to full version