Article 3145 of rec.games.corewar: Path: news.cs.utah.edu!dog.ee.lbl.gov!agate!soda.CSUA.Berkeley.EDU!mconst From: mconst@soda.CSUA.Berkeley.EDU (Michael Constant) Newsgroups: rec.games.corewar Subject: Pyramid v5.5 Source [was: More newbie questions...] Date: 25 Aug 1994 04:20:23 GMT Organization: Society for the Prevention of Cruelty to Vegetables, UC Berkeley Lines: 153 Message-ID: <33h667$jc4@agate.berkeley.edu> References: NNTP-Posting-Host: soda.csua.berkeley.edu In article , Mark Dobervich wrote: >I've been looking around and reading a bit of redcode, and it looks like >imps are almost impossible to beat. I figured out a way to do it using >the experamental rules, but can someone give me an example of a program >that can withstand imps, but was not writen totally for that purpose? It >can be written in '86, '88 or anything other than X. Here is the source for Pyramid v5.5 (written according to the proposed '94 standard). (I've actually been meaning to post this for quite a while now, I've just kept forgetting... sorry to anyone who was wondering when I'd post it.) Pyramid does *very* well against most imps, by finding them with the quick-scan and hitting the imp-code with vampire fangs before the imps actually get completely launched. Usually there will be a couple of imps surviving after the quick-scan, but certainly never as many as there are supposed to be :-) This doesn't really make much of a difference, however, since the regular vampire which is launched after the quick-scan incorporates a gate. However, the fact that some imps will be hit by the quick-scan is vital when fighting against gate- crashing imps, because it ensures that the spiral will *not* be able to crash through Pyramid's normal gate. That's how Pyramid beats Cannonade without a hyper-perfect gate. Pyramid is actually a pretty well-balanced program -- it survived at the top of the '94-draft hill for at least two months before being pushed down and finally off last week. ;redcode-94 ;name Pyramid v5.5 ;author Michael Constant ;strategy quick-vamp -> vampire ;macro ; ----------- Quick-Scan Parameters (see diagrams at end of program) ------- OVERLAP1 equ 50 OVERLAP2 equ 0 BIGSTEP equ 100 OFFSET equ 150 BOMBDIR equ -1 ; 1 is forward, -1 is backward SPACE equ 6 ; -------------------------------------------------------------------------- STEP equ 3364 first spl split wimp jmp #0, <-15 look qscan for 6 sne.x (first+OFFSET+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+(qscan*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)) mov.ab #(first+OFFSET+(qscan*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+6)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+6)*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+12)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+12)*2*BIGSTEP))-found, @found rof found jmz.b first, #0 add.b found, found2 sne.x @found, @found2 add.ab #(CORESIZE/2), found jmn.f 2, @found add.ab #BIGSTEP,found mkfang sub.ba found, qfang add.b found, qfang mov.i qfang, @qfang sub.f subber, qfang djn.b -2, #((BIGSTEP+(OVERLAP1+OVERLAP2))/SPACE)+1 found2 jmp first, #found+BIGSTEP qfang jmp (BOMBDIR*OVERLAP1)+pit+(qfang-found), #(-BOMBDIR*OVERLAP1)+found-qfang subber dat References: <1995Feb7.064112.1825@rhodes> NNTP-Posting-Host: soda.csua.berkeley.edu Randy Graham wrote: >I keep seeing warriors with strategies saying qcmp or qscan? I know >what a cmp-scanning or b-scanning warrior is. What is a qcmp or qscan >warrior supposed to be? It's a special type of cmp-scanning that uses a hardcoded scan pattern (instead of a scanning loop) to scan part of core very quickly (2 core locations per cycle, as opposed to .67 for a cmp-scanner). The basic quick-scan engine looks liks this: cmp loc1, loc2 ; loc1 and loc2 are 4000 apart mov #loc1, target ; if we found something, store location cmp loc3, loc4 ; loc3 is loc1+100, or close to that mov #loc3, target ... cmp loc39, loc40 mov #loc39, target target jmz failed, #0 ; see if we found anything mov target, target-1 mov bomb, vampire ;macro ; ----------- Quick-Scan Parameters (see diagrams at end of program) ------- OVERLAP1 equ 50 OVERLAP2 equ 0 BIGSTEP equ 100 OFFSET equ 150 BOMBDIR equ -1 ; 1 is forward, -1 is backward SPACE equ 6 ; -------------------------------------------------------------------------- STEP equ 3364 first spl split wimp jmp #0, <-15 look qscan for 6 sne.x (first+OFFSET+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+(qscan*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)) mov.ab #(first+OFFSET+(qscan*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+6)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+6)*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+12)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+12)*2*BIGSTEP))-found, @found rof found jmz.b first, #0 add.b found, found2 sne.x @found, @found2 add.ab #(CORESIZE/2), found jmn.f 2, @found add.ab #BIGSTEP,found mkfang sub.ba found, qfang add.b found, qfang mov.i qfang, @qfang sub.f subber, qfang djn.b -2, #((BIGSTEP+(OVERLAP1+OVERLAP2))/SPACE)+1 found2 jmp first, #found+BIGSTEP qfang jmp (BOMBDIR*OVERLAP1)+pit+(qfang-found), #(-BOMBDIR*OVERLAP1)+found-qfang subber dat References: <199512011330.OAA28436@iol-mail.iol.it> NNTP-Posting-Host: soda.csua.berkeley.edu Robert Macrae wrote: >mconst@soda.CSUA.Berkeley.EDU (Michael Constant) wrote: >>If you want to write a quickscanner, read Pyramid v5.5. There's no >>substitute. I've only posted it 10 or 15 times, but I'll post it again >>if anyone's missing a copy :-) > >Salutary lesson on the dangers of posting on a subject that has been >well covered before. I think 11-16 would do fine :-) Well, well, if you insist :-) I finally found my old diagrams, so I have included those as well. They make the job of deciphering the quick-scan parameters much easier! ;redcode-94 ;name Pyramid v5.5 ;author Michael Constant ;strategy quick-vamp -> vampire ;macro ; ----------- Quick-Scan Parameters (see diagrams at end of program) ------- OVERLAP1 equ 50 OVERLAP2 equ 0 BIGSTEP equ 100 OFFSET equ 150 BOMBDIR equ -1 ; 1 is forward, -1 is backward SPACE equ 6 ; -------------------------------------------------------------------------- STEP equ 3364 first spl split wimp jmp #0, <-15 look qscan for 6 sne.x (first+OFFSET+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+(qscan*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)) mov.ab #(first+OFFSET+(qscan*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+6)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+6)*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+12)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+12)*2*BIGSTEP))-found, @found rof found jmz.b first, #0 add.b found, found2 sne.x @found, @found2 add.ab #(CORESIZE/2), found jmn.f 2, @found add.ab #BIGSTEP,found mkfang sub.ba found, qfang add.b found, qfang mov.i qfang, @qfang sub.f subber, qfang djn.b -2, #((BIGSTEP+(OVERLAP1+OVERLAP2))/SPACE)+1 found2 jmp first, #found+BIGSTEP qfang jmp (BOMBDIR*OVERLAP1)+pit+(qfang-found), #(-BOMBDIR*OVERLAP1)+found-qfang subber dat References: <1995Feb7.064112.1825@rhodes> Nntp-Posting-Host: soda.csua.berkeley.edu Apparently-To: cbx.rec.games.corewar@valhalla.stormking.com Randy Graham wrote: >I keep seeing warriors with strategies saying qcmp or qscan? I know >what a cmp-scanning or b-scanning warrior is. What is a qcmp or qscan >warrior supposed to be? It's a special type of cmp-scanning that uses a hardcoded scan pattern (instead of a scanning loop) to scan part of core very quickly (2 core locations per cycle, as opposed to .67 for a cmp-scanner). The basic quick-scan engine looks liks this: cmp loc1, loc2 ; loc1 and loc2 are 4000 apart mov #loc1, target ; if we found something, store location cmp loc3, loc4 ; loc3 is loc1+100, or close to that mov #loc3, target ... cmp loc39, loc40 mov #loc39, target target jmz failed, #0 ; see if we found anything mov target, target-1 mov bomb, vampire ;macro ; ----------- Quick-Scan Parameters (see diagrams at end of program) ------- OVERLAP1 equ 50 OVERLAP2 equ 0 BIGSTEP equ 100 OFFSET equ 150 BOMBDIR equ -1 ; 1 is forward, -1 is backward SPACE equ 6 ; -------------------------------------------------------------------------- STEP equ 3364 first spl split wimp jmp #0, <-15 look qscan for 6 sne.x (first+OFFSET+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+(qscan*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)) mov.ab #(first+OFFSET+(qscan*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+6)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+6)*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+12)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+12)*2*BIGSTEP))-found, @found rof found jmz.b first, #0 add.b found, found2 sne.x @found, @found2 add.ab #(CORESIZE/2), found jmn.f 2, @found add.ab #BIGSTEP,found mkfang sub.ba found, qfang add.b found, qfang mov.i qfang, @qfang sub.f subber, qfang djn.b -2, #((BIGSTEP+(OVERLAP1+OVERLAP2))/SPACE)+1 found2 jmp first, #found+BIGSTEP qfang jmp (BOMBDIR*OVERLAP1)+pit+(qfang-found), #(-BOMBDIR*OVERLAP1)+found-qfang subber dat References: <199512011330.OAA28436@iol-mail.iol.it> NNTP-Posting-Host: soda.csua.berkeley.edu Apparently-To: cbx.rec.games.corewar Robert Macrae wrote: >mconst@soda.CSUA.Berkeley.EDU (Michael Constant) wrote: >>If you want to write a quickscanner, read Pyramid v5.5. There's no >>substitute. I've only posted it 10 or 15 times, but I'll post it again >>if anyone's missing a copy :-) > >Salutary lesson on the dangers of posting on a subject that has been >well covered before. I think 11-16 would do fine :-) Well, well, if you insist :-) I finally found my old diagrams, so I have included those as well. They make the job of deciphering the quick-scan parameters much easier! ;redcode-94 ;name Pyramid v5.5 ;author Michael Constant ;strategy quick-vamp -> vampire ;macro ; ----------- Quick-Scan Parameters (see diagrams at end of program) ------- OVERLAP1 equ 50 OVERLAP2 equ 0 BIGSTEP equ 100 OFFSET equ 150 BOMBDIR equ -1 ; 1 is forward, -1 is backward SPACE equ 6 ; -------------------------------------------------------------------------- STEP equ 3364 first spl split wimp jmp #0, <-15 look qscan for 6 sne.x (first+OFFSET+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+(qscan*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+(qscan*2*BIGSTEP)) mov.ab #(first+OFFSET+(qscan*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+6)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+6)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+6)*2*BIGSTEP))-found, @found rof jmn found+1,found qscan for 6 sne.x (first+OFFSET+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+((qscan+12)*2*BIGSTEP)) seq.x (first+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)), (first+(CORESIZE/2)+OFFSET+BIGSTEP+((qscan+12)*2*BIGSTEP)) mov.ab #(first+OFFSET+((qscan+12)*2*BIGSTEP))-found, @found rof found jmz.b first, #0 add.b found, found2 sne.x @found, @found2 add.ab #(CORESIZE/2), found jmn.f 2, @found add.ab #BIGSTEP,found mkfang sub.ba found, qfang add.b found, qfang mov.i qfang, @qfang sub.f subber, qfang djn.b -2, #((BIGSTEP+(OVERLAP1+OVERLAP2))/SPACE)+1 found2 jmp first, #found+BIGSTEP qfang jmp (BOMBDIR*OVERLAP1)+pit+(qfang-found), #(-BOMBDIR*OVERLAP1)+found-qfang subber dat