From news-rocq.inria.fr!univ-lyon1.fr!in2p3.fr!oleane!plug.news.pipex.net!pipex!tube.news.pipex.net!pipex!lade.news.pipex.net!pipex!tank.news.pipex.net!pipex!howland.reston.ans.net!gatech!purdue!mozo.cc.purdue.edu!cartoon.ecn.purdue.edu!bremermr Tue Jan 16 10:24:23 1996 Article: 3570 of rec.games.corewar Path: news-rocq.inria.fr!univ-lyon1.fr!in2p3.fr!oleane!plug.news.pipex.net!pipex!tube.news.pipex.net!pipex!lade.news.pipex.net!pipex!tank.news.pipex.net!pipex!howland.reston.ans.net!gatech!purdue!mozo.cc.purdue.edu!cartoon.ecn.purdue.edu!bremermr From: bremermr@cartoon.ecn.purdue.edu (Myer R. Bremer) Newsgroups: rec.games.corewar Subject: Core Warrior #12 Date: 15 Jan 1996 21:02:08 GMT Organization: Purdue University, W. Lafayette, IN Lines: 732 Message-ID: <4defcg$gtd@mozo.cc.purdue.edu> NNTP-Posting-Host: cartoon.ecn.purdue.edu .xX$$x. .x$$$$$$$x. d$$$$$$$$$$$ ,$$$$$$$P' `P' , . $$$$$$P' ' .d b $$$$$P b ,$$x ,$$x ,$$x ,$$b $$. Y$$$$' `$. $$$$$$. $$$$$$ $$P~d$. d$$$b d d$$$ `$$$$ ,$$ $$$$$$$b $$$P `$ $$$b.$$b `Y$$$d$d$$$' . . a . a a .aa . a `$$$ ,$$$,$$' `$$$ $$$' ' $$P$XX$' `$$$$$$$$$ .dP' `$'$ `$'$ , $''$ `$'$ `Y$b ,d$$$P `$b,d$P' `$$. `$$. , `$$P $$$' Y $. $ $ $ Y..P $ `$$$$$$$' $$$P' `$$b `$$$P `P `$' `Y'k. $. $. $. $$' $. Issue 12 January 15, 1996 ______________________________________________________________________________ Core_Warrior_ is a weekly newsletter promoting the game of corewar. Emphasis is placed on the most active hills--currently the '94 draft hill and the beginner hill. Coverage will follow where ever the action is. If you have no clue what I'm talking about then check out these five-star internet locals for more information: FAQs are available by anonymous FTP from rtfm.mit.edu as pub/usenet/news.answers/games/corewar-faq.Z FTP site is: ftp.csua.berkeley.edu /pub/corewar Web pages are at: http://www.stormking.com/~koth ;Stormking http://www.ecst.csuchico.edu/~pizza/koth ;Pizza http://pauillac.inria.fr/~doligez/corewar/ ;Planar ______________________________________________________________________________ Greetings. Everyone get a chance to check out that mega-queue at Pizza? Sheesh. It's interesting that everyone concentrates almost exclusively on the one vs one coresize equals 8000 hills. Other hills were created out of discussions in the newsgroup, and many initially received a lot of activity. But everyone eventually moves back to the -94 and -b hills. The beginners' hill may condition authors to the one vs one 8000 style hill. The -94 hill is a logical progression. And since all the veterans still submit there quite regularly, that's where all the competition is. With the corewar farm system the way it is and the momentum of the -94 draft hill, the situation won't likely get any more diverse. Which is a shame since Tuc recently has revised Stormking's hills to accomodate a lot of the requests mentioned in various postings. Revisions include the following: ;password identifies the password for this warrior. ;kill kills a warrior. Must be used with ;password ;newpasswd assigns a new password for a warrior. Must be used with the original ;redcode ;name and ;password lines. ;newredcode assigns a new redcode line for a warrior. Must include the new ;redcode line ;name and ;password lines. This allows allows authors to change from ;redcode quiet to ;redcode verbose or whatever the desired response level. For a complete listing mail kothtest@stormking.com (;help for a menu). There are also additional modifications to the web page that let browsers view strategy lines and source code at the author's discretion. Lots of thanks goes to Tuc for his work. Let's really put his coding skills to the test and try to break his hills. ______________________________________________________________________________ Current Status of the Internet Pizza Server ICWS '94 Draft Hill: Hill Specs: coresize: 8000 max. processes: 8000 duration: after 80,000 cycles, a tie is declared. max. entry length: 100 minimum distance: 100 rounds fought: 200 instruction set: ICWS '94 Draft Last challenge: Mon Jan 15 05:13:19 PST 1996 # %W/ %L/ %T Name Author Score Age 1 35/ 39/ 26 quiz Schitzo 131 388 2 21/ 12/ 67 Impfinity v4g1 Planar 130 188 3 31/ 33/ 36 Test Robert Macrae 130 38 4 17/ 6/ 77 Evol Cap 6.6 John Wilkinson 129 3 5 22/ 15/ 63 Hector 2 Kurt Franke 128 303 6 25/ 23/ 51 Jack in the box Beppe Bezzi 128 755 7 33/ 38/ 29 Harmony P.Kline 127 30 8 16/ 6/ 78 Evol Cap 6.2a John Wilkinson 127 22 9 34/ 42/ 24 Frontwards v2 Steven Morrell 127 241 10 15/ 5/ 79 Night Train Karl Lewin 126 275 11 24/ 23/ 54 La Bomba Beppe Bezzi 125 383 12 28/ 33/ 39 Mason 2.0 Robert Macrae 124 124 13 14/ 5/ 81 DoorMat v0.1 K Lewin 124 237 14 33/ 42/ 25 Provascan 3.0 Beppe Bezzi 123 138 15 17/ 11/ 71 Cheap Hack M R Bremer 123 75 16 31/ 39/ 31 Boombastic Maurizio Vittuari 123 123 17 30/ 37/ 33 Koolaid II: WoGG v2.2 David Boeren 123 5 18 16/ 10/ 73 Evol Cap VII .3 John Wilkinson 123 19 19 13/ 5/ 82 .2 Evolve VIII John Wilkinson 122 9 20 31/ 39/ 30 testnorm Maurizio Vittuari 122 7 21 26/ 30/ 43 Torch t18 P.Kline 122 767 22 20/ 19/ 61 juliet and paper M R Bremer, B. Bezzi 121 384 23 29/ 38/ 33 paris Kafka 120 2 24 24/ 28/ 48 Blue Funk 5 Steven Morrell 120 24 25 10/ 0/ 90 Evolve VIII John Wilkinson 119 1 The hill has aged 47 this week. Average scores continue downward to 120 (128 last week, 136 the week before) as the five versions of evol* tie everything on the hill. Only 12 points separate number 1 from number 25. The average age is 182 compared with 162 last week. Torch has been suffering lately. It was seen as high as fifth, but it has been sulking in the high teens and low twenties the last few challenges. Jack in the box continues to prove effective. With the loss of interest in pspace and as a result--brainwashing, Jack can adapt fairly well to new warriors. Redundant scanners and Torch style bombers are effective against it, but some--Pulido's FireMaster and Macrae's Harm--were forced off the hill earlier. Now Jack rides in 6th place. Dat bombers seem to be ineffective. Aeka and juliet storm were removed from the hill after debuting quite well. The newest version of Tornado was also eliminate. Blue Funk 5 still clings to life, but with a tenuous grasp at best. It did shoot up the hill into the top ten with the introduction of a few scanners, but they were very short lived. Impfinity seems to be an exception, even with a published source code. Also successful is Macrae's Test warrior which the strategy lines proclaim to be a quick scan / bomber. quiz is on top of the heap as usual. However it's grasp is not the steel fist it once was. Impfinity, Test, and Frontwards have all been in first place this week. ______________________________________________________________________________ 94 - What's New 3 31/ 33/ 36 Test Robert Macrae 130 38 4 17/ 6/ 77 Evol Cap 6.6 John Wilkinson 129 3 17 30/ 37/ 33 Koolaid II: WoGG v2.2 David Boeren 123 5 18 16/ 10/ 73 Evol Cap VII .3 John Wilkinson 123 19 19 13/ 5/ 82 .2 Evolve VIII John Wilkinson 122 9 20 31/ 39/ 30 testnorm Maurizio Vittuari 122 7 23 29/ 38/ 33 paris Kafka 120 2 24 24/ 28/ 48 Blue Funk 5 Steven Morrell 120 24 25 10/ 0/ 90 Evolve VIII John Wilkinson 119 1 Test entered the hill in first place and reclaims that spot every few hill challenges. Perhaps Macrae will give his warrior a name sometime soon. ______________________________________________________________________________ 94 - What's No More 26 2/ 2/ 0 test9 Maurizio Vittuari 5 2 26 3/ 1/ 0 itest ai 8 8 26 25/ 47/ 28 John's Zizzor 2h John Wilkinson 103 2 26 17/ 19/ 65 myOmy Paulsson 114 15 26 28/ 35/ 37 Tornado 2.0 h1 Beppe Bezzi 122 193 26 0/ 0/ 4 Evol Cap 6.2 John Wilkinson 4 38 26 25/ 30/ 45 endpoint . M R Bremer 121 37 26 24/ 24/ 52 juliet storm M R Bremer 124 59 26 34/ 47/ 19 seventyfive Anders Ivner 121 82 Tornado is the biggest loss at age 193. ______________________________________________________________________________ What's Old 21 26/ 30/ 43 Torch t18 P.Kline 122 767 6 25/ 23/ 51 Jack in the box Beppe Bezzi 128 755 1 35/ 39/ 26 quiz Schitzo 131 388 22 20/ 19/ 61 juliet and paper M R Bremer, B. Bezzi 121 384 11 24/ 23/ 54 La Bomba Beppe Bezzi 125 383 5 22/ 15/ 63 Hector 2 Kurt Franke 128 303 10 15/ 5/ 79 Night Train Karl Lewin 126 275 9 34/ 42/ 24 Frontwards v2 Steven Morrell 127 241 13 14/ 5/ 81 DoorMat v0.1 K Lewin 124 237 Another of Lewin's warriors, DoorMat, enters the over 200 mark. La Bomba, juliet and paper, and quiz all begin their journey up the hall of fame ranks. ______________________________________________________________________________ HALL OF FAME * means the warrior is still running. Pos Name Author Age Strategy 1 Iron Gate 1.5 Wayne Sheppard 926 CMP scanner 2 Agony II Stefan Strack 912 CMP scanner 3 Blue Funk Steven Morrell 869 Stone/ imp 4 Thermite 1.0 Robert Macrae 802 Qscan -> bomber 5 Torch t18 P.Kline 767 * Bomber 6 Blue Funk 3 Steven Morrell 766 Stone/ imp 7 Jack in the box Beppe Bezzi 755 * P-warrior 8 HeremScimitar A.Ivner,P.Kline 666 Bomber 9 myVamp v3.7 Paulsson 643 Vampire 10 Armory - A5 Wilkinson 609 P-warrior 11 Phq Maurizio Vittuari 589 Qscan -> replicator 12 B-Panama X Steven Morrell 518 Stone/ replicator 13 quiz Schitzo 388 * scanner/ bomber 14 NC 94 Wayne Sheppard 387 Stone/ imp 15 juliet and paper Bremer & Bezzi 384 * P-warrior 16 La Bomba Beppe Bezzi 383 * Qscan -> replicator 17 Cannonade P.Kline 382 Stone/ imp 18 Torch t17 P.Kline 378 Bomber 19 Lucky 3 Stefan Strack 355 Stone/ imp 20 Derision M R Bremer 351 Scanner 21 Request v2.0 Brant D. Thomsen 347 Qvamp -> vampire 22 Dragon Spear c w blue 346 CMP scanner 23 Leprechaun on speed Anders Ivner 344 Qscan -> scanner/bomber The hall of fame will be slowly expanded to 25 slots to match the number of rankings on the '94 hill. ______________________________________________________________________________ Current Status of the Internet Pizza Server Beginner's Hill: Hill Specs: coresize: 8000 max. processes: 8000 duration: after 80,000 cycles, a tie is declared. max. entry length: 100 minimum distance: 100 maximum age: At age 100, warriors are retired. rounds fought: 200 instruction set: ICWS '94 Draft Last challenge: Sun Jan 14 17:35:23 PST 1996 # %W/ %L/ %T Name Author Score Age 1 57/ 23/ 20 Fire Master v1.6 JS Pulido 191 4 2 58/ 27/ 15 Koolaid II: The Wrath of David Boeren 190 34 3 51/ 29/ 20 Our Vamp v2 R Bartolome & JS Pul 173 83 4 48/ 36/ 16 Assassin XII Andy Nevermind 160 16 5 34/ 9/ 57 RingWorm_v2.5 Calvin Loh 160 23 6 46/ 36/ 19 Monitor M R Bremer 155 12 7 36/ 22/ 42 Spacehead1.1 Warpi 151 95 8 32/ 19/ 48 Thunder V 1.0 Andy Nevermind 145 30 9 39/ 34/ 27 Winter Werewolf W. Mintardjo 143 75 10 35/ 32/ 33 Inherit v0.9 Philemon 138 14 11 37/ 37/ 25 RedPixel.2 John Lewis 137 31 12 37/ 38/ 25 Test Stone #1 David Boeren 135 50 13 35/ 39/ 26 test.1 Anton Marsden 131 1 14 31/ 34/ 34 Everybody Must Get Vamped Nathan Summers 129 42 15 22/ 21/ 57 Spiral Again Calvin Loh 122 24 16 21/ 21/ 57 Spiral Again Calvin Loh 121 22 17 29/ 40/ 31 EveryoneMustGetStoned 2.5 Nathan Summers 117 41 18 11/ 5/ 84 Evol Cap 6.1 John Wilkinson 117 13 19 17/ 19/ 65 SpiralTest2 Calvin Loh 115 33 20 25/ 36/ 39 StoneTest v2.1 Raul Bartolome 114 8 21 29/ 44/ 27 Forked Lite Ning 4.07 Ansel Greenwood Serm 114 5 22 23/ 44/ 33 Mixed 0.1 Philemon 101 7 23 23/ 47/ 29 StoneTest v1.2 Raul Bartolome 99 11 24 24/ 50/ 26 FireSilk v1.3B Raul Bartolome 98 20 25 26/ 56/ 17 Test Ian Oversby 96 2 Koolaid had a lock on the top spot until Pulido re-introduced Fire Master. However, Koolaid has settled in on the '94 draft hill at 17th place while Fire Master was pushed off. Don't be discouraged if your warrior does well on the b-hill and not the '94 draft hill. The composition of the hill has a lot to do with a warrior's success. Keep trying. A big welcome to some of the new names I've seen here. The core war community is generally willing to answer your questions in the rec.games.corewar newgroup. Don't be shy. The 'Monitor'ing warrior I submitted to track the hill is included below. Feel free to hack any piece of it for yourself. ;redcode-b ;name Monitor ;author M R Bremer ;kill Monitor ;strategy Need to track the b-hill. ;strategy 3-shot to scan to partial spl dat clear ;strategy Not the time or energy for full double spl/dat u jmp o, o s add.f inc, 2 mov.i off, @1 p mov.i >-2, @0 jmz.a -3, *-1 djn.b -4, #2 o spl #20, 10 ; self hit in b field sometimes mov.i @u, }p mov.i @u, }p djn.f -2, <-20 d dat 20, <2667 for 27 dat 0, 0 rof off dat 1, 445 inc dat -445, 445*2 ______________________________________________________________________________ The Hint C. The speed of light. Authors use C to denote the speed of a scan or bomb pattern. A sne/seq/mov quick scan operates at 2c or 200% of C until it finds something. An add/mov/djn bomber dat bombs at .33c. The decrement or increment in the move and the djn stream typically makes it more viscious. At times, a corewar challenge simply reduces to who can find who first. So the quest becomes to increase speed while keeping as small a profile as possible. A cmp scanner usually uses an add/cmp/slt/djn engine. This warrior will search core at .66c. By postponing the djn and 'unrolling' the engine, we can increase the speed to .8c. Taking Names is a good example. Notice the scan engine now uses an add/sne/add/seq/slt/djn sequence. If the sne spots something, the second add is skipped and the seq will fall through to the slt instruction. ;redcode-94 quiet ;name Taking Names ;kill Taking Names ;author P.Kline ;strategy sne.x/seq.x scanner using spl-spl-jmp bomb ;strategy and continuous forward-clear step equ 98 clrptr dat jump+2 dat 0,0 reset dat #step-2,#step for 19 dat 0,0 rof attack mov jump,*comp ; drop wide bomb on a-pointer compptr mov split,{comp mov split,{comp ; after bombing, reset to sub reset,@compptr ; make b-pointer the next a-pointer scan add split,@compptr comp sne 2*step,3*step ; take a look add split,@compptr seq *comp,@comp ; take another look slt #100+step,@compptr ; don't attack self ctr djn scan,#1000 ; countdown to finish jmn attack,-1 split spl.i #(2*step),#(2*step) clear mov reset,>clrptr ; continuous forward clear jump jmp -1 for 30 dat 0,0 rof for 12 dat #1,1 ; simple decoy mov.i #attack+1000,2667 rof end comp Of course you pay for the increased speed with increased size. Is an increase from .66c to .8c worth 2 extra instructions? Perhaps. Another way to increase speed is to use on of your bombs as a pointer for the other. A .5c jmz scan can be increase to .66c using just one more instruction. bomb add.ab #8, scan ;of course you can use anything as the bomb mov.i bomb, @scan ;the bomb falls wherever scan points to scan jmz.f -2, *XXXX ;the scan is made +8 addresses from the bomb This loop can be further modified to scan/bomb at .75c by adding yet another instruction. add.f inc, stone ;you'll need an inc and bomb line mov.i bomb, @stone stone mov.i XX, @XX jmz.f -3, *-1 Ivner created a .75c bomber using the following code. While more a hybrid scanner/bomber, this fragment bombs normally until the cmp finds something. Then the bomb pattern is realigned so that the bomb hits the scanned locations. b1 dat #2*STEP,#2*STEP c dat #3*STEP,#3*STEP loop add c, pt mov b1, @pt pt cmp A, @A-STEP sub b1, pt djn loop, #COUNT Here is the full code to Anders Ivner's seventyfive. ;redcode-94 ;name seventyfive ;kill seventyfive ;author Anders Ivner ;assert (CORESIZE == 8000) ;strategy 75% bomber -> separate multipass coreclear ;strategy Credits to Karl Lewin for crow. STEP EQU 14 ORG bomber STEPB EQU 85 COUNT EQU 500 A equ (jump+STEPB*2) head dat #0, #tail+100 d1 dat <0, head mov.i @tail, >head tail djn.b go, {s1 for 74 dat 0,0 rof bd dat #2*STEPB,#2*STEPB incrb spl #3*STEPB,#3*STEPB dat 0, 0 bomber mov bd, @pt pt cmp A, @A-STEPB sub bd, pt add incrb, pt jump djn.b bomber, #COUNT jmp incr end Porch Swing takes this type of idea and expands it to .8c by adding another bombing line before the cmp instruction and changing the cmp to indirect addressing in the a field. However, Porch Swing does not loop back to the beginning when the scan finds something like seventyfive does. Once the scan finds something, PS moves on to a core clear. It is simple to change this into a bombing loop if desired. ;redcode-94 ;name Porch Swing ;kill Porch Swing ;Author Randy Graham ;assert 1 ;strategy Swing with a little wider range. ;strategy Now 80% bomb/scan with djn-stream once-thru STEP equ 12 EXTRA equ 4 DJNOFF equ (-426-EXTRA) dat.f #gate-10, step-gate+5 gate dat.f #gate-10, sneer-STEP+1 dat2 dat.f #gate-20, step-gate+5 dat1 dat.f #gate-25, step-gate+5 site2 spl.a #gate-30, step-gate+5 site spl.a #gate-40, step-gate+5 for EXTRA dat.f 0, 0 rof adder sub.f sweeper, sneer hithigh mov.i step, *sneer hitlow mov.i step, @sneer sneer sne.i @gate+STEP*6-1-EXTRA, *gate+STEP*3-EXTRA ;so we bomb step looper djn.b adder, gate swinger djn.b mover, {site step dat.f does the same thing. Macro execution --------------- Macros are executed, you guessed it, with the "macro" command. To continue our example above, (cdb) m hello prints the line "hello world". With the PC version of pMARS, you can display the help screen by pressing the "F1" key. With other versions of pMARS you have to execute this macro with "m F1". Of course, macros can call other macros. This way, you can write complicated macro programs that are longer than one line. I am explaining some of them below. They are contained in the default macro file "pmars.mac". Predefined macros ----------------- ctrl-n= m next next= echo Advancing to next round~@pq~@f0,$~dat 0,0~@pq off~@go~@st This macro aborts the current round and advances to the beginning of the next round. This may be much quicker than waiting it out with the "go" command. To kill the current program, "next" uses a command we haven't talked about yet: the process queue or pqueue command. In pqueue mode, "list", "edit" and "fill" operate on the process queue instead of core addresses. What the "@f0,$~dat 0,0" sequence does is to fill each core address about to be executed with dat 0,0. We could have gotten the same effect by wiping out the entire core, but this would've been slower. ------------------------------------------------------------------------- count= &ca z=.~m w?~&ca x=.,c=0~!!~m w?~&ca c=c+1~if .!=x~!~ca c~&l z w?= &search , "Count" is extremely useful if you want to find out things like how many bombs have been dropped, how far paper replication has gone, etc.. The macro reports the number of core addresses the match the search string given in the "w?" macro. As is, "count" searches for a comma, which matches all non-zero addresses. To count something else, say all SPL instructions, simply replace the "w?" macro from within CDB: (cdb) m= w?= &search spl . (cdb) By the way, the "&" operator is similar to "@", but whereas "@" only suppresses screen output, "&" also suppresses output to logfiles. ------------------------------------------------------------------------- pcur - count number of processes pointing to the current address pcur= m _pstep~if.==z~@ca n=n+1~m _pend These two (sub)macros are shared code: _pstep=@ca z=.,c=n=0~!!~@pq~@l c=(c+1)%($+1)~@pq off _pend=if c!=0~!~ca n~@l z pseg - calculates how many processes are operating inside segment [x,y] pseg= m _pstep~m _ptest~m _pend _ptest= if y>=x && x<=. && y>=. || y=.)~@ca n=n+1 "pcur" and "pseg" are related macros that use shared submacros. It is a good idea to use a special naming convention for macros that are not to be called directly from the CDB prompt. In "pmars.mac", submacros start with the underscore character. One scenario where, e.g. "pseg" is useful: You want to find out how many processes are still alive in an imp-spiral at the end of a round, but you also have a self-splitting stone, so "registers" won't work. Simply exclude the range that the stone occupies and run "pseg". Suppose the stone extends from 0 to 4: (cdb) ca x=5,y=7999 5,7999 (cdb) m pseg 19 (cdb) ------------------------------------------------------------------------- Macro check: execute until a core segment [x,y] changes check= if x==y && x==0~m c_err~@ca c=0~!!~m c_step ~m _check~if z==c~!~m _cd Subroutine c_step, advance execution. Change this to "@skip n" for more speed c_step= @step Subroutine _check computes the actual checksum, expects x,y; uses i,j; returns z _check= @ca (i=x)&&(j=(y+1)%($+1)),z=0~!!~@l i~m _c2 _c2= @ca z=z+i+(A+B),i=(i+1)%($+1)~if i != j~!~if !c~@ca c=z A difference was detected _cd=@ca c=z~echo Code segment has changed Usage info if x and y were not set _ce= echo Set x to start, y to end of code to be checksummed (x <= y)~reset "Check" is one the more complex macros in "pmars.mac". It is does the same thing as Planar's commands to detect self-bombing of "Fahrenheit", but is more general. The macro steps and then calculates a checksum over a user-defined core range. If the range has changed, the macro stops with the message "Code segment has changed". A warning: "check" is very slow, and it is not practical to use a range of more than 10 addresses or so. You can speed up execution by rewriting the "c_step" submacro. Replacing the "@step" with "@skip 10" will do the trick, or set a break point inside a loop and use "@go". ------------------------------------------------------------------------- Exercises: 1) The "next" macro only works for battles with one or two warriors. Modify it so it skips to the next round even if more than 2 warriors are loaded. 2) Write a macro that steps until the number of processes of a warrior decreases (Hint: use the pqueue command). ------------------------------------------------------------------------- Answers to the exercises from part 2: Hello, this is Planar again. I got only one answer to my request for answers to the exercises. Are you all sleeping or what ? Since I'm very lazy, I'll mostly quote. (I didn't have the time to test the following, so a good exercise is to find the bugs and fix them.) >From: jgpletin@vub.ac.be (Pletinckx Jurgen) > >Okay. Let's see about this. Your original instructions were: > >(cdb) ca C=1003,X=3039 >(cdb) !!~ca C=C+1,D=0~@ed1~mov.i<100,B==X~!~ca d~@g~@s~!4 > >First off, I rewrote this to a couple of macros. (I _am_ new to cdb, >it's just that I'm lazy enough to dig macro's.) > >tilt=@ca c=999~!!~m prep~m inn~@g~@s~!8 >prep=@ca c=c+1,d=0~@ed1~mov.i <100, inn=!!~@ca d=d+1~@s~@0~if b==3039~!~ca c,d > >where "prep" does the preparation and "inn" is the inner loop. >"tilt" would mean "boinkers", or perhaps "wacko", if you need to know. > >|1. The above loop will take a lot of time. Accelerate it by stepping >| 10 by 10 instead of 1 by 1. > >Pretty easy. I just change "inn" to > >inn=!!~@ca d=d+10~sk9~@0~if b==3039~!~ca c,d ^ maybe you should insert an @ here > >|2. We're only interested in the value that gives the greatest number >| of cycles. Change the command line to display only that value and >| the corresponding number of cycles. > >Let's say I store the maximum number of steps in e, and the correspon- >ding constant in f. I don't need to change "prep", and I can leave off >the last ca in "inn": > >tilt=@ca c=999,e=0~!!~m prep~m inn~if d>e~@ca e=d,f=c~@g~@s~!8~ca f,e >inn=!!~@ca d=d+1~@s~@0~if b==3039~! > >|3. Use "fill" to abort the current battle instead of finishing it with >| "go". How much faster is this ? > >Pass. If I understand correctly, you'd want to fill lines 0-4 with >"dat0,0", so that the warrior crashes on its next step? So that you can >replace the "g" with a single "s"? Yes, or you can use what Stefan taught us today and change the "@g~@s" in "tilt" to a "@m next": tilt=@ca c=999,e=0~!!~m prep~m inn~if d>e~@ca e=d,f=c~@m next~!8~ca f,e >|4. Even faster: instead of doing the inner loop step by step all the >| way, skip to the greatest number of cycles so far, and start >| stepping from there if the SPL is still not bombed. (Is that >| clear ?) > >I can nicely use the counter d for this. Add a skip to "tilt", and initialise >d to maximum-1, instead of to 0. To make it work, I need to initialise >e to 1 instead of to 0. And I keep the modifications from question 2. > >tilt=@ca c=999,e=1~!!~m prep~sk d~m inn~if d>e~@ca e=d,f=c~@g~@s~!8~ca f,e >prep=@ca c=c+1,d=e-1~@ed1~mov.i <100, |5. Figure out a way of putting a sequence of instructions under an >| "if" instead of a single instruction, so that the sequence is >| executed only when the condition is true. > >Pass. Something with !!, if I recall correctly. But what's the point of >a tutorial, if I have to go look things up in a manual :)? OK, then I'll give you the answer: use a loop with a counter of 1. When the next command after an "if" is a loop, CDB will skip the whole loop if the condition is false. If it's true, CDB will loop once, i.e. execute the sequence, so you'd write: if condition ~ !! ~ command 1 ~ command 2 ~ !1 For a real example, you'll have to wait a few weeks, or you can look up "_sd" in pmars.mac. >|6. [hard] The inner loop fails to stop if the self-bombing doesn't >| occur on the SPL. How do you make it work in all cases ? > >I haven't got a clue. You can't just go and check each line, I guess. >And neither can you just store away an untouched version of the warrior >since it wouldn't remain untouched in the core for very long. Hmpf. >Sounds like an important question, though. You could stop at the bombing lines and check what they are going to bomb. You could try to use the macro "check" but the "ADD" line will get in the way. I was hoping that somebody could come up with a better idea. I'll publish one or two solutions next week. >-- > Jurgen Pletinckx Department of Ultrastructure > Vrije Universiteit Brussel Belgium jgpletin@vub.ac.be > ***************** Kwaliteit drijft boven ***************** Congratulations Jurgen, you gave the best answer to every exercise. You win a lifetime subscription to Core Warrior :-) ______________________________________________________________________________ Questions? Concerns? Comments? Complaints? Mail them to people who care: Beppe Bezzi , Myer R Bremer or Maurizio Vittuari