Subject: Retrovirus1.0 and large programs From: rjc@hal.gnu.ai.mit.edu (Ray) Organization: ^ Date: 13 Dec 91 12:36:26 GMT Message-ID: <21021@life.ai.mit.edu> With all the recent arguing over small-braindead vs large-intelligent programs I decided to try and write a large program to see if it was possible for a large program to beat a small one. My results are somewhat mixed. Large programs have the disadvantage of being easy to hit (big targets), too big to copy quickly, and slow to execute. In designing this program I chose to "offload" the expense of copying to the opposing warrior, while excuting a small subverting loop. The bonus is, even if the program is damaged it is more likely to be damaged in the copy/bomb routines rather than the scan/subvert simply because they are larger. The effect of this is, the program will go on scanning/subverting only this time, the opposing warrior will die from excuting damaged code. With all these effects, Retrovirus still loses alot. For instance a lucky hit by mice kills it, but I think it kills mice far more often. It kills chang1, commando, raidar, and most of the others in the redcode.tar.Z on soda.bereley.edu. Still, a large program can never fully defend itself against something like mortar simply because the address range is unlimitied. I think address range limitations (CORESIZE/16) will provide a much more interesting game since programs will have to send out scouts on bombing missions. The strain that the unlimited addressing puts on the game can be summarized as follows: start mov b @a add a b mov @a a jmp start a dat #5 b dat #8 (optimized version of mortar) It is very hard to hit this program and it succeeds in beating lots of programs in the first 1000-2000 cycles. I have tried self-repairing programs but they are no good simply because you can't tell whether another one of the error-correcting tasks has died. For instance, task1, task2, and task3 are constantly comparing programs 1, 2, and 3 looking to fix errors. If task3 gets hit, task1 and task2 will detect the damage and fix it, but they have no way of knowing whether task3 died or not. If they SPLit off another task3, and task3 is still running, two copies will be running at the same time which is chaos on non-reentrant code. (unless you implement a stack) If the address range limitation is added to the standard, I hope some environment variables are defined so corewars program can adapt to changing sizes. (e.g. mov #ADDRESS_RANGE ptr, fence mov #0 ptr, djn fence ptr) In fact, I think corewars should get a better preprocessor (EQU is good, but how about somethinglike #ifdef, and more env vars like CORESIZE, __ICWSVERSION__, etc to make programs more portable.) I think limited address ranges will solve the large vs small problem! An address range of +/- 500 on a coresize of 8000 seems adequate to stop programs like mortar from being so offensive. -------------------------------------------------------------------------- ;;Retrovirus v1.0 ;;By Ray Cromwell (rjc@gnu.ai.mit.edu) ;;USA ;;December 1991 ;;Technique: Subvert other program, so that it impstomps and copies ;; our virus for it. ;; (not optimized, yet) ;; Idea came from Tierra (artificial life program), ;; see comp.theory.cell-automata for more details. rnaoffset equ virusrna-memptr exoff equ (833-(endprog-startprog)+(execaddr-dest)) pend equ endprog-ptr ;; ;; Impstomp. Opposing warrior usually executes this. ;; startprog dat #0 impstomp mov #0 startprog imp2 mov #0 startprog mov #0 startprog mov #0 startprog jmp impstomp ;; ;; Constants and pointers ;; jmp0 jmp 0 jmp1 jmp 1 jmp5 jmp 5 jmpvec jmp 600+rnaoffset ;make sure jmp points to "virusrna" routine memptr dat #-600 tmp dat #0 imp mov 0 1 size dat #0 ptr dat #0 dest dat #0 delta dat #0 ;; ;; Startup ;; start mov stopper virusrna ;inialize some constants ; and vectors mov jmp5 tmp ; sub jmp0 tmp ;Find jmp5-jmp0 mov jmp1 delta ; sub jmp0 delta ;Find jmp1-jmp0 ;; ;; Scan loop ;; mainloop cmp dabomb @memptr ;scan for nonzero code jmp subvert ;if non zero, subvert it! s4 sub #5 memptr ;sub 5 from ptr add tmp jmpvec ;add 5 to jmp instruction tjmp jmp mainloop ;loop ;; ;; Bombing after subversion ;; mov njmp tjmp ;fix vector mov memptr delta ;temporary register add #60 delta ;fudge for time-delay bombit cmp @delta tagid ;about to bomb us? jmp bomb ;bomb! sub #(endprog-startprog+6) delta ;skip us! bomb mov dabomb