From news-rocq.inria.fr!irisa.fr!univ-rennes1.fr!univ-angers.fr!ciril.fr!cnusc.fr!univ-lyon1.fr!newsfeed.nacamar.de!news.idt.net!ais.net!uunet!in3.uu.net!comp.vuw.ac.nz!paramount.mcs.vuw.ac.nz!amarsden Mon Feb 23 14:48:51 1998 Article: 8422 of rec.games.corewar Path: news-rocq.inria.fr!irisa.fr!univ-rennes1.fr!univ-angers.fr!ciril.fr!cnusc.fr!univ-lyon1.fr!newsfeed.nacamar.de!news.idt.net!ais.net!uunet!in3.uu.net!comp.vuw.ac.nz!paramount.mcs.vuw.ac.nz!amarsden From: Anton Marsden Newsgroups: rec.games.corewar Subject: Anton's CW Tournament Round 1 Warriors Date: Mon, 23 Feb 1998 11:48:49 +1300 Organization: School of Mathematical and Computing Sciences, VUW Lines: 259 Message-ID: NNTP-Posting-Host: kaukau.mcs.vuw.ac.nz Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cache-Post-Path: kaukau.mcs.vuw.ac.nz!unknown@paramount.mcs.vuw.ac.nz X-Cache: nntpcache 2.3.2.1 (see http://www.nntpcache.org/) ;name Particle Sorter ;author Mole IX ;strategy Bubble sorter ;strategy 12 instructions ;assert 1 tmp equ loop_a-1 loop_a mov.b d2, d1 nop.f >loop mov.b loop, l loop slt.b >l, ITEMLIST-1 l jmp d1 mov.f @loop, tmp mov.f l d1 djn loop, #0 start jmz.b finish, #ITEMS d2 djn loop_a, #ITEMS finish dat 0 end start ;redcode-94 ;name Sortidator ;author Christian Schmidt ;assert 1 ;strategy ---------------------------------------------------------- ;strategy 1. search for the lowest key value (hopfully save a lot of cycles) ;strategy 2. sort the itemlist starting with the value ;strategy found in part 1 and store the items behind the ;strategy itemlist. ;strategy 3. overwrite the itemlist by the generated list of items ;strategy ---------------------------------------------------------- SL equ (ITEMLIST+ITEMS+1) ;------------------------------------------------------------------- ;find the lowest keynumber of the itemlist ;and store it as startvalue for the ascending sorting routine (13 instructions) ;------------------------------------------------------------------- low slt.b *sqeptr,@sqeptr ;has the comparing item a lower b-value incr jmp.a chsqe, 1 ;yes, get this item plus add.b incr, sqeptr ;no, Ok the next one seq.b next, stor ;or am I at the end of the list? jmp.a low, >stor ;no, compare the next item add.b *sqeptr, ref ;yes, set the startvalue for the sorting routine stor jmp.a start, 2 ;and start the sorting chsqe sub.ab sqeptr, sqeptr ;uhhh, I do not find a better routine add.ba sqeptr, sqeptr ;for reseting this sub.b sqeptr, sqeptr ;but, it works add.ab sqeptr, sqeptr ;and that's it jmp plus ;and look again sqeptr dat ITEMLIST, ITEMLIST+1 ;here are the pointer for this ;------------------------------------------------------------------- ;this is the sorting routine, which search in ascending ;order through the itemlist (15 instruction) ;------------------------------------------------------------------- start sne.b *ptr, @ptr ;is this a item I need? ref jmp.a sort, 0 ;yes, it is, go to the sorting routine ad nop >ptr, >reset ;no, increment pointer and reset seq.b next, reset ;am I at the end of the itemlist? reset jmp.a start, 0 ;no, let's see what the next item brings anz jmp.a back, 0 ;yes sort mov @ptr, @sziel ;move the item to the sorting list nop >anz, >sziel ;actualize pointer sne.b next, anz ;do I have all items? sziel jmp copy, SL ;yes, then copy them to the itemlist next jmp.a ad, ITEMS ;and again back sub.b reset, ptr ;now I'll go to the start of the itemlist sub.b reset, reset ;reset the pointer and the reset itself jmp.a start, >ref ;start again and increment the key-value ptr dat ref, ITEMLIST ;this is the pointer ;------------------------------------------------------------------- ;copy now the sorted list to the itemlist (3 instructions) ;------------------------------------------------------------------- copy mov.i }cc, >cc ;copy the sorted list djn -1, #ITEMS ;and finish ;YESSSSS!!!!!!!!!! I'm ready cc dat SL, (SL-ITEMS-1) ;my copy pointer ;redcode-94 ;name Sort v1.5 ;author Zul Nadzri ;strategy Round 1 Entry : Anton's Sorting Tournament ;assert 1 org start a slt ITEMLIST-comp,ITEMLIST-comp b slt ITEMLIST-comp,ITEMLIST-comp+1 second mov.b ida,idb sub minus,b mov b,comp mov #0,second-4 start mov *comp,second-3 comp slt ITEMLIST,ITEMLIST+1 ida jmp mark,ITEMS-1 adjust sub #-1,comp return djn comp,idb sne #0,second-4 idb jmp loop,ITEMS-1 mov a,comp mov second-3,@comp loop djn second,ida minus dat #-1,#-1 mark mov @comp,*comp mov comp,a jmp adjust,data1-3,}data1-3 jmp.a return mov.i {data1-3,data1-1-3 mov.i data1-3 return djn.b runer,data1-2 djn.a init,init ende dat.f #256,#256 end ;redcode ;name Consort ;author Robert Hale ;contact rghale@market1.com ;assert 1 ;strategy A simple bubble sort. ;strategy Optimized to be long and slow. ;) ;strategy Ok maybe not so long but it is a N^2 sort. inc add.f #1, comp comp slt.b ITEMLIST, ITEMLIST+1 done jmp loop, #1 swap mov.i *comp, tEnd+1 mov.i @comp, *comp mov.i tEnd+1, @comp mov.ab #0, done loop djn inc, #ITEMS-1 check jmn.b tEnd+1, done ;reset flag, counter and pointers mov.ab #1, done mov.ab #ITEMS-1, loop sub.a #ITEMS-2, comp sub.ab #ITEMS-2, comp tEnd jmp comp end comp ;redcode ;name Seaside sort ;author Brian Haskin ;strategy Walking by the sea one day ;strategy I saw a shell by the way ;strategy Then looking inside there to my suprise ;strategy It was sorting and ordering in ascending ;strategy Ok, so I write terrible poems. ;startegy Hopefully I did a little better on the program. :) ;strategy shell sort ;assert 1 tmp equ (back-10) LAST equ (ITEMLIST+ITEMS-1) SDIST equ ((ITEMS/3)+1) org comp back add.f const, comp mov.i bjmp,ljmp comp slt.b LAST-SDIST, LAST sne.b *comp,@comp ljmp djn.f comp,comp slt.a #-comp+ITEMLIST-1,comp jmp cdist slt.f hgh,comp mov.f comp,hgh mov.i *comp,tmp mov.i @comp,*comp mov.i tmp,@comp retr slt.ab #-comp+LAST-SDIST,comp jmp back snorm mov.i njmp, ljmp mov.f hgh,comp djn.f comp,comp hgh dat #-comp+LAST,#-comp+LAST cdist slt.a #1,const const dat SDIST,SDIST div.f dvc,const mov.f lstc,comp sub.a const,comp mov.a #-comp+LAST,retr sub.a const,retr mov lstc,hgh jmp comp bjmp jmp -ljmp+snorm njmp djn.f -ljmp+comp,-ljmp+comp lstc dat #-comp+LAST,#-comp+LAST dvc dat #2,#2 end ;redcode-94 ;name Bubbly Sort 1b ;author Ilmari Karonen ;strategy Going for the size point with this one.. ;strategy I hope I'm not too late, good reason: ;strategy I've spent the last twelve days a few ;strategy kilometers away from the nearest modem, ;strategy and so couldn't participate earlier, or ;strategy even know that the tournament had begun ;strategy Written and optimized in a few hours for ;strategy size only! ;strategy length: 10 instructions ;strategy speed: ITEMS*(ITEMS-1)/2 comparisons ;strategy 1 comparison = 2 cycles ;strategy 1 swap = 7 cycles (!) ;date Jul 14, 1997 ;planar sort ;assert MAXLENGTH > 10 LAST equ (ITEMLIST+ITEMS-1) temp equ (swap-1) org loop swap mov.i @ptr, temp mov.i *ptr, >ptr mov.i temp, }ptr loop slt.b