Author Topic: Antivirus  (Read 5490 times)

Offline Shasta

  • Administrator
  • Bot Destroyer
  • *****
  • Posts: 231
    • View Profile
Antivirus
« on: December 18, 2007, 12:10:36 AM »
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: [Select]
'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

[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!  

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Antivirus
« Reply #1 on: December 18, 2007, 08:01:48 AM »
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.
Oh my god, who the hell cares.

Offline Shasta

  • Administrator
  • Bot Destroyer
  • *****
  • Posts: 231
    • View Profile
Antivirus
« Reply #2 on: December 19, 2007, 12:32:52 AM »
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: [Select]
  *.genes 1 !=
  *.thisgene 1 != and
  *.thisgene 1 sub .delgene store clearbool
  *.genes 1 !=
  *.thisgene 1 = and
  *.thisgene 1 add .delgene store
would work for single gene bots, but it too deletes the virus after letting it run for one cycle  

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Antivirus
« Reply #3 on: December 19, 2007, 08:49:09 AM »
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.
Oh my god, who the hell cares.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Antivirus
« Reply #4 on: December 19, 2007, 11:02:12 AM »
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.
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Antivirus
« Reply #5 on: December 19, 2007, 11:09:53 AM »
Can you delgene numgenes + 1?  That would let you delete a virus if it manages to get lucky and gets inserted into the last position in the DNA.  If you don't have to worry about a virus comming last, then antivirus techniques become much simpler.  You can guarentee that your last gene wipes away any mkvirus or vshoot commands.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Antivirus
« Reply #6 on: December 19, 2007, 11:55:30 AM »
Quote from: Numsgil
Can you delgene numgenes + 1?  That would let you delete a virus if it manages to get lucky and gets inserted into the last position in the DNA.  If you don't have to worry about a virus comming last, then antivirus techniques become much simpler.  You can guarentee that your last gene wipes away any mkvirus or vshoot commands.
I see no reason why this won't work except that when a infection happens where the insertion isn't last, the gene with the delgene will delete itself...  And of course, a bot can potentially get hit by two or more virus shots in the same cycle and you can only .delgene one gene per cycle..  

This is one reason I want a richer virus targeting mechanism.  There are co-evolution riches to explore here.
Many beers....

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Antivirus
« Reply #7 on: December 19, 2007, 12:36:35 PM »
Quote from: Shasta
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.
On the cycle .mkvirus goes non-zero, if .vtimer is 0, the DNA of the specified gene gets snapshotted and stored.  If will get shot on the next cycle where .vtimer is 0 and the bot sets .vshoot to something non-zero.

If the virus is firing without the bot storing into .vshoot or before .vtimer counts down to 0, that is a bug.  It's not a bug that the virus contains the original DNA even after that gene is deleted in the mainline DNA.

But this begs an interesting question: once .mkvirus is executed, there is no way for a bot to change it's mind and cancel the virus short of creating a new virus.  I do beleive that if .mkvirus is set again (once .vtimer has counted down to 0) the new virus will supplant the old without the old being fired.  It looks like we might leak a shot here though, but that's a bug for me to investigate.
Many beers....

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Antivirus
« Reply #8 on: December 20, 2007, 09:11:40 PM »
Might be able to make a better antivirus method out of that. Tons safer than trying to use delgene to delete what you think might be an actual virus. Might even be happening naturally, helping spread genes and limiting viruses at the same time.

Could still use a better system for viruses though. Kind of messed up that all of our viruses are Retro viruses, be better if there were viruses that replicated without being incorporated into the genome.

Offline MacadamiaNuts

  • Bot Destroyer
  • ***
  • Posts: 273
    • View Profile
Antivirus
« Reply #9 on: December 20, 2007, 10:30:04 PM »
Yeah I suggested something about that once.

Like:

hack
virusstuff
virusstuff
virusstuff
endhack

being inserted anywhere, hack and endhack being ignored during execution, the whole block deleted upon reproduction, .mkvirus making reference to existing hack blocks instead of genes, and adding *.thishack for self replication.
Sometimes you win, and sometimes you lose...