From news-rocq.inria.fr!doligez Sat Apr 18 14:22:41 1998 Article: 8866 of rec.games.corewar Path: news-rocq.inria.fr!doligez From: Planar Newsgroups: rec.games.corewar Subject: Re: My first good warrior?? Any advice? Date: 17 Apr 1998 20:10:50 GMT Organization: "" Lines: 101 Sender: doligez@inria.fr (Damien Doligez) Message-ID: <6h8d0a$lrl@news-rocq.inria.fr> References: <1998041520431800.QAA20731@ladder03.news.aol.com> NNTP-Posting-Host: volnay.inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit >From: mtstahl@aol.com (MTStahl) > >This is the first 'good' warrior I've made. I don't think it'll win anything on >the pizza server, but it's worth a try. If anyone has any free advice on it >they'd like to share I'd love to hear it. I wouldn't call it "good", since it is syntactically incorrect. But it illustrates the most common beginner errors, and understanding why will give you some useful notions of Redcode. >;redcode-88 This is supposed to be a warrior written in Redcode-88, but many of its instructions use addressing modes that are illegal in '88 (but legal in '94), so we'll assume Redcode-94. >;assert CORESIZE==8000 The warrior doesn't depend on CORESIZE in any way, so why not "assert 1" ? >core DAT 0,0 >scan ADD #1,#0 This instruction is expanded to 'ADD.AB #1, #0'. It increments its own B-field. The B-field is now 1, so it points to the next instruction. This is not good, because you're going to scan your own warrior. Make this "ADD #1, #7", for example. > SEQ core,scan This will skip the next instruction if the instruction at 'core' (the DAT) is the same as the instruction at 'scan' (the ADD), which is not true. I'm sure you mean something like "SEQ core, @scan", which would skip if the DAT is equal to the instruction pointed by (the B-field of) the instruction at scan. > DAT @scan You then execute the DAT, and die. Not very efficient. I presume you want to do "MOV core, @scan" > SEQ #core-#CORESIZE-#1,@scan This one doesn't make sense at all, and is refused by pmars. The A-field of the instruction should be a constant: the instruction does not compute its A-field (the same is true of the B-field). So the first argument of this instruction should be something like "#-1". Now, for the second argument, it is the B-field of scan itself that you want to compare, not the B-field of the instruction pointed by scan. So this line should read "SEQ #-1, scan". > JMP scan OK > SUB scan,scan This will subtract the fields of scan from themselves, resetting the "scan" instruction to "ADD #0, #0". No good. > ADD #7,scan Let's remove the previous instruction, and make this "MOV.AB #7, scan". > JMP scan > END scan OK. This is a working version of your warrior: ;redcode ;name Stalin is dead too ;author Max Stahl & Planar ;assert 1 core DAT 0,0 scan ADD.AB #1,#7 SEQ.I core, @scan MOV.I core, @scan SEQ.AB #-1, scan JMP scan MOV.AB #7, scan JMP scan END scan It is not a very efficient warrior, but you have to understand the instructions first, then worry about strategy and optimisation. HTH, -- Planar P.S. Did you read the various beginner's guides for Redcode ?