As you probably know, RoboCom was designed so that the robots are very independant from each other, and cannot get a lot of information about their enemies. That's why, for example, the standard variables (#1...#20) are not remote accessible, nor can you find out on which bank your enemy runs.
But there is still a method to exchange data between robots1. It makes use of the fact that the (remote accessible) #active variable can't just be set to one or zero, but to any number. The result is the following:
-32768 .. 0 | robot inactive |
1 .. 32767 | robot active |
This can be used to specify a certain status the robot is in, either by setting #active to a certain value, so that the others have to read the value and act accordingly, or by setting %active to a certain value, so that your own value has to be checked regularly.
The simplest usage of this principle is an identifier if the bot is still in its original state. This is done by setting the active variable on creation to a certain value. Later in the game, the %active variable can be compared to this value to check if:
Below is a more complex example which shows how to use #active to spread out informations:
Following: Listing of Active.rob |
---|
;RoboCom program Name Active Alert Author Dennis C. Bemmann Country Germany ; An example program on %active communication. This program shows ; how to (ab)use the %active variable for communication. ; A simple alarm system: bots spread slowly, carefully regenerating their ; friends (anti-virus protection). However, if a bot makes contact with an ; enemy, an alarm signal is triggered and passed through to all friends, ; using the %active variable. After receiving the alarm signal, the bots ; pass it on to more friends and then jump to a simplified program which ; is optimized on dealing with enemies (no time-consuming expansion or ; regeneration anymore). If after some time of running the simplified ; program the bot is still alive and the alarm has not been re-triggered ; by a direct neighbor, the bot jumps back to the normal program. ; This program is kept simple and only demonstrates %active ; communication. Several other aspects of good bot design were ; disregarded in order to keep it small and easy to understand. ; Test it against programs like ; Persuaders 3 ; <MegaMorf> Bank ActiveAlert ; ---------- the default program ---------- ; Build clones on free fields, regenerate friends (anti-virus ; protection). If enemy bot found: alarm friends, get simplified jump @Scan @NoEnemy ; no enemy on next field. ; if friend: pass program on (regenerate) ; if free: build new bot and program it (clone) comp #4, 2 create 2, 2, 0 trans 1, 1 add %active, 1 turn 0 ; Is the alarm bell ringing? comp #active, 760 ; no: okay, no need for panic. jump @Scan ; yes, alarm! pass alarm on and get simplified set %active, 760 turn 0 jump @Alarm @Scan scan #4 comp #4, 1 jump @NoEnemy ; Enemy detected! Deactivate it and alarm friends! set %active, 0 turn 0 Set #active, 760 @Alarm set %active, 760 turn 0 set %active, 760 turn 0 set %active, 760 ; ---------- the simplified program ---------- ; turn around and look for enemies. if found, erase first 4 banks. ; after doing this for awhile and still alive, return to normal prog. @Simplified turn 0 scan #5 comp #5, 1 jump @Yellow ; combat enemy set %active, 0 trans 2, 1 trans 2, 2 trans 2, 3 trans 2, 4 set %active, 1 @Yellow add #active, 1 comp #active, 768 jump @Simplified jump @Scan |
There are even more methods to use active communication. There are #active viruses, etc... The possibilities seem unlimited, though it's just one single variable!
There will be other possiblities of data exchange in RoboCom 3, i.e. by using the #PUB variable, which is equal -and can be read from and written to- from all robots on the board.