The basic way is to have a program scan for bots and if it encounters an opponent, transfer a program which is designed to spread across and harm the other bots. This can go from keeping them busy up to self-destruction after a delay.
Important issues are:
The 3rd issue is especially important, since a virus has no influence on a bot if it's not in the running bank. If a virus can force opponent bots to a certain bank, it gets easier to keep the infection going on, because it doesn't need to infect many banks anymore (and thus gets very fast and hard to combat). Common strategies to make sure that your opponent runs your virus are:
In some cases, virii can be designed to run in both your own bots and your opponents, but just be harmful to your opponents. One example for this is to have the program build very simple bots and only spread the virus. This can be used for your own bots to expand your territory and against your opponents by keeping them busy and (important:) keeping them in a defined state that you know about. A very simple example is to set a variable to a certain code number and check it from time to time. Another very nice example is the programs which only use one single bank and rely on the fact that most others have at least two banks. With this presumption you can write a program which does useful things but causes a fatal error if the bot executing it has more than one bank - thus it can be used as a virus. There was some genial and very simple bot which did this around June '98, but I don't remember its name. Anybody else maybe?
Another quick advice: the elimination trigger can be (ab)used to kill a robot after a certain delay, by simply incrementing a variable somewhere in a loop.
To see how virii can be implemented, you can take a look at
Persuaders 3 | the first virus in RoboCom |
(((Infector))) | another early virus |
Strikers 0.9 | run against older bots like DJC, CopyBot |
Outer Limits | Picard's very simple but genial masterpiece |
Kreuziger | it infects bots... among MANY other things... |
Everybody is invited to suggest more examples. I just proposed some bots that came to mind because I know well how they work. Yes, simple programs are very welcome, since we're talking about how to do it, not about perfection.