<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6722581740507471912</id><updated>2011-11-27T23:15:09.067Z</updated><category term='subroutine'/><category term='return'/><category term='challenge'/><category term='simulator'/><category term='djn'/><category term='qscan'/><category term='abs'/><category term='pseudo-random'/><category term='lagged fibonacci'/><category term='gcd'/><category term='competition'/><category term='privacy'/><category term='forth'/><category term='underload'/><category term='evolver'/><category term='happy numbers'/><category term='warrior'/><category term='fractal'/><category term='parallel processes'/><category term='picture'/><category term='bf'/><category term='gnome sort'/><category term='core war'/><category term='corewar'/><category term='sts'/><category term='macro'/><category term='semaphore'/><category term='thoughts on corewar'/><category term='quick-scan'/><category term='stooge sort'/><category term='quicksort'/><category term='birthday'/><category term='nano'/><category term='logarithmic search'/><category term='tutorial'/><category term='random'/><category term='sorting'/><category term='graphics'/><category term='tiny'/><category term='insertion sort'/><category term='rssb'/><category term='bubble sort'/><category term='algorithm'/><category term='nanowarrior'/><category term='tev'/><category term='brainf***'/><category term='linear search'/><category term='redcode talk'/><category term='maezumo'/><category term='interpreter'/><category term='output'/><category term='hello world'/><category term='sign'/><category term='call'/><category term='redcode'/><category term='binary search'/><category term='newsletter'/><category term='history'/><category term='power'/><category term='search'/><category term='selection sort'/><category term='oisc'/><category term='euclid'/><category term='hill'/><category term='Dobosiewicz sort'/><category term='tinywarrior'/><category term='comb sort'/><category term='lds'/><title type='text'>Thoughts on Corewar...</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>61</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-9204699976311314131</id><published>2011-10-22T18:43:00.001+01:00</published><updated>2011-10-22T18:45:09.422+01:00</updated><title type='text'>Koenigstuhl Top 20: Where Are They Now</title><content type='html'>This afternoon I stumbled across a status report from Koenigstuhl, 03 July 2001. Curious to see how the hill has changed over 10 years I compared the report to the current hill:&lt;br /&gt;&lt;br /&gt;&lt;table style="background: white; border: black solid 1px"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left"&gt;2001 Rank&lt;/th&gt;&lt;th align="left"&gt;Warrior&lt;/th&gt;&lt;th align="left"&gt;Author&lt;/th&gt;&lt;th align="left"&gt;2011 Rank&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Pattel's Virus&lt;/td&gt;&lt;td&gt;Ben Ford&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Recycled Bits&lt;/td&gt;&lt;td&gt;David Moore&lt;/td&gt;&lt;td&gt;12&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;Combatra&lt;/td&gt;&lt;td&gt;David Moore&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;Self-Modifying Code v0.11&lt;/td&gt;&lt;td&gt;Ben Ford&lt;/td&gt;&lt;td&gt;22&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;Self-Modifying Code v0.10&lt;/td&gt;&lt;td&gt;Ben Ford&lt;/td&gt;&lt;td&gt;25&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;Quicksilver&lt;/td&gt;&lt;td&gt;Michal Janeczek&lt;/td&gt;&lt;td&gt;76&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;Uninvited&lt;/td&gt;&lt;td&gt;John Metcalf&lt;/td&gt;&lt;td&gt;88&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;Recycled Bits--&lt;/td&gt;&lt;td&gt;David Moore&lt;/td&gt;&lt;td&gt;93&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;Tuesday Afternoon&lt;/td&gt;&lt;td&gt;John K W&lt;/td&gt;&lt;td&gt;139&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;10&lt;/td&gt;&lt;td&gt;Fire and Ice&lt;/td&gt;&lt;td&gt;David Moore&lt;/td&gt;&lt;td&gt;94&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;11&lt;/td&gt;&lt;td&gt;Recovery&lt;/td&gt;&lt;td&gt;Ian Oversby&lt;/td&gt;&lt;td&gt;97&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;12&lt;/td&gt;&lt;td&gt;Reindeer&lt;/td&gt;&lt;td&gt;Ian Oversby&lt;/td&gt;&lt;td&gt;141&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;13&lt;/td&gt;&lt;td&gt;Three Musketeers&lt;/td&gt;&lt;td&gt;Robert Macrae&lt;/td&gt;&lt;td&gt;157&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;14&lt;/td&gt;&lt;td&gt;The Stormbringer&lt;/td&gt;&lt;td&gt;Christian Schmidt&lt;/td&gt;&lt;td&gt;133&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;15&lt;/td&gt;&lt;td&gt;Am I alive?&lt;/td&gt;&lt;td&gt;Christian Schmidt&lt;/td&gt;&lt;td&gt;166&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;2 Crazy&lt;/td&gt;&lt;td&gt;Christian Schmidt&lt;/td&gt;&lt;td&gt;189&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;17&lt;/td&gt;&lt;td&gt;Digitalis 4&lt;/td&gt;&lt;td&gt;Christian Schmidt&lt;/td&gt;&lt;td&gt;198&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;18&lt;/td&gt;&lt;td&gt;Bigger Brother&lt;/td&gt;&lt;td&gt;Philip Kendall&lt;/td&gt;&lt;td&gt;58&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;19&lt;/td&gt;&lt;td&gt;Liquid Paper&lt;/td&gt;&lt;td&gt;Sean McDonald&lt;/td&gt;&lt;td&gt;109&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;20&lt;/td&gt;&lt;td&gt;Origami Harquebus&lt;/td&gt;&lt;td&gt;mjp&lt;/td&gt;&lt;td&gt;49&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Only three warriors remain in the top 20 while the majority have fallen 50+ places. :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-9204699976311314131?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/9204699976311314131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=9204699976311314131&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/9204699976311314131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/9204699976311314131'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2011/10/koenigstuhl-top-20-where-are-they-now.html' title='Koenigstuhl Top 20: Where Are They Now'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2721064224179111678</id><published>2011-09-27T19:31:00.000+01:00</published><updated>2011-09-27T19:31:42.067+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='warrior'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Whirl: '88 qscan -&gt; oneshot</title><content type='html'>Whirl is a qscan -&amp;gt; oneshot which recently entered the &lt;a href="http://www.koth.org/lcgi-bin/current.pl?hill"&gt;'88 hill&lt;/a&gt;.&lt;pre&gt;;redcode&lt;br /&gt;;name Whirl&lt;br /&gt;;author John Metcalf&lt;br /&gt;;strategy qscan -&amp;gt; oneshot&lt;br /&gt;;assert CORESIZE==8000&lt;br /&gt;&lt;br /&gt;        qfirst equ (qp2+2*qstep)&lt;br /&gt;        qdist  equ qfirst+111&lt;br /&gt;        qstep  equ &lt;br /&gt;&lt;br /&gt;        qi  equ 7                       &lt;br /&gt;        qr  equ 7&lt;br /&gt;&lt;br /&gt;qbomb   dat &amp;lt;qi/2-qi*qr,   &amp;lt;qi*qr-qi/2&lt;br /&gt;&lt;br /&gt;        qa  equ qstep*16&lt;br /&gt;        qb  equ qstep*5+2&lt;br /&gt;        qc  equ qstep*10&lt;br /&gt;        qd  equ qstep*2&lt;br /&gt;        qe  equ qstep*1&lt;br /&gt;&lt;br /&gt;qgo     cmp qdist+qc,      qfirst+qc&lt;br /&gt;        jmp qfast,         &amp;lt;qa&lt;br /&gt;        cmp qdist+qe+qd,   qfirst+qe+qd&lt;br /&gt;qp1     jmp &amp;lt;qfast,        &amp;lt;qc&lt;br /&gt;qp2     cmp qdist,         qfirst&lt;br /&gt;qp3     jmp qskip,         &amp;lt;qe&lt;br /&gt;&lt;br /&gt;        cmp qdist+qb,      qfirst+qb&lt;br /&gt;q1      djn qfast,         #qp1&lt;br /&gt;&lt;br /&gt;        cmp qdist+qd+qc,   qfirst+qd+qc&lt;br /&gt;        jmp qslow,         &amp;lt;qfirst+qd+qc+4&lt;br /&gt;        cmp qdist+qd+qb,   qfirst+qd+qb&lt;br /&gt;x1      jmp qslow,         &amp;lt;q1&lt;br /&gt;        cmp qdist+qc+qc,   qfirst+qc+qc&lt;br /&gt;q2      djn qslow,         #qp2&lt;br /&gt;        cmp qdist+qd,      qfirst+qd&lt;br /&gt;        jmp qslow,         &amp;lt;qfast&lt;br /&gt;        cmp qdist+qa,      qfirst+qa&lt;br /&gt;        jmp q1,            &amp;lt;q1&lt;br /&gt;&lt;br /&gt;        cmp qdist+qa+qd,   qfirst+qa+qd&lt;br /&gt;        jmp x1,            &amp;lt;q1&lt;br /&gt;        cmp qdist+qc+qb,   qfirst+qc+qb&lt;br /&gt;        jmp q2,            &amp;lt;q1&lt;br /&gt;        cmp qdist+qe+qd+qc,qfirst+qe+qd+qc&lt;br /&gt;        jmp qslower,       &amp;lt;qfirst+qe+qd+qc+4&lt;br /&gt;        cmp qdist+qe+qd+qb,qfirst+qe+qd+qb&lt;br /&gt;        jmp qslower,       &amp;lt;q1&lt;br /&gt;        cmp qdist+qe+qc+qc,qfirst+qe+qc+qc&lt;br /&gt;        jmp qslower,       &amp;lt;q2&lt;br /&gt;        cmp qdist+qd+qd+qc,qfirst+qd+qd+qc&lt;br /&gt;q3      djn qslower,       #qp3&lt;br /&gt;        cmp qdist+qe+qc,   qfirst+qe+qc&lt;br /&gt;        jmp &amp;lt;qfast,        &amp;lt;q2&lt;br /&gt;        cmp qdist+qd+qd,   qfirst+qd+qd&lt;br /&gt;        jmp &amp;lt;qfast,        &amp;lt;q3&lt;br /&gt;        cmp qdist+qd+qd+qb,qfirst+qd+qd+qb&lt;br /&gt;        slt &amp;lt;q3,           &amp;lt;q1&lt;br /&gt;&lt;br /&gt;        jmz pgo,           qdist+qe+qd+qc+10&lt;br /&gt;&lt;br /&gt;qslower add @q3,           @qslow&lt;br /&gt;qslow   add @q2,           qkil&lt;br /&gt;qfast   add @q1,           @qslow&lt;br /&gt;&lt;br /&gt;qskip   cmp &amp;lt;qdist+qstep+50, @qkil&lt;br /&gt;        jmp qloop,         &amp;lt;1234&lt;br /&gt;&lt;br /&gt;        add #qdist-qfirst, qkil&lt;br /&gt;qloop   mov qbomb,         @qkil&lt;br /&gt;qkil    mov &amp;lt;qfirst+qstep+50, &amp;lt;qfirst&lt;br /&gt;        sub #qi,           @qloop&lt;br /&gt;        djn qloop,         #qr+2&lt;br /&gt;&lt;br /&gt;pgo     mov last,          boot+10&lt;br /&gt;c       for 10&lt;br /&gt;        mov last-c,        &amp;lt;pgo&lt;br /&gt;        rof&lt;br /&gt;        jmp boot+7&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;step    equ -12&lt;br /&gt;first   equ (201*12-8)&lt;br /&gt;boot    equ (pgo-first-100)&lt;br /&gt;&lt;br /&gt;dbmb    dat &amp;lt;2667,         &amp;lt;-10&lt;br /&gt;&lt;br /&gt;clear   spl 0,             &amp;lt;dbmb-sptr-8&lt;br /&gt;cloop   mov @sloop,        &amp;lt;sptr&lt;br /&gt;        mov @sloop,        &amp;lt;sptr&lt;br /&gt;bomb    djn cloop,         &amp;lt;dbmb-4&lt;br /&gt;&lt;br /&gt;steps   dat &amp;lt;step*3,       &amp;lt;step*3+1&lt;br /&gt;&lt;br /&gt;sloop   add steps,         @cloop&lt;br /&gt;        mov dbmb,          &amp;lt;sptr&lt;br /&gt;sptr    cmp first+step*2,  @first+1&lt;br /&gt;        jmp &amp;lt;sloop&lt;br /&gt;last    jmp sloop&lt;br /&gt;&lt;br /&gt;        end qgo&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2721064224179111678?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2721064224179111678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2721064224179111678&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2721064224179111678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2721064224179111678'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2011/09/whirl-88-qscan-oneshot.html' title='Whirl: &apos;88 qscan -&gt; oneshot'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-4868993402398818026</id><published>2011-08-11T19:09:00.002+01:00</published><updated>2011-08-11T19:16:17.455+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='competition'/><category scheme='http://www.blogger.com/atom/ns#' term='core war'/><title type='text'>The Second ICPC</title><content type='html'>Christian Schmidt recently announced the &lt;a href="http://www.corewar.info/tournament/icpc2"&gt;Second International Corewar Programming Contest&lt;/a&gt; with a concept similar to the new &lt;a href="http://dynahill.bplaced.net/dynahill"&gt;DynaHill&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The hill will be initialised with a pool of 3800 published warriors. Entries will compete against programs in their neighbourhood and move up or down depending on their score.&lt;br /&gt;&lt;br /&gt;An interesting twist is the chance to enter warriors in 8 different categories including '94, '88, &lt;acronym title="limited process"&gt;LP&lt;/acronym&gt; and nano. For full details of the rules see the &lt;a href="http://www.corewar.info/tournament/icpc2"&gt;official tournament page&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The deadline is 15&lt;sup&gt;th&lt;/sup&gt; September. Good luck :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-4868993402398818026?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/4868993402398818026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=4868993402398818026&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4868993402398818026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4868993402398818026'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2011/08/second-icpc.html' title='The Second ICPC'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-3532799950292260842</id><published>2011-07-01T22:51:00.002+01:00</published><updated>2011-07-01T23:02:40.985+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>A Brief Introduction to Core War</title><content type='html'>&lt;h2&gt;What is Corewar?&lt;/h2&gt;&lt;br /&gt;&lt;strong&gt;Corewar&lt;/strong&gt; is a programming game in which the aim is to eliminate all opponents from the memory of a virtual computer. Players write short battle programs to compete against each other.&lt;br /&gt;&lt;br /&gt;Battle programs are written in Redcode, the assembly language of the MARS virtual processor. Redcode has 18 opcodes. Each Redcode instruction is made up of an opcode, a source pointer, a destination pointer, a source addressing mode and a destination addressing mode.  For example, the mov instruction copies information from the source to the destination:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;mov 10, 20&lt;/pre&gt;&lt;br /&gt;In the example, the source is 10 and the destination is 20. When the instruction is executed, it take the information in the cell 10 locations after the mov and copies it to the cell 20 locations after.&lt;br /&gt;&lt;br /&gt;Here's another example, known as an imp:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;mov 0, 1&lt;/pre&gt;&lt;br /&gt;When this executes, it copies the information from 0 locations ahead (i.e. itself) to 1 location ahead:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;mov 0, 1&lt;br /&gt;mov 0, 1 &amp;lt;--- the copy&lt;/pre&gt;&lt;br /&gt;Execution continues with the next instruction, so the program executes the copy it just made. Addresses in Corewar are relative to the cell they're stored in, so when the copy executes it makes a new copy one location ahead:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;mov 0, 1&lt;br /&gt;mov 0, 1 &amp;lt;--- the copy&lt;br /&gt;mov 0, 1 &amp;lt;--- the second copy&lt;/pre&gt;&lt;br /&gt;The addressing mode affects how the address is interpreted. If no addressing mode is specified, direct addressing is used as in the examples above. The alternatives are immediate and indirect addressing.&lt;br /&gt;&lt;br /&gt;Immediate addressing is indicated by an octothorpe (#). Instead of using data a number of cells away, it uses the data stored in the current instruction. For example:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;add #10, 20&lt;/pre&gt;&lt;br /&gt;The # shows the data to be used is 10, not the value from the cell 10 locations away. add #10, 20 adds 10 to the value in the cell 20 locations ahead.&lt;br /&gt;&lt;br /&gt;Indirect addressing is indicated by one of the following symbols, &amp;lt; @ &amp;gt; { * }. Instead of using data from a number of cells away, that data is used as a pointer to the actual data to be used. For example:&lt;br /&gt;&lt;pre&gt;add #10, @1&lt;br /&gt;dat 0,   19&lt;/pre&gt;&lt;br /&gt;When the add instruction executes, it adds 10 to the cell 20 locations ahead. @1 tells the Redcode processor to use the destination of the cell 1 location away as a pointer. This contains 19, so the destination is 19 locations after the dat, or 20 after the add.&lt;br /&gt;&lt;br /&gt;Here's a quick run down of addressing modes. A-field is another name for the source pointer and b-field is for the destination pointer:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&amp;lt; use the b-field as a pointer after subtracting 1 from it&lt;/li&gt;&lt;li&gt;@ use the b-field as a pointer&lt;/li&gt;&lt;li&gt;&amp;gt; use the b-field as a pointer and afterwards add 1 to it&lt;/li&gt;&lt;li&gt;{ use the a-field as a pointer after subtracting 1 from it&lt;/li&gt;&lt;li&gt;* use the a-field as a pointer&lt;/li&gt;&lt;li&gt;} use the a-field as a pointer and afterwards add 1 to it&lt;/li&gt;&lt;li&gt;# use the data in the currently executing instruction&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Here are the 18 opcodes supported by the Redcode processor:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;mov - copy data from source to destination&lt;/li&gt;&lt;li&gt;add - add value from source to destination&lt;/li&gt;&lt;li&gt;sub - subtract value at source from destination&lt;/li&gt;&lt;li&gt;div - divide destination by source&lt;/li&gt;&lt;li&gt;mod - destination = destination MODULO source&lt;/li&gt;&lt;li&gt;mul - multiply destination by source&lt;/li&gt;&lt;li&gt;seq - skip next instruction if source equal to destination&lt;/li&gt;&lt;li&gt;sne - skip next instruction if source not equal to destination&lt;/li&gt;&lt;li&gt;slt - skip next instruction if source less than destination&lt;/li&gt;&lt;li&gt;jmp - jump to a-field&lt;/li&gt;&lt;li&gt;jmn - jump to a-field if b-field non-zero&lt;/li&gt;&lt;li&gt;jmz - jump to a-field if b-field zero&lt;/li&gt;&lt;li&gt;djn - subtract 1 from b-field. if result non-zero, jump to a-field&lt;/li&gt;&lt;li&gt;spl - start a new thread at a-field&lt;/li&gt;&lt;li&gt;dat - destroy thread when executed&lt;/li&gt;&lt;li&gt;stp - store source to private memory&lt;/li&gt;&lt;li&gt;ldp - load private memory to destination&lt;/li&gt;&lt;li&gt;nop - no operation&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Top Corewar Links&lt;/h2&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://vyznev.net/corewar/guide.html"&gt;Beginners' Guide to Redcode&lt;/a&gt;&lt;br /&gt;Ilmari's guide to Redcode provides a gentle introduction to the art of Corewar.&lt;/li&gt;&lt;li&gt;&lt;a href="http://corewar.co.uk/biblio.htm"&gt;Corewar Bibliography&lt;/a&gt;&lt;br /&gt;The Corewar Bibliography is a comprehensive index of Corewar articles and the ideal starting point to research any Corewar topic.&lt;/li&gt;&lt;li&gt;&lt;a href="http://koth.org/"&gt;Corewars - King of the Hill&lt;/a&gt;&lt;br /&gt;KOTH.org is the provider of several online hills. Submit your program by email to compete against others.&lt;/li&gt;&lt;li&gt;&lt;a href="http://sal.math.ualberta.ca/"&gt;KOTH@SAL Corewar Hills&lt;/a&gt;&lt;br /&gt;The hills at SAL present some alternative settings, including the beginner hill and the popular nano hill.&lt;/li&gt;&lt;li&gt;&lt;a href="http://users.obs.carnegiescience.edu/birk/COREWAR/koenigstuhl.html"&gt;CoreWar "Koenigstuhl" Page&lt;/a&gt;&lt;br /&gt;Koenigstuhl is the Valhalla of Corewar! When an author publishes their battle programs, they're archived on the Koenigstuhl infinite hills.&lt;/li&gt;&lt;li&gt;&lt;a href="http://corewar.co.uk/"&gt;Programming in Corewar&lt;/a&gt;&lt;br /&gt;In Corewar a battle is played out between computer programs, which attempt to eliminate all opponents within the memory of the MARS virtual computer.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.corewar.info/"&gt;Fizmo's Corewar Info&lt;/a&gt;&lt;br /&gt;The ultimate source for any information regarding Corewar, a programming game where small programs fight each other.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-3532799950292260842?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/3532799950292260842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=3532799950292260842&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3532799950292260842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3532799950292260842'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2011/07/brief-introduction-to-core-war.html' title='A Brief Introduction to Core War'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-7458230779373746279</id><published>2011-02-10T20:44:00.006Z</published><updated>2011-02-10T20:50:04.347Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='history'/><title type='text'>An Early Description of Core War</title><content type='html'>Until I saw this description of Core War I assumed Dewdney and Jones were the first to use the term in the &lt;a href="http://corewar.co.uk/cwg.txt"&gt;Core War Guidelines&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 30px; margin-right: 30px; border: 1px solid silver"&gt;&lt;blockquote&gt;“&lt;em&gt;Core war&lt;/em&gt; is a game surreptitiously played by systems programmers on large installations, where a player's goal in each fixed time slice of real time is to propagate his program elsewhere in memory, while doing as much “damage” (read: clearing to zero) as possible at random places in the hopes of causing the opponent's program to blow up. The game of &lt;em&gt;core war&lt;/em&gt; is rarely mentioned with more than a whisper, and thus tends to be lost amid the din of easier and less abstract games such as &lt;em&gt;Star Trek&lt;/em&gt;, &lt;em&gt;Adventure&lt;/em&gt; or &lt;em&gt;Dungeons and Dragons&lt;/em&gt;”&lt;/blockquote&gt;&lt;div style="margin-right: 50px; text-align: right;"&gt;-- BYTE Magazine, July 1978, page 106-107&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This brief description was published 6 years before A. K. Dewdney's first Core War article in Scientific American (May 1984, page 14-22).&lt;br /&gt;&lt;br /&gt;Have you seen any other early mentions of Core War?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-7458230779373746279?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/7458230779373746279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=7458230779373746279&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7458230779373746279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7458230779373746279'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2011/02/early-description-of-core-war.html' title='An Early Description of Core War'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2160916587167552970</id><published>2011-01-17T14:11:00.002Z</published><updated>2011-01-17T14:42:54.125Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='fractal'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='picture'/><title type='text'>Revisiting the Dragon Curve</title><content type='html'>A few days ago I published code to draw the &lt;a href="http://impomatic.blogspot.com/2011/01/dragon-curve-in-redcode.html"&gt;Heighway Dragon Curve&lt;/a&gt;. Here's a variation that's 3 lines shorter and plots the curve in 655360 cycles. The pMARS command line is &lt;code&gt;pmarsv -s 90000 -c 1000000&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;;redcode-fractal&lt;br /&gt;;name Dragon Curve 2&lt;br /&gt;;author John Metcalf&lt;br /&gt;&lt;br /&gt;        width  equ 315&lt;br /&gt;        stack  equ dragon+100&lt;br /&gt;        plot   equ direct+width+1&lt;br /&gt;        first  equ 80*width+50&lt;br /&gt;&lt;br /&gt;        mov    #first,   plot&lt;br /&gt;dragon  mov.ab count,    &amp;lt;plot&lt;br /&gt;test    mov.b  @plot,    #0&lt;br /&gt;        add.ba @plot,    direct&lt;br /&gt;        div    #2,       @plot&lt;br /&gt;        mod    #2,       test&lt;br /&gt;        jmz    test,     test&lt;br /&gt;        mod.a  #4,       direct&lt;br /&gt;direct  add.b  3,        width+1&lt;br /&gt;count   sub.ba #65536,   #1+1&lt;br /&gt;        jmp    dragon,   -width+1&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2160916587167552970?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2160916587167552970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2160916587167552970&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2160916587167552970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2160916587167552970'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2011/01/revisiting-dragon-curve.html' title='Revisiting the Dragon Curve'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-4029706449475346813</id><published>2011-01-09T19:59:00.000Z</published><updated>2011-01-09T19:59:23.728Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='fractal'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='picture'/><title type='text'>Dragon Curve in Redcode</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_kDyMtZ_dJwQ/TSm2kk5E6bI/AAAAAAAABw8/pT3YUTnCFAU/s1600/dragon_curve3.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="400" width="400" src="http://2.bp.blogspot.com/_kDyMtZ_dJwQ/TSm2kk5E6bI/AAAAAAAABw8/pT3YUTnCFAU/s400/dragon_curve3.png" alt="dragon curve in redcode" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The Heighway Dragon Curve is fractal line than goes through a series of 90&amp;deg; turns, creating a pattern which fills a 2 dimensional space. The program plots 32768 points in 458741 cycles. The pMARS command line is &lt;code&gt;pmarsv -s 90000 -c 500000&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;;redcode-fractal&lt;br /&gt;;name Dragon Curve&lt;br /&gt;;author John Metcalf&lt;br /&gt;&lt;br /&gt;        width  equ 315&lt;br /&gt;        stack  equ dragon+100&lt;br /&gt;&lt;br /&gt;dragon  mov.x  paira,    &amp;lt;stack&lt;br /&gt;recur   djn    dragon,   #15&lt;br /&gt;        mod.a  #4,       direct&lt;br /&gt;        add.b  *direct,  plot&lt;br /&gt;plot    mov    &amp;gt;recur,   80*width+110&lt;br /&gt;        mov.ba &amp;gt;stack,   ret&lt;br /&gt;ret     jmp    0,        }stack&lt;br /&gt;turn    add.a  @stack,   direct&lt;br /&gt;        mov.x  pairb,    &amp;lt;stack&lt;br /&gt;        jmp    recur&lt;br /&gt;&lt;br /&gt;direct  dat    3,        width&lt;br /&gt;paira   dat    turn-ret, -1&lt;br /&gt;        dat    0,        -width&lt;br /&gt;pairb   dat    plot-ret, 1&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-4029706449475346813?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/4029706449475346813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=4029706449475346813&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4029706449475346813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4029706449475346813'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2011/01/dragon-curve-in-redcode.html' title='Dragon Curve in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/TSm2kk5E6bI/AAAAAAAABw8/pT3YUTnCFAU/s72-c/dragon_curve3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-3989580104309507339</id><published>2010-12-09T22:12:00.003Z</published><updated>2010-12-09T22:15:16.411Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='competition'/><title type='text'>Corewar Programming Contest</title><content type='html'>The &lt;a href="http://www.corewar.info/tournament/icpc1"&gt;First International Corewar Programming Contest&lt;/a&gt; has just been announced, with a first prize of $50 sponsored by &lt;a href="http://www.corewar.info/"&gt;www.corewar.info&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The competition takes place in the unexplored area between '94nop and &lt;acronym title="limited process"&gt;LP&lt;/acronym&gt; settings which has recently been investigated by Fizmo in &lt;a href="http://corewar.co.uk/redtalk"&gt;Redcode Talk&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The exact settings are as follows:&lt;br /&gt;&lt;br /&gt;&lt;table style="border: 1px solid black; padding: 10px"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Standard:&lt;/td&gt;&lt;td&gt;&lt;acronym title="Core War Standard 1994"&gt;CWS'94&lt;/acronym&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Coresize:&lt;/td&gt;&lt;td&gt;8000&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Processes:&lt;/td&gt;&lt;td&gt;200&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Entry length:&lt;/td&gt;&lt;td&gt;20&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Points win:&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Points tie:&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Cycles:&lt;/td&gt;&lt;td&gt;80000&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Rounds:&lt;/td&gt;&lt;td&gt;1000&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;The pMARS command line is &lt;code&gt;pmars -p 200 -l 20 -r 1000&lt;/code&gt;. &lt;code&gt;STP&lt;/code&gt; and &lt;code&gt;LDP&lt;/code&gt; are forbidden, up to two entries are allowed and battles will take part in a round-robin tournament.&lt;br /&gt;&lt;br /&gt;For more information, take a look at the &lt;a href="http://groups.google.com/group/rec.games.corewar/browse_thread/thread/4be19d3fdfaf50ee#"&gt;announcement in rec.games.corewar&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-3989580104309507339?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/3989580104309507339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=3989580104309507339&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3989580104309507339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3989580104309507339'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2010/12/first-international-corewar-programming.html' title='Corewar Programming Contest'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-7570654864177874292</id><published>2010-11-05T23:07:00.006Z</published><updated>2010-11-05T23:12:39.644Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='fractal'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='picture'/><title type='text'>Four Lines of Redcode</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_kDyMtZ_dJwQ/TNSItO1Zq_I/AAAAAAAABvM/w3RoDU5wUvA/s1600/sierpinski.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="400" width="400" src="http://4.bp.blogspot.com/_kDyMtZ_dJwQ/TNSItO1Zq_I/AAAAAAAABvM/w3RoDU5wUvA/s400/sierpinski.png" alt="Sierpinski triangle"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The Sierpinski triangle or gasket is a fractal named after the Polish mathematician Waclaw Sierpinski. Surprisingly the fractal can be generated with just 4 lines of Redcode:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        width  equ 126&lt;br /&gt;        trail  equ (sum-CORESIZE%width)&lt;br /&gt;        start  equ (trail-width+1)&lt;br /&gt;&lt;br /&gt;sum     mov    #3,    @3&lt;br /&gt;ptr     mov.b  trail, sum&lt;br /&gt;        add.b  {ptr,  sum&lt;br /&gt;        djn    sum,   #start&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The magic incantation for pMARS is &lt;code&gt;pmars -v 132&lt;/code&gt;. Alternatively set the width to 128 to view using CoreWin :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-7570654864177874292?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/7570654864177874292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=7570654864177874292&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7570654864177874292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7570654864177874292'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2010/11/four-lines-of-redcode.html' title='Four Lines of Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_kDyMtZ_dJwQ/TNSItO1Zq_I/AAAAAAAABvM/w3RoDU5wUvA/s72-c/sierpinski.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-709542758071042259</id><published>2010-09-05T07:58:00.004+01:00</published><updated>2010-09-05T08:01:06.850+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='newsletter'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode talk'/><title type='text'>Redcode Talk Issue 1</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.corewar.info/corewarrior/redcodetalk/RedcodeTalk001.txt" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img alt="Redcode Talk" border="0" height="133" src="http://2.bp.blogspot.com/_kDyMtZ_dJwQ/TIM-OfAnpwI/AAAAAAAABr8/UI3un5IMKho/s200/redcode_talk.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;Christian Schmidt recently published the first issue of &lt;a href="http://www.corewar.info/corewarrior/redcodetalk/RedcodeTalk001.txt"&gt;Redcode Talk&lt;/a&gt;. The issue contains a couple of articles by Fizmo:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The undiscovered area between &lt;acronym title="limited process"&gt;LP&lt;/acronym&gt; &amp;amp; 94draft&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Random Warrior Talk: One Man Army v1.0&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-709542758071042259?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/709542758071042259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=709542758071042259&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/709542758071042259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/709542758071042259'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2010/09/christian-schmidt-recently-published.html' title='Redcode Talk Issue 1'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/TIM-OfAnpwI/AAAAAAAABr8/UI3un5IMKho/s72-c/redcode_talk.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2270366123698765397</id><published>2010-07-23T23:54:00.025+01:00</published><updated>2010-07-24T15:13:08.415+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='happy numbers'/><title type='text'>Happy Numbers</title><content type='html'>Today's &lt;a href="http://programmingpraxis.com/2010/07/23/happy-numbers"&gt;Programming Praxis&lt;/a&gt; challenges us to write a program to list the happy numbers up to a given limit. A number is happy if the sum of the square of it's digital eventually reaches 1. E.g. 7 is happy because 7&lt;sup&gt;2&lt;/sup&gt;=49, 4&lt;sup&gt;2&lt;/sup&gt;+9&lt;sup&gt;2&lt;/sup&gt;=97, 9&lt;sup&gt;2&lt;/sup&gt;+7&lt;sup&gt;2&lt;/sup&gt;=130, 1&lt;sup&gt;2&lt;/sup&gt;+3&lt;sup&gt;2&lt;/sup&gt;+0&lt;sup&gt;2&lt;/sup&gt;=10, 1&lt;sup&gt;2&lt;/sup&gt;+0&lt;sup&gt;2&lt;/sup&gt;=1.&lt;br /&gt;&lt;br /&gt;Here's my solution in Redcode:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;org    newcand&lt;br /&gt;&lt;br /&gt;        base   equ 10&lt;br /&gt;        limit  equ 100&lt;br /&gt;        tries  equ 50&lt;br /&gt;&lt;br /&gt;stack   dat    0&lt;br /&gt;happy   dat    1&lt;br /&gt;cand    dat    0&lt;br /&gt;total   dat    0&lt;br /&gt;repeat  dat    0&lt;br /&gt; &lt;br /&gt;newcand mov.ba happy,     cand&lt;br /&gt;        mov    #tries,    repeat&lt;br /&gt;again   mov    #-1,       total&lt;br /&gt;digits  mov.ab cand,      cand&lt;br /&gt;        mod    #base,     cand&lt;br /&gt;        div.a  #base,     cand&lt;br /&gt;        mul.b  cand,      cand&lt;br /&gt;        add.b  cand,      total&lt;br /&gt;        jmn.a  digits,    cand&lt;br /&gt;        jmz    found,     total&lt;br /&gt;        mov.ba total,     cand&lt;br /&gt;        add.a  #1,        cand&lt;br /&gt;        djn    again,     repeat&lt;br /&gt;nexthap seq    #limit,    happy&lt;br /&gt;        jmp    newcand,   &amp;gt;happy&lt;br /&gt;        dat    0&lt;br /&gt;&lt;br /&gt;found   mov.b  happy,     &amp;lt;stack&lt;br /&gt;writen  mov.b  @stack,    &amp;lt;stack&lt;br /&gt;        div    #10,       &amp;gt;stack&lt;br /&gt;        mod    #10,       @stack&lt;br /&gt;        add    #48,       @stack&lt;br /&gt;        jmn    writen,    &amp;lt;stack&lt;br /&gt;        add    #1,        stack&lt;br /&gt;wloop   sts    &amp;gt;stack,    0&lt;br /&gt;        jmn    wloop,     stack&lt;br /&gt;        sts.a  #10,       0&lt;br /&gt;        jmp    nexthap&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2270366123698765397?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2270366123698765397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2270366123698765397&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2270366123698765397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2270366123698765397'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2010/07/happy-numbers.html' title='Happy Numbers'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-6519396977825737991</id><published>2010-01-24T19:11:00.003Z</published><updated>2010-01-24T19:21:22.066Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='simulator'/><category scheme='http://www.blogger.com/atom/ns#' term='graphics'/><title type='text'>Cross Simulator Core Graphics</title><content type='html'>One difficulty when trying to write code to plot graphics in Redcode is the width of the core display. The four most popular simulators uses a variety of different widths:&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Simulator&lt;br /&gt;&lt;/th&gt;&lt;th&gt;Display Width&lt;br /&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;pMARS SDL mode 0&lt;br /&gt;&lt;/td&gt;&lt;td&gt;157&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;pMARS SDL mode 2&lt;br /&gt;&lt;/td&gt;&lt;td&gt;126&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;CoreWin&lt;br /&gt;&lt;/td&gt;&lt;td&gt;128&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ARES&lt;br /&gt;&lt;/td&gt;&lt;td&gt;80&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;nMars&lt;br /&gt;&lt;/td&gt;&lt;td&gt;various&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;The simplest solution is to define a variable for the width which can be modified by the person running the program. Alternatively it's possible to use the the predefined &lt;code&gt;VERSION&lt;/code&gt; constant to determine the simulator:&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Simulator&lt;br /&gt;&lt;/th&gt;&lt;th&gt;Version&lt;br /&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;pMARS SDL mode 0&lt;br /&gt;&lt;/td&gt;&lt;td&gt;92&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;pMARS SDL mode 2&lt;br /&gt;&lt;/td&gt;&lt;td&gt;92&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;CoreWin&lt;br /&gt;&lt;/td&gt;&lt;td&gt;230&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ARES&lt;br /&gt;&lt;/td&gt;&lt;td&gt;0&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;nMars&lt;br /&gt;&lt;/td&gt;&lt;td&gt;93&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Putting the two together we can write the following code which sets the correct width for pMARS SDL, CoreWin and ARES:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;width equ ( (VERSION==92)*157 + (VERSION==230)*128 + (VERSION==0)*80 )&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-6519396977825737991?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/6519396977825737991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=6519396977825737991&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/6519396977825737991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/6519396977825737991'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2010/01/cross-simulator-core-graphics.html' title='Cross Simulator Core Graphics'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1605324069841426089</id><published>2010-01-07T20:49:00.004Z</published><updated>2010-07-24T15:58:17.975+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fractal'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='picture'/><title type='text'>Fractals in Corewar</title><content type='html'>&lt;span style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img alt="Koch Curve in Redcode" border="0" src="http://2.bp.blogspot.com/_kDyMtZ_dJwQ/S0ZDsyRCj5I/AAAAAAAABR0/gwuviwor_do/s320/koch_curve.png" /&gt;&lt;/span&gt;In 1997 Anton Marsden organised a Corewar tournament with a difference. &amp;nbsp;The three rounds challenged players to use Redcode to solve a variety of problems.&lt;br /&gt;&lt;br /&gt;In the third round of &lt;a href="http://corewar.co.uk/marsden/index.htm"&gt;Anton's Corewar Tournament&lt;/a&gt; the challenge was to write a Redcode program to draw a pretty picture. &amp;nbsp;First place was taken by Ilmari Karonen with a fractal fern.&lt;br /&gt;&lt;br /&gt;Here's my own attempt at creating a pretty picture in the core view of &lt;a href="http://corewar.co.uk/pmars/"&gt;pMARS&lt;/a&gt;. It's a fractal known as the Koch Curve.&lt;br /&gt;&lt;br /&gt;Here's the program, just 18 instructions:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;width equ 157&lt;br /&gt;&lt;br /&gt;        org    koch&lt;br /&gt;&lt;br /&gt;        stack equ count+30&lt;br /&gt;&lt;br /&gt;koch:   mov    #2-ptr, &amp;gt;stack&lt;br /&gt;        jmp    count,  }move&lt;br /&gt;&lt;br /&gt;        sub.a  #2,     move&lt;br /&gt;        mov    #2-ptr, &amp;gt;stack&lt;br /&gt;        jmp    count&lt;br /&gt;&lt;br /&gt;        jmp    return, }move&lt;br /&gt;&lt;br /&gt;count:  djn    koch,   #11&lt;br /&gt;        mod.a  #8,     move&lt;br /&gt;        div.a  #2,     move&lt;br /&gt;        add.b  *move,  pos&lt;br /&gt;        mul.a  #2,     move&lt;br /&gt;pos:    add    #1,     koch+71*width/2+16&lt;br /&gt;return: mov.ba &amp;lt;stack, ptr&lt;br /&gt;ptr:    jmp    0,      &amp;gt;count&lt;br /&gt;&lt;br /&gt;move:   dat    -1&lt;br /&gt;        dat    -width&lt;br /&gt;        dat    1&lt;br /&gt;        dat    width&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Have you tried to write a graphical display in Corewar?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1605324069841426089?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1605324069841426089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1605324069841426089&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1605324069841426089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1605324069841426089'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2010/01/fractals-in-corewar.html' title='Fractals in Corewar'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/S0ZDsyRCj5I/AAAAAAAABR0/gwuviwor_do/s72-c/koch_curve.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2889582473828467239</id><published>2009-10-27T08:01:00.003Z</published><updated>2009-10-27T11:05:55.271Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='tiny'/><category scheme='http://www.blogger.com/atom/ns#' term='tinywarrior'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><title type='text'>Tinywarrior Issue 4</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://corewar.co.uk/tw/tw04.txt"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 256px; height: 192px;" src="http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SuapCLe9RrI/AAAAAAAABN0/-Kf8nAZY7g4/s400/tinywarrior04.jpg" border="0" alt="Tinywarrior issue 4, corewar" id="BLOGGER_PHOTO_ID_5397187058357585586" /&gt;&lt;/a&gt;The fourth issue of &lt;a href="http://corewar.co.uk/tw"&gt;Tinywarrior&lt;/a&gt; has just been published, the newsletter which reports the latest events and techniques for the &lt;a href="http://sal.math.ualberta.ca/hill.php?key=tiny"&gt;tiny hill&lt;/a&gt;. Here's what you can expect to find in this issue:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;em&gt;Flux and the SPL/DIV Clear&lt;/em&gt; by John Metcalf examines a SPL/DIV clear inspired by G2.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Larger Than Infinity&lt;/em&gt; by Zul Nadzri reveals the results of Zul's experiments with White Noise.&lt;br /&gt;&lt;br /&gt;Any feedback would be greatly appreciated.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2889582473828467239?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2889582473828467239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2889582473828467239&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2889582473828467239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2889582473828467239'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/10/tinywarrior-issue-4.html' title='Tinywarrior Issue 4'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SuapCLe9RrI/AAAAAAAABN0/-Kf8nAZY7g4/s72-c/tinywarrior04.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-7491105395064613570</id><published>2009-08-25T13:26:00.004+01:00</published><updated>2009-08-25T14:21:49.874+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='evolver'/><category scheme='http://www.blogger.com/atom/ns#' term='maezumo'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><title type='text'>Maezumo, Evolving for the Corewar Tiny Hill with a Twist</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.corewar.info/maezumo/"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 300px; height: 220px;" src="http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SpPaOx5BfGI/AAAAAAAABDk/ziwcgFHGWAM/s400/maezumo.JPG" border="0" alt="Maezumo, the Evolver with a Twist" id="BLOGGER_PHOTO_ID_5373878727828667490" /&gt;&lt;/a&gt;At the beginning of August, Christian Schmidt released version 1.04 of &lt;a href="http://www.corewar.info/maezumo/"&gt;Maezumo&lt;/a&gt;, his corewar evolver. If you're familiar with the old version the biggest difference you'll notice are the additions to the progress report.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Maezumo evolves warriors using traditional mutation, keeping a hill of the top warriors. Hill warriors are then injected back into the soup. Where Maezumo offers something innovative is in the hint modes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If the hint modes are enabled, Maezumo generates warriors from inbuilt templates. These challenge the hill and if successful enter the soup for further enhancement by the mutation algorithm.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Maezumo is supplied with a Windows binary, Basic source code and all the necessary support files. To evolve for the tiny hill, I simply extracted the archived, changed the settings in maezumo.ini and double clicked maezumo.exe. I selected the scanner/paper hint mode to cover the two most successful tiny strategies.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After a 13 hour run, the top warrior on Maezumo's hill is an evolved style paper which scores 75 against &lt;a href="http://sal.math.ualberta.ca/hill.php?key=tiny"&gt;SAL's tiny hill&lt;/a&gt;. I think it would be realistic to expect a strong tiny warrior after a 3 or 4 day run.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Have you tried Maezumo yet? If so, let me know your thoughts :-)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-7491105395064613570?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/7491105395064613570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=7491105395064613570&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7491105395064613570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7491105395064613570'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/08/maezumo-evolving-for-corewar-tiny-hill.html' title='Maezumo, Evolving for the Corewar Tiny Hill with a Twist'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SpPaOx5BfGI/AAAAAAAABDk/ziwcgFHGWAM/s72-c/maezumo.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-4960999220058187697</id><published>2009-07-09T06:54:00.005+01:00</published><updated>2009-07-09T08:25:51.661+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='evolver'/><category scheme='http://www.blogger.com/atom/ns#' term='tev'/><category scheme='http://www.blogger.com/atom/ns#' term='nano'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>TEV Hints and Another Evolved Bomber</title><content type='html'>Recently I've been experimenting with different hints in &lt;a href="http://impomatic.blogspot.com/2009/06/corewar-tiny-evolver-tev-v0.html"&gt;TEV0&lt;/a&gt; and &lt;a href="http://impomatic.blogspot.com/2009/06/12k-tiny-corewar-evolver.html"&gt;TEV12&lt;/a&gt; hoping to guide the evolution of Redcode programs. TEV is a small program written in Basic and uses the principles of random mutation and survival of the fittest to create a Redcode program over a number of generations.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Redcode is the language of Corewar, a game in which two or more programs battle to control the memory of a virtual computer. Here's a quick introduction to &lt;a href="http://retrocode.blogspot.com/2008/11/core-war-hostile-programming.html"&gt;Corewar&lt;/a&gt;. Traditionally programs are coded by hand, but a number of players have risen to the challenge of writing a program to evolve good contenders.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The purpose of a hint is to control the direction of evolution by issuing a score penalty for certain types of code. Here are the hints I've been experimenting with:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a penalty for three consecutive opcodes the same&lt;/li&gt;&lt;li&gt;a penalty for the first opcode being a SPL&lt;/li&gt;&lt;li&gt;a penalty for the a-mode of a SPL being #&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This produced some really weird programs to begin with, but after relaxing the penalties stronger programs emerged. Unfortunately TEV still hasn't produced a decent replicator so instead here's the code for the most successful bomber of the latest run, medusa's mirror:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;pre&gt;;redcode-nano&lt;br /&gt;;name medusa's mirror&lt;br /&gt;;author John Metcalf&lt;br /&gt;;strategy evolved using TEV12 with hints&lt;br /&gt;;assert CORESIZE==80&lt;br /&gt;&lt;br /&gt;mov.i &amp;lt;46, $11&lt;br /&gt;spl.i #-4, {56&lt;br /&gt;mov.i &amp;lt;36, {79&lt;br /&gt;mov.i {79, {54&lt;br /&gt;djn.f $78, {59&lt;br /&gt;end&lt;/pre&gt;&lt;br /&gt;Next I'm hoping to divide the pool into different regions and implement a different hint in each region. If you have any suggestions for hints, please let me know.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-4960999220058187697?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/4960999220058187697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=4960999220058187697&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4960999220058187697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4960999220058187697'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/07/tev-hints-and-another-evolved-bomber.html' title='TEV Hints and Another Evolved Bomber'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2751923385079797216</id><published>2009-06-25T23:14:00.003+01:00</published><updated>2009-06-25T23:24:10.464+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='evolver'/><category scheme='http://www.blogger.com/atom/ns#' term='core war'/><category scheme='http://www.blogger.com/atom/ns#' term='tev'/><category scheme='http://www.blogger.com/atom/ns#' term='nano'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><title type='text'>1.2K Tiny Corewar Evolver</title><content type='html'>Here's the latest version of the Tiny Corewar Evolver, a small (&amp;lt;1.2K) GWBasic program to evolve Redcode warriors against a benchmark. This version producted &lt;a href="http://impomatic.blogspot.com/2009/06/results-from-even-simpler-corewar.html"&gt;Wrath of the Machines&lt;/a&gt; after a 28 hour run.&lt;br /&gt;&lt;br /&gt;The two biggest differences from &lt;a href="http://impomatic.blogspot.com/2009/06/corewar-tiny-evolver-tev-v0.html"&gt;TEV0&lt;/a&gt; are as follows:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;no longer aborts a bad benchmark early&lt;/li&gt;&lt;li&gt;replaces the lowest scoring warrior with the current warrior&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;TEV12.BAT&lt;br /&gt;&lt;pre&gt;@dir /b /o-d *.red &amp;gt;w.evo&lt;br /&gt;@echo END &amp;gt;&amp;gt;w.evo&lt;br /&gt;@gwbasic tev12&lt;br /&gt;@erase ?.evo&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;TEV12.BAS&lt;br /&gt;&lt;pre&gt;10 P$="pmars -s 80 -p 80 -c 800 -l 5 -b -k -P":R=142:L=5:P=25:K=80&lt;br /&gt;20 O$="mov.imov.ispl.bdjn.f;xxxx":M$="&amp;lt;@&amp;gt;{*}$#"&lt;br /&gt;30 DIM W$(99),A$(L,P),B$(L,P),C(L,P),D$(L,P),E(L,P),S(P):RANDOMIZE TIMER&lt;br /&gt;40 W=0:OPEN "w.evo" FOR INPUT AS #1:M=LEN(M$):q=0:h=1&lt;br /&gt;50 INPUT #1,W$(W+1):IF W$(W+1)&amp;lt;&amp;gt;"END" THEN W=W+1:GOTO 50 ELSE CLOSE #1&lt;br /&gt;60 q=(q mod p)+1:J=1:FOR I=2 TO P:IF S(I)&amp;lt;s(j) THEN j=i&lt;br /&gt;70 NEXT i:FOR I=1 TO L:A$(I,J)=A$(I,q):B$(I,J)=B$(I,q):C(I,J)=C(I,q)&lt;br /&gt;80 D$(I,J)=D$(I,q):E(I,J)=E(I,q):NEXT I:S(J)=s(q)&lt;br /&gt;90 Z=S(Q)/H:FOR I=1 TO L:IF RND*Z&amp;lt;.3 THEN C(I,q)=INT(RND*K)&lt;br /&gt;100 IF RND*Z&amp;lt;.3 THEN E(I,q)=INT(RND*K)&lt;br /&gt;110 Z$=MID$(M$,INT(RND*M)+1,1):IF RND*Z&amp;lt;.3 THEN B$(I,q)=Z$&lt;br /&gt;120 IF RND*Z&amp;lt;.3 THEN D$(I,q)=","+Z$&lt;br /&gt;130 IF RND*Z&amp;lt;.1 THEN A$(I,q)=MID$(O$,INT(RND*LEN(O$)/5)*5+1,5)+" "&lt;br /&gt;140 NEXT I:OPEN "w.evo" FOR OUTPUT AS #1:FOR I=1 TO L&lt;br /&gt;150 PRINT #1,A$(I,q);B$(I,q);C(I,q);D$(I,q);E(I,q):NEXT I:CLOSE #1&lt;br /&gt;160 s(q)=0:FOR I=1 TO W:SHELL P$+" w.evo "+W$(I)+" &amp;gt;s.evo"&lt;br /&gt;170 OPEN "s.evo" FOR INPUT AS #1:INPUT #1,Z$:CLOSE #1:Z=1&lt;br /&gt;180 IF MID$(Z$,Z,1)&amp;lt;&amp;gt;" " THEN Z=Z+1:GOTO 180&lt;br /&gt;190 s(q)=s(q)+3*VAL(LEFT$(Z$,Z))+VAL(RIGHT$(Z$,LEN(Z$)-Z)):NEXT I&lt;br /&gt;200 IF s(q)&amp;gt;H THEN H=s(q):SHELL "copy w.evo best.war"&lt;br /&gt;210 goto 60&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2751923385079797216?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2751923385079797216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2751923385079797216&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2751923385079797216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2751923385079797216'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/06/12k-tiny-corewar-evolver.html' title='1.2K Tiny Corewar Evolver'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-8729967892897489389</id><published>2009-06-20T21:27:00.001+01:00</published><updated>2009-06-20T21:51:49.466+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='evolver'/><category scheme='http://www.blogger.com/atom/ns#' term='core war'/><category scheme='http://www.blogger.com/atom/ns#' term='nano'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><title type='text'>Results from an Even Simpler Corewar Evolver</title><content type='html'>Over the last week I've been removing as much as possible from TEV, the &lt;a href="http://impomatic.blogspot.com/2009/06/corewar-tiny-evolver-tev-v0.html"&gt;Tiny Corewar Evolver&lt;/a&gt;. The latest version is down to 1.2K and produced a mad mad bomber which entered &lt;a href="http://sal.math.ualberta.ca/hill.php?key=nano"&gt;SAL's nano hill&lt;/a&gt; in 7th place:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;;redcode-nano&lt;br /&gt;;name wrath of the machines&lt;br /&gt;;author John Metcalf&lt;br /&gt;;strategy evolved mad mad bomber&lt;br /&gt;;strategy 28 hours with TEV 1.2K&lt;br /&gt;;assert CORESIZE==80&lt;br /&gt;&lt;br /&gt;spl.b #76, {32&lt;br /&gt;mov.i &amp;gt;11, {49&lt;br /&gt;mov.i }79, {76&lt;br /&gt;mov.i &amp;lt;64, {29&lt;br /&gt;djn.f $-3, {58&lt;br /&gt;end&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-8729967892897489389?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/8729967892897489389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=8729967892897489389&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8729967892897489389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8729967892897489389'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/06/results-from-even-simpler-corewar.html' title='Results from an Even Simpler Corewar Evolver'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-160496899085112239</id><published>2009-06-10T21:32:00.008+01:00</published><updated>2009-06-11T07:09:22.235+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='evolver'/><category scheme='http://www.blogger.com/atom/ns#' term='core war'/><category scheme='http://www.blogger.com/atom/ns#' term='tev'/><category scheme='http://www.blogger.com/atom/ns#' term='nano'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><title type='text'>Corewar Tiny Evolver TEV v0</title><content type='html'>The Corewar Tiny Evolver is a small (&amp;lt; 1.5K) program written in GWBasic. After a couple of hours evolving, TEV is capable of producing programs able to compete with hand-written progams and enter the &lt;a href="http://sal.math.ualberta.ca/hill.php?key=nano"&gt;Corewar nano hill&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Instructions&lt;/h3&gt;Place TEV0.BAS, TEV0.BAT and a selection of benchmark warriors in the same directory.  The parameters in line 10-20 are set up for the nano hill but can be adjusted if required.&lt;br /&gt;&lt;br /&gt;Run TEV0.BAT.  Evolution will continue until you decide to terminate the program.  Throughout the process, the best warrior can always be found in the file BEST.WAR.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Program Layout&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;batch file: generate a list of benchmark warriors, run the evolver&lt;/li&gt;&lt;li&gt;10-20: set evolution parameters (see Parameters)&lt;/li&gt;&lt;li&gt;30-50: initialise the evolver&lt;/li&gt;&lt;li&gt;60-110: mutate current warrior based on how well it performs&lt;/li&gt;&lt;li&gt;120-130: write current warrior to file&lt;/li&gt;&lt;li&gt;140-180: benchmark current warrior, abort if poor performance&lt;/li&gt;&lt;li&gt;190: if benchmark warrior is best to date, save a copy&lt;/li&gt;&lt;li&gt;200-220: replace a lower scoring warrior with current warrior&lt;/li&gt;&lt;li&gt;230-250: if score below threshold, discard warrior and select another&lt;/li&gt;&lt;li&gt;repeat from 60&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;Parameters&lt;/h3&gt;The evolution parameters are set in lines 10-20&lt;br /&gt;&lt;ul&gt;&lt;li&gt;K: coresize&lt;/li&gt;&lt;li&gt;L: maximum warrior length&lt;/li&gt;&lt;li&gt;P: number of warriors in the evolution pool&lt;/li&gt;&lt;li&gt;R: number of rounds per benchmark battle&lt;/li&gt;&lt;li&gt;M$: addressing modes to be used&lt;/li&gt;&lt;li&gt;O$: opcode/modifier combinations to be used&lt;/li&gt;&lt;li&gt;P$: pMARS command line&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;TEV0.BAT&lt;br /&gt;&lt;pre&gt;@dir /b /o-d *.red &amp;gt;w.evo&lt;br /&gt;@echo END &amp;gt;&amp;gt;w.evo&lt;br /&gt;@gwbasic tev0&lt;br /&gt;@erase ?.evo&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;TEV0.BAS&lt;br /&gt;&lt;pre&gt;10 P$="pmars -s 80 -p 80 -c 800 -l 5 -b -k -P":R=142:L=5:P=20:K=80&lt;br /&gt;20 O$="mov.ispl.bdjn.f;xxxx":M$="&amp;lt;@&amp;gt;{*}$#"&lt;br /&gt;30 DIM W$(500),A$(L,P),B$(L,P),C(L,P),D$(L,P),E(L,P),S(P):RANDOMIZE TIMER&lt;br /&gt;40 W=0:OPEN "w.evo" FOR INPUT AS #1:M=LEN(M$):H=80&lt;br /&gt;50 INPUT #1,W$(W+1):IF W$(W+1)&amp;lt;&amp;gt;"END" THEN W=W+1:GOTO 50 ELSE CLOSE #1&lt;br /&gt;60 FOR I=1 TO L:IF RND*S(1)/H&amp;lt;.6/L THEN C(I,1)=(C(I,1)+INT((RND-RND)*K))MOD K&lt;br /&gt;70 IF RND*S(1)/H&amp;lt;.7/L THEN E(I,1)=(E(I,1)+INT((RND-RND)*K))MOD K&lt;br /&gt;80 IF RND*S(1)/H&amp;lt;.3/L THEN B$(I,1)=MID$(M$,INT(RND*M)+1,1)&lt;br /&gt;90 IF RND*S(1)/H&amp;lt;.4/L THEN D$(I,1)=MID$(M$,INT(RND*M)+1,1)&lt;br /&gt;100 IF RND*S(1)/H&amp;lt;.3/L THEN A$(I,1)=MID$(O$,INT(RND*LEN(O$)/5)*5+1,5)&lt;br /&gt;110 NEXT I&lt;br /&gt;120 OPEN "w.evo" FOR OUTPUT AS #1:FOR I=1 TO L&lt;br /&gt;130 PRINT #1,A$(I,1)+" "+B$(I,1);C(I,1);","+D$(I,1);E(I,1):NEXT I:CLOSE #1&lt;br /&gt;140 S(1)=0:FOR I=1 TO W:SHELL P$+" w.evo "+W$(I)+" &amp;gt;s.evo"&lt;br /&gt;150 OPEN "s.evo" FOR INPUT AS #1:INPUT #1,Z$:CLOSE #1:Z=1&lt;br /&gt;160 IF MID$(Z$,Z,1)&amp;lt;&amp;gt;" " THEN Z=Z+1:GOTO 160&lt;br /&gt;170 S(1)=S(1)+3*VAL(LEFT$(Z$,Z))+VAL(RIGHT$(Z$,LEN(Z$)-Z))&lt;br /&gt;180 IF I&amp;gt;W/5 AND S(1)*150/H&amp;lt;I*R THEN 240 ELSE NEXT I&lt;br /&gt;190 S(1)=100*S(1)/(W*R):IF S(1)&amp;gt;H THEN H=S(1):SHELL "copy w.evo best.war"&lt;br /&gt;200 FOR J=2 TO P:IF S(J)&amp;gt;S(1) THEN NEXT J:GOTO 230&lt;br /&gt;210 FOR I=1 TO L:A$(I,J)=A$(I,1):B$(I,J)=B$(I,1):C(I,J)=C(I,1)&lt;br /&gt;220 D$(I,J)=D$(I,1):E(I,J)=E(I,1):NEXT I:S(J)=S(1)&lt;br /&gt;230 IF S(1)&amp;gt;H*.9 THEN 60&lt;br /&gt;240 Z=INT(RND*(P-1))+2:FOR I=1 TO L:A$(I,1)=A$(I,Z):B$(I,1)=B$(I,Z)&lt;br /&gt;250 C(I,1)=C(I,Z):D$(I,1)=D$(I,Z):E(I,1)=E(I,Z):NEXT I:S(1)=S(Z):GOTO 60&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-160496899085112239?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/160496899085112239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=160496899085112239&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/160496899085112239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/160496899085112239'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/06/corewar-tiny-evolver-tev-v0.html' title='Corewar Tiny Evolver TEV v0'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-3106942682071437219</id><published>2009-05-27T13:07:00.009+01:00</published><updated>2009-05-27T15:00:46.710+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='core war'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><title type='text'>The Incredible! Corewar Secret</title><content type='html'>Towards the end of 2002 a five line warrior entered the KOTH.org '94 Draft hill in fifth place, later becoming King of the Hill. Although I've often been asked about Incredible, so far I've kept its secret quiet:&lt;br /&gt;&lt;pre&gt;Program "Incredible!" (length 5) by "John Metcalf"&lt;br /&gt;;strategy tweaked away one instruction&lt;br /&gt;&lt;br /&gt;Last battle concluded at : Sun Dec 1 17:26:58 EST 2002&lt;br /&gt;&lt;br /&gt; #  %W/ %L/ %T               Name              Author   Score     Age&lt;br /&gt; 1  40/ 42/ 18     Herbal Avenger     Michal Janeczek     139      18&lt;br /&gt; 2  39/ 42/ 19           Combatra         David Moore     136       7&lt;br /&gt; 3  24/ 11/ 65            Blowrag     Metcalf/Schmidt     136      62&lt;br /&gt; 4  35/ 35/ 30     Mantrap Arcade         Dave Hillis     136       2&lt;br /&gt; 5  24/ 13/ 64        Incredible!        John Metcalf     135       1&lt;br /&gt; 6  28/ 22/ 51         Reepicheep      Grabun/Metcalf     133     135&lt;br /&gt; 7  27/ 22/ 52        Son of Vain     Oversby/Pihlaja     132     106&lt;br /&gt; 8  33/ 34/ 33     Cyanide Excuse         Dave Hillis     131       8&lt;br /&gt; 9  25/ 22/ 53          Paperazor   Christian Schmidt     129      79&lt;br /&gt;10  28/ 27/ 45          Uninvited        John Metcalf     129     125&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Incredible is a standard paper/imp using an exploit to hide its true length from the KOTH script. The script has two sections. The front-end checks a warrior compiles correctly and extracts the name, author, strategy and length for the reports. The back-end runs the actual battle.&lt;br /&gt;&lt;br /&gt;Incredible takes advantage of the fact the front-end calls pMARS with a different number of rounds to the back-end. This is used to present different code to the front-end:&lt;br /&gt;&lt;pre&gt;;redcode-94&lt;br /&gt;;name length exploit&lt;br /&gt;;author John Metcalf&lt;br /&gt;;strategy demonstrate how to hide a program's true length&lt;br /&gt;;assert CORESIZE == 8000&lt;br /&gt;&lt;br /&gt;    for ROUNDS &amp;lt; 5&lt;br /&gt;        ;the front-end sees this code&lt;br /&gt;        for 5&lt;br /&gt;            dat 0, 0&lt;br /&gt;        rof&lt;br /&gt;    rof&lt;br /&gt;&lt;br /&gt;    for ROUNDS &amp;gt; 4&lt;br /&gt;        ;the back-end sees this code&lt;br /&gt;        ;insert warrior code here&lt;br /&gt;    rof&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I couldn't reveal the secret earlier because the KOTH script crashes if the code for the back-end contains errors. The script also crashes if the exploit is used to send '94 code to the '88 hill or p-space code to the no p-space hill. Unfortunately KOTH.org will be closing in a few days so it should be safe to share this now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-3106942682071437219?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/3106942682071437219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=3106942682071437219&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3106942682071437219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3106942682071437219'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/05/incredible-corewar-secret.html' title='The Incredible! Corewar Secret'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-7482750716640361844</id><published>2009-05-25T22:15:00.003+01:00</published><updated>2009-05-27T15:42:14.005+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='evolver'/><category scheme='http://www.blogger.com/atom/ns#' term='core war'/><category scheme='http://www.blogger.com/atom/ns#' term='nano'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><title type='text'>First Results from a New Corewar Evolver</title><content type='html'>Over the last few days I've been working on a short program written in GWBasic to evolve Corewar programs. After a test run earlier today, plateau entered SAL's &lt;a href="http://sal.math.ualberta.ca/hill.php?key=nano"&gt;nano hill&lt;/a&gt;:&lt;br /&gt;&lt;pre&gt;;redcode-nano&lt;br /&gt;;name plateau&lt;br /&gt;;author John Metcalf&lt;br /&gt;;strategy evolved mad mad bomber&lt;br /&gt;;strategy hit a plateau after 4 hours&lt;br /&gt;;assert CORESIZE==80&lt;br /&gt;&lt;br /&gt;spl.b #16,  &amp;lt;28&lt;br /&gt;mov.i &amp;lt;-15, {-35&lt;br /&gt;mov.i {-1,  {-3&lt;br /&gt;mov.i &amp;lt;-28, &amp;lt;25&lt;br /&gt;djn.f $-3,  &amp;lt;33&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;The evolver creates warriors through pure evolution. The soup is seeded with random instructions and evolution is guided only by performance against the 2007 Nano Benchmark. If a benchmark test is scoring below a certain threshold, the test breaks out early.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Evolution is by mutation only. Crossover, insertion and deletion are not implemented. The lower a warrior scores, the more it is changed by mutation. After each round, a high scoring program replaces a randomly chosen low scoring program.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here are the plans for the next version:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;keep a checksum of warriors to prevent duplicates in the pool&lt;/li&gt;&lt;li&gt;add a hint mode, but to keep it pure it'll hint what we don't want&lt;/li&gt;&lt;li&gt;implement crossover&lt;/li&gt;&lt;li&gt;think of a decent name (I think revolver is already taken)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Any suggestions would be greatly appreciated.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-7482750716640361844?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/7482750716640361844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=7482750716640361844&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7482750716640361844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7482750716640361844'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/05/first-results-from-new-corewar-evolver.html' title='First Results from a New Corewar Evolver'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-8354831359413288721</id><published>2009-04-19T01:11:00.004+01:00</published><updated>2009-04-20T08:32:47.443+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='djn'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='oisc'/><title type='text'>Redcode's OISC - the DJN Computer</title><content type='html'>An &lt;acronym title="One-Instruction Set Computer"&gt;OISC&lt;/acronym&gt; is an abstract computer designed to be Turing complete with only one instruction. &lt;acronym title="One-Instruction Set Computer"&gt;OISC&lt;/acronym&gt; is short for One-Instruction Set Computer.&lt;br /&gt;&lt;br /&gt;The instruction used by most variants of &lt;acronym title="One-Instruction Set Computer"&gt;OISC&lt;/acronym&gt; subtracts and branches on certain conditions, for example the &lt;a href="http://impomatic.blogspot.com/2009/01/redcode-interpretter-for-rssb-single.html"&gt;URISC / RSSB Single Instruction Computer&lt;/a&gt;. It may come as a surprise that the Redcode instruction set contains a primative instuction suitable for building a One-Instruction Computer, &lt;code&gt;&lt;acronym title="Decrement and Jump if Non-zero"&gt;DJN&lt;/acronym&gt;&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;DJN X, Y&lt;/code&gt; uses Y as a pointer into memory. 1 is subtracted from the value stored at location Y. If the result is non-zero, &lt;code&gt;DJN&lt;/code&gt; jumps to X. Here's an example demonstrating how to copy A to B using &lt;code&gt;DJN&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        DJN 0,   TEMP&lt;br /&gt;        DJN 0,   B&lt;br /&gt;        DJN 1,   TEMP&lt;br /&gt;        DJN -1,  A&lt;br /&gt;        DJN 1,   A&lt;br /&gt;        DJN 1,   B&lt;br /&gt;        DJN -2,  TEMP&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Unfortunately, the performance is poor, 56000 cycles to execute a &lt;code&gt;MOV&lt;/code&gt;!&lt;br /&gt;&lt;br /&gt;The following code proves &lt;code&gt;DJN&lt;/code&gt; is Turing complete by equivalence to SUBLEQ A, B, C:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;         DJN 0,   TEMP&lt;br /&gt;         DJN 1,   TEMP&lt;br /&gt;         DJN 10,  B&lt;br /&gt;         DJN 4,   SCRATCH&lt;br /&gt;         DJN 3,   SCRATCH&lt;br /&gt;         DJN 1,   TEMP&lt;br /&gt;         DJN 1,   B&lt;br /&gt;         DJN -2,  A&lt;br /&gt;         DJN 1,   A&lt;br /&gt;         DJN -1,  TEMP&lt;br /&gt;         DJN C,   SCRATCH&lt;br /&gt;         DJN C,   SCRATCH&lt;br /&gt;         DJN -11, A&lt;br /&gt;         DJN 1,   A&lt;br /&gt;         DJN -1,  TEMP&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, who's volunteering to implement the first self-interpreter? ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-8354831359413288721?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/8354831359413288721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=8354831359413288721&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8354831359413288721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8354831359413288721'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/04/redcodes-oisc-djn-computer.html' title='Redcode&apos;s OISC - the DJN Computer'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-4559538007200560415</id><published>2009-03-02T10:55:00.001Z</published><updated>2010-07-15T19:26:02.633+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='core war'/><category scheme='http://www.blogger.com/atom/ns#' term='birthday'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><title type='text'>Happy 25th Birthday Core War</title><content type='html'>When David Jones and A. K. Dewdney produced their &lt;a href="http://corewar.co.uk/cwg.txt"&gt;Core War Guidelines&lt;/a&gt; in March 1984, they could hardly have imagined the success it would achieve. Core War is still going strong 25 years later and I'd like to wish everyone in the Core War community a very happy birthday.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Core War, a Short History:&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Shortly after the guidelines were complete, an article in Dewdney's Computer Recreations column in &lt;i&gt;Scientific American&lt;/i&gt; introduce the world to Core War. The wheels on the Core War machine had been put in motion.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The following year the &lt;acronym title="International Core Wars Society"&gt;ICWS&lt;/acronym&gt; was formed to standardise and promote Core War, with Mark Clarkson as director. The &lt;acronym title="International Core Wars Society"&gt;ICWS&lt;/acronym&gt; published &lt;i&gt;The Core Wars Standard&lt;/i&gt; and organised the &lt;a href="http://corewar.co.uk/icwt1986/index.htm"&gt;First International Core War Tournament&lt;/a&gt; at the Computer Museum in Boston, Mass.&lt;br /&gt;&lt;br /&gt;William R. Buckley began publication of &lt;i&gt;The Core War Newsletter&lt;/i&gt; in early 1987, providing a forum for Core War players. Early issues covered what we now consider the basic techniques of Core War. Later issues discussed advance topics, for example the holy grail of Core War: self-repairing programs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Core War, 25 Years On:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Fast forward to 2009. Dozens of players are competing on the &lt;a href="http://corewar.co.uk/hills.htm"&gt;Core War hills&lt;/a&gt; and the possibilities seem endless. I can't help wondering what a Core War player from 1984 would make of our battle programs, or if they ever imagined how we'd be creating them 25 years later. Computer optimized constants and evolved code are the order of the day.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The &lt;acronym title="International Core Wars Society"&gt;ICWS&lt;/acronym&gt; has fallen by the wayside, as has &lt;acronym title="The Core War Newletter"&gt;TCWN&lt;/acronym&gt;. However, a number of irregular Core War journals have florished and the online Core War community organise the occasional tournament as an alternative to competing on the hill.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let's hope Core War is still going strong in 2034, to celebrate it's 50th birthday! :-)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;More About Core War:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Here are the top resources to discover more about Core War:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://vyznev.net/corewar/guide.html"&gt;Beginner's Guide to Redcode&lt;/a&gt; covers the basics of Redcode, the language of Core War&lt;/li&gt;&lt;li&gt;&lt;a href="http://corewar.co.uk/pmars"&gt;pMARS&lt;/a&gt; is a portable Core War virtual machine, implemented in C&lt;/li&gt;&lt;li&gt;&lt;a href="http://corewar.co.uk/biblio.htm"&gt;The Core War Bibliography&lt;/a&gt; lists tutorials covering almost every aspect of Core War&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.koth.org/"&gt;KOTH.org&lt;/a&gt; and &lt;a href="http://sal.math.ualberta.ca/"&gt;KOTH@SAL&lt;/a&gt; organise the King of the Hill tournaments, played by email&lt;/li&gt;&lt;li&gt;&lt;a href="http://users.obs.carnegiescience.edu/birk/COREWAR/koenigstuhl.html"&gt;Koenigstuhl&lt;/a&gt; is a huge archive of published Core War battle programs&lt;/li&gt;&lt;li&gt;&lt;a href="irc://irc.freenode.net/#COREWARS"&gt;#corewars&lt;/a&gt; is the Core War IRC channel, hosted on &lt;a href="irc://irc.freenode.net/#COREWARS"&gt;irc.freenode.net&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-4559538007200560415?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/4559538007200560415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=4559538007200560415&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4559538007200560415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4559538007200560415'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/03/happy-25th-birthday-core-war.html' title='Happy 25th Birthday Core War'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-4505101275908251063</id><published>2009-02-24T17:28:00.008Z</published><updated>2009-02-25T13:16:29.146Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='sts'/><category scheme='http://www.blogger.com/atom/ns#' term='forth'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='interpreter'/><title type='text'>Implementing Forth in Redcode</title><content type='html'>I'm currently working on a threaded Forth interpreter in Redcode. The first version should provide about 20 key Forth instructions in 50 lines of code.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Threading&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;The Forth program will be stored as a list of subroutine calls, for example:&lt;br /&gt;&lt;pre&gt;        dat    lit     ; push 1111&lt;br /&gt;        dat    1111&lt;br /&gt;        dat    lit     ; push 1234&lt;br /&gt;        dat    1234&lt;br /&gt;        dat    plus    ; add TOS to 2OS&lt;br /&gt;        dat    udot    ; display TOS&lt;br /&gt;&lt;/pre&gt;A more compact representation would be to store addresses in both the a-field and b-field. Unfortunately this would be at the expense of more complex flow control:&lt;br /&gt;&lt;pre&gt;        dat    lit,      1111&lt;br /&gt;        dat    lit,      1234&lt;br /&gt;        dat    plus,     udot&lt;br /&gt;&lt;/pre&gt;I'm open to suggestions how the interpreter can use the compact representation without causing too many difficulties.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Instruction Set&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;I'm planning to support the following instructions in version 1. Have I missed anything important, or have I included something which can be left out:&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left"&gt;Ins&lt;/th&gt;&lt;th align="left"&gt;Description&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;subtract TOS from 2OS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;+&lt;/td&gt;&lt;td&gt;add TOS to 2OS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;multiply TOS by 2OS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;U.&lt;/td&gt;&lt;td&gt;print TOS as an unsigned number&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SPACE&lt;/td&gt;&lt;td&gt;print a space&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DUP&lt;/td&gt;&lt;td&gt;copy TOS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DROP&lt;/td&gt;&lt;td&gt;remove TOS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;ABS&lt;/td&gt;&lt;td&gt;replace TOS with its absolute value&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NEGATE&lt;/td&gt;&lt;td&gt;replace TOS with -TOS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;!&lt;/td&gt;&lt;td&gt;2OS is stored at the address in TOS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;+!&lt;/td&gt;&lt;td&gt;2OS is added to the address in TOS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;@&lt;/td&gt;&lt;td&gt;fetch the value at the address in TOS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;=&lt;/td&gt;&lt;td&gt;TRUE if TOS=2OS, else FALSE&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SWAP&lt;/td&gt;&lt;td&gt;exchange TOS with 2OS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DEPTH&lt;/td&gt;&lt;td&gt;number of elements on stack&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BEGIN&lt;/td&gt;&lt;td&gt;start of BEGIN .. UNTIL structure&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;UNTIL&lt;/td&gt;&lt;td&gt;if TRUE, return to matching BEGIN&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DO&lt;/td&gt;&lt;td&gt;start of DO .. LOOP structure&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;LOOP&lt;/td&gt;&lt;td&gt;inc counter, jump to DO if below limit&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Signed vs Unsigned&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Unfortunately numbers in Forth are signed and numbers in Redcode are unsigned. This affects a number of instructions, including division and comparison. Would it be worth the extra code to support unsigned numbers in Redcode Forth?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Example Code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The following example interprets +, U. and literals. New instructions can easily be added in Redcode. Support for calling new instuctions written in Forth needs to be added:&lt;/div&gt;&lt;/div&gt;&lt;pre&gt;        org    next&lt;br /&gt;&lt;br /&gt;stack   dat    0,         0&lt;br /&gt;&lt;br /&gt;; LIT - place the next value on the stack&lt;br /&gt;&lt;br /&gt;lit     mov.b  }ip,       &amp;lt;stack&lt;br /&gt;        jmp    next&lt;br /&gt;&lt;br /&gt;; + - remove 2OS and TOS and put their sum on stack&lt;br /&gt;&lt;br /&gt;plus    add.b  &amp;gt;stack,    @stack&lt;br /&gt;        jmp    next&lt;br /&gt;&lt;br /&gt;; U. - remove and display TOS as an unsigned number&lt;br /&gt;&lt;br /&gt;udot    mov.b  @stack,    &amp;lt;stack&lt;br /&gt;        div    #10,       &amp;gt;stack&lt;br /&gt;        mod    #10,       @stack&lt;br /&gt;        add    #48,       @stack&lt;br /&gt;        add    #1,        udcount&lt;br /&gt;        jmn    udot,      &amp;lt;stack&lt;br /&gt;        add    #1,        stack&lt;br /&gt;udloop  sts    &amp;gt;stack,    0&lt;br /&gt;udcount djn    udloop,    #0&lt;br /&gt;        sts.a  #32,       0&lt;br /&gt;        jmp    next&lt;br /&gt;&lt;br /&gt;; --------------------------------&lt;br /&gt;&lt;br /&gt;next&lt;br /&gt;ip      jmp    @prog,     }ip&lt;br /&gt;&lt;br /&gt;; --------------------------------&lt;br /&gt;&lt;br /&gt;prog&lt;br /&gt;        dat    lit     ; push 1111&lt;br /&gt;        dat    1111&lt;br /&gt;        dat    lit     ; push 1234&lt;br /&gt;        dat    1234&lt;br /&gt;        dat    plus    ; add TOS to 2OS&lt;br /&gt;        dat    udot    ; display TOS&lt;br /&gt;&lt;br /&gt;        end&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-4505101275908251063?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/4505101275908251063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=4505101275908251063&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4505101275908251063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4505101275908251063'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/02/implementing-forth-in-redcode.html' title='Implementing Forth in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-8454803066105777693</id><published>2009-02-16T13:32:00.000Z</published><updated>2009-02-25T13:18:53.555Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='interpreter'/><category scheme='http://www.blogger.com/atom/ns#' term='underload'/><title type='text'>Underload Interpreter in Redcode</title><content type='html'>Underload is a stack-based esoteric programming language designed by ais523. A set of 8 single character instructions operate on a stack of variable length strings:&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th scope="col" align="left"&gt;Ins&lt;/th&gt;&lt;th scope="col" align="left"&gt;Description&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;:&lt;/td&gt;&lt;td&gt;copy the top stack entry&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;!&lt;/td&gt;&lt;td&gt;drop the top stack entry&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;~&lt;/td&gt;&lt;td&gt;swap the top two stack entries&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;join the top two stack entries&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;S&lt;/td&gt;&lt;td&gt;display then drop the top stack entry&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;^&lt;/td&gt;&lt;td&gt;drop then run the top stack entry&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;a&lt;/td&gt;&lt;td&gt;enclose the top stack entry in parentheses&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;( )&lt;/td&gt;&lt;td&gt;add a new stack entry&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;A combination of different factors make an interpreter for Underload an interesting project to tackle in Redcode:&lt;div&gt;&lt;ul&gt;&lt;li&gt;parsing single character instructions is easy, I don't like writing parsers&lt;/li&gt;&lt;li&gt;handling variable length data can be tricky&lt;/li&gt;&lt;li&gt;no operands / no side effects to worry about&lt;/li&gt;&lt;li&gt;only 8 instructions, the size of the interpreter should be reasonable&lt;/li&gt;&lt;li&gt;^ is the only means of flow control&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;The final code weighs in at a mere 79 instructions. Here's the final version of the &lt;a href="http://corewar.co.uk/assembly/underload.htm"&gt;Underload Interpreter&lt;/a&gt;. If you have any improvements to suggest, please leave a comment below.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-8454803066105777693?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/8454803066105777693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=8454803066105777693&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8454803066105777693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8454803066105777693'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/02/underload-interpreter-in-redcode.html' title='Underload Interpreter in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1133598205715994168</id><published>2009-02-06T21:52:00.000Z</published><updated>2009-02-25T13:18:27.556Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='sts'/><category scheme='http://www.blogger.com/atom/ns#' term='output'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Display Signed Number in Base X</title><content type='html'>The following Redcode displays a signed number is a chosen number base:&lt;br /&gt;&lt;pre&gt;dot     slt    @stack,    #1+CORESIZE/2&lt;br /&gt;        sts.a  #45,       0&lt;br /&gt;        slt    @stack,    #1+CORESIZE/2&lt;br /&gt;        mul    #-1,       @stack&lt;br /&gt;udot    mov.b  @stack,    &amp;lt;stack&lt;br /&gt;        div.b  base,      &amp;gt;stack&lt;br /&gt;        mod.b  base,      @stack&lt;br /&gt;        slt    @stack,    #10&lt;br /&gt;        add    #7,        @stack&lt;br /&gt;        add    #48,       @stack&lt;br /&gt;        add    #1,        udcount&lt;br /&gt;        jmn    udot,      &amp;lt;stack&lt;br /&gt;        add    #1,        stack&lt;br /&gt;udloop  sts    &amp;gt;stack,    0&lt;br /&gt;udcount djn    udloop,    #0&lt;br /&gt;&lt;br /&gt;base    dat    10&lt;/pre&gt;Unfortunately, the code is pretty ugly. Can you suggest a more elegant solution?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1133598205715994168?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1133598205715994168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1133598205715994168&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1133598205715994168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1133598205715994168'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/02/display-signed-number-in-base-x.html' title='Display Signed Number in Base X'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-8744596130674924373</id><published>2009-01-25T14:12:00.006Z</published><updated>2009-01-25T17:29:05.513Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='bf'/><category scheme='http://www.blogger.com/atom/ns#' term='interpreter'/><category scheme='http://www.blogger.com/atom/ns#' term='brainf***'/><title type='text'>Brainf*** Interpreter in Redcode</title><content type='html'>Brainf*** is an esoteric programming language developed by Urban Müller. There are 8 instructions in brainf***:&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left"&gt;Ins&lt;/th&gt;&lt;th align="left"&gt;Macro&lt;/th&gt;&lt;th align="left"&gt;Description&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;lt;&lt;/td&gt;&lt;td&gt;lt&lt;/td&gt;&lt;td&gt;move pointer left&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;gt;&lt;/td&gt;&lt;td&gt;gt&lt;/td&gt;&lt;td&gt;move pointer right&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;+&lt;/td&gt;&lt;td&gt;inc&lt;/td&gt;&lt;td&gt;increment memory cell at pointer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;dec&lt;/td&gt;&lt;td&gt;decrement memory cell at pointer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;.&lt;/td&gt;&lt;td&gt;out&lt;/td&gt;&lt;td&gt;output a character from the cell at pointer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;,&lt;/td&gt;&lt;td&gt;in&lt;/td&gt;&lt;td&gt;input a character and store in cell at pointer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;[&lt;/td&gt;&lt;td&gt;op&lt;/td&gt;&lt;td&gt;jump past matching ] if cell at pointer is 0&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;]&lt;/td&gt;&lt;td&gt;cl&lt;/td&gt;&lt;td&gt;jump to matching [ if cell at pointer not 0&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Brainf*** operates on an array of memory cells and has a pointer into the array. Each instruction translates directly into Redcode. Before executing the brainf*** program, the interpreter calculates and stores the offset for [ and ] to avoid repeated searching.&lt;br /&gt;&lt;br /&gt;Here's the code:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;        lt equ sub #1, ptr&lt;br /&gt;        gt equ add #1, ptr&lt;br /&gt;        inc equ add #1, @ptr&lt;br /&gt;        dec equ sub #1, @ptr&lt;br /&gt;        out equ sts @ptr, 0&lt;br /&gt;        in equ lds @ptr, 0&lt;br /&gt;        op equ jmz 0, @ptr&lt;br /&gt;        cl equ jmn 2, @ptr&lt;br /&gt;&lt;br /&gt;        org    seek&lt;br /&gt;&lt;br /&gt;ptr     mov.ba #0,        #prog&lt;br /&gt;&lt;br /&gt;find    sne.a  #2,        *ptr&lt;br /&gt;        sub    #1,        count&lt;br /&gt;        sne.a  #0,        }ptr&lt;br /&gt;        jmp    find,      &amp;gt;count&lt;br /&gt;count   jmn    find,      #0&lt;br /&gt;&lt;br /&gt;        mov.a  ptr,       @ptr&lt;br /&gt;        sub.ba ptr,       &amp;gt;ptr&lt;br /&gt;        mov.ba ptr,       {ptr&lt;br /&gt;        sub.a  ptr,       *ptr&lt;br /&gt;&lt;br /&gt;seek    jmn.a  seek,      &amp;gt;ptr&lt;br /&gt;        jmn    ptr,       &amp;lt;ptr&lt;br /&gt;&lt;br /&gt;prog&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-8744596130674924373?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/8744596130674924373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=8744596130674924373&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8744596130674924373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8744596130674924373'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/01/brainf-interpreter-in-redcode.html' title='Brainf*** Interpreter in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-550561709269276695</id><published>2009-01-18T16:14:00.005Z</published><updated>2009-01-25T14:25:32.840Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='sts'/><category scheme='http://www.blogger.com/atom/ns#' term='rssb'/><category scheme='http://www.blogger.com/atom/ns#' term='lds'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='interpreter'/><category scheme='http://www.blogger.com/atom/ns#' term='oisc'/><title type='text'>Redcode Interpreter for the RSSB Single Instruction Computer</title><content type='html'>The &lt;acronym title="Reverse Subtract and Skip if Borrow"&gt;RSSB&lt;/acronym&gt; single instruction computer is a minimal, Turing complete virtual machine. The instruction used is Reverse Subtract and Skip if Borrow. &lt;acronym title="Reverse Subtract and Skip if Borrow"&gt;RSSB&lt;/acronym&gt; subtracts the accumulator from the contents of a memory location and stores the result in both. The next instruction will be skipped if the accumulator was greater than the value in memory.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Jumps can be implemented by manipulating the instruction pointer at memory location 0. Other special locations are as follows:&lt;/div&gt;&lt;ol&gt;&lt;li&gt;accumulator&lt;/li&gt;&lt;li&gt;always contains 0&lt;/li&gt;&lt;li&gt;input&lt;/li&gt;&lt;li&gt;output&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Here's the code for the interpreter. I've included a Hello World program written in &lt;acronym title="Reverse Subtract and Skip if Borrow"&gt;RSSB&lt;/acronym&gt;. If you think you can reduce the size of Hello World, please let me know how.&lt;/div&gt;&lt;pre&gt;        org    rssbint&lt;br /&gt;&lt;br /&gt;rssbint mov.ba &gt;ip,       ip    ; load next instruction&lt;br /&gt;&lt;br /&gt;        mov    #0,        zero  ; set zero&lt;br /&gt;&lt;br /&gt;        sne.a  #3,        ip    ; handle input&lt;br /&gt;        lds    in,        0&lt;br /&gt;&lt;br /&gt;        sne.a  #4,        ip    ; handle output&lt;br /&gt;        sts    acc,       0&lt;br /&gt;        mov    acc,       out&lt;br /&gt;        add    out,       out&lt;br /&gt;&lt;br /&gt;        slt    *ip,       acc   ; set flag for skip&lt;br /&gt;        mov    #2,        skip&lt;br /&gt;&lt;br /&gt;        sub.b  acc,       *ip   ; acc, *ip = *ip - acc&lt;br /&gt;        mov.b  *ip,       acc&lt;br /&gt;&lt;br /&gt;skip    djn    noskip,    #1    ; skip if required&lt;br /&gt;        nop    &gt;ip,       &gt;skip&lt;br /&gt;&lt;br /&gt;noskip  slt    #7900,     @ip   ; protect interpreter&lt;br /&gt;&lt;br /&gt;        jmn    rssbint,   ip    ; loop until ip = 0&lt;br /&gt;&lt;br /&gt;; --------------------------------------&lt;br /&gt;&lt;br /&gt;ip      dat    5      ; instruction pointer&lt;br /&gt;acc     dat    0      ; accumulator&lt;br /&gt;zero    dat    0      ; always 0&lt;br /&gt;in      dat    0      ; character input&lt;br /&gt;out     dat    0      ; character output&lt;br /&gt;&lt;br /&gt;; --------------------------------------&lt;br /&gt;&lt;br /&gt;loop    dat    -ip+   acc       ; acc = character from ptr&lt;br /&gt;ptr     dat    -ip+   hello        &lt;br /&gt;&lt;br /&gt;        dat    -ip+   out       ; display character&lt;br /&gt;&lt;br /&gt;        dat    -ip+   zero      ; acc = -acc&lt;br /&gt;&lt;br /&gt;        dat    -ip+   zero      ; always skipped&lt;br /&gt;&lt;br /&gt;        dat    -ip+   sum       ; subtract acc from sum&lt;br /&gt;&lt;br /&gt;        dat    -ip+   ip        ; skipped if sum is negative,&lt;br /&gt;                                ; otherwise jump to 0&lt;br /&gt;&lt;br /&gt;one     dat    -ip+   acc       ; subtract 1 from ptr&lt;br /&gt;        dat    -ip+   one&lt;br /&gt;        dat    -ip+   ptr&lt;br /&gt;&lt;br /&gt;        dat    -ip+   acc       ; jump to loop&lt;br /&gt;        dat    -ip+   loopoff&lt;br /&gt;        dat    -ip+   ip&lt;br /&gt;loopoff dat    -loop&lt;br /&gt;&lt;br /&gt;sum     dat    -1116&lt;br /&gt;&lt;br /&gt;        dat    33         ; '!'&lt;br /&gt;        dat    100        ; 'd'&lt;br /&gt;        dat    108        ; 'l'&lt;br /&gt;        dat    114        ; 'r'&lt;br /&gt;        dat    111        ; 'o'&lt;br /&gt;        dat    87         ; 'W'&lt;br /&gt;        dat    32         ; ' '&lt;br /&gt;        dat    44         ; ','&lt;br /&gt;        dat    111        ; 'o'&lt;br /&gt;        dat    108        ; 'l'&lt;br /&gt;        dat    108        ; 'l'&lt;br /&gt;        dat    101        ; 'e'&lt;br /&gt;hello   dat    72         ; 'H'&lt;br /&gt;&lt;br /&gt;        end&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-550561709269276695?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/550561709269276695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=550561709269276695&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/550561709269276695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/550561709269276695'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/01/redcode-interpretter-for-rssb-single.html' title='Redcode Interpreter for the RSSB Single Instruction Computer'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1374180611818752151</id><published>2009-01-09T22:15:00.003Z</published><updated>2009-01-09T22:41:31.824Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='hill'/><title type='text'>The Corewar DynaHill</title><content type='html'>Christian Schmidt has announced the opening of a new Corewar hill with a ranking system similar to Japanese Sumo. &lt;a href="http://www.corewar.info/dhill/"&gt;The Corewar DynaHill&lt;/a&gt; is of unlimited size. New warriors enter at the bottom and at certain time intervals each warrior fights 15 neighbours.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Depending on the number of wins / losses, each warrior moves either up or down a number of positions. Eventually, the warrior will be unable to climb higher, possibly becoming King of the DynaHill!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;'94draft and limited process warriors co-exist on the hill. If a '94draft warrior battles against a limited process warrior, a random number of processes is chosen between 40 and 120.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The use of &lt;code&gt;PIN&lt;/code&gt; and &lt;code&gt;MAXPROCESSES&lt;/code&gt; is forbidden. The maximum length is 200.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For more information, take a look at &lt;a href="http://www.corewar.info/dhill/faq.htm"&gt;The Corewar DynaHill FAQ&lt;/a&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1374180611818752151?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1374180611818752151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1374180611818752151&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1374180611818752151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1374180611818752151'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/01/corewar-dynahill.html' title='The Corewar DynaHill'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1576622442654455628</id><published>2009-01-06T09:58:00.003Z</published><updated>2009-01-06T10:27:15.580Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='call'/><category scheme='http://www.blogger.com/atom/ns#' term='return'/><category scheme='http://www.blogger.com/atom/ns#' term='subroutine'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Call / Return Macros in Redcode, a Possible Solution</title><content type='html'>Here's one solution to &lt;a href="http://impomatic.blogspot.com/2009/01/call-return-macros-in-redcode.html"&gt;the &lt;code&gt;call&lt;/code&gt; / &lt;code&gt;ret&lt;/code&gt; problem in Redcode&lt;/a&gt;. Unfortunately the offsets in multi-line-equates can be slightly out. In this solution, the offsets are adjusted the first time the &lt;code&gt;call&lt;/code&gt; is executed.  Here's how it works:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;call routine&lt;/code&gt; compiles as follows:&lt;br /&gt;&lt;pre&gt;        mov    #2-return, &amp;lt;stack ; save return address&lt;br /&gt;        jmp    callsub,   1+routine ; jump to callsub which adjusts the address&lt;br /&gt;                                    ; b-field pointer is either correct or out by 1&lt;br /&gt;&lt;/pre&gt;&lt;code&gt;callsub&lt;/code&gt; then adjusts the pointer if necessary and moves it to the a-field of the &lt;code&gt;jmp&lt;/code&gt;:&lt;br /&gt;&lt;pre&gt;         mov    #2-return, &amp;lt;stack ; save return address&lt;br /&gt;         jmp    routine,   1+routine ; jump to routine, a-field is correct&lt;br /&gt;&lt;/pre&gt;The &lt;code&gt;jmp&lt;/code&gt; now contains the correct offset and jumps directly to &lt;code&gt;routine&lt;/code&gt; in future.&lt;br /&gt;&lt;br /&gt;Here's the code:&lt;br /&gt;&lt;pre&gt;stack   dat    0&lt;br /&gt;&lt;br /&gt;call    equ    mov    #2-return, &amp;lt;stack&lt;br /&gt;        equ    jmp    callsub,   1+&lt;br /&gt;&lt;br /&gt;ret     equ    jmp    return&lt;br /&gt;&lt;br /&gt;return  mov.b  &amp;gt;stack,    #0&lt;br /&gt;        jmp    @return&lt;br /&gt;&lt;br /&gt;callsub mov.b  @stack,    #0&lt;br /&gt;        add    #return-callsub, callsub&lt;br /&gt;        mov.ba &amp;lt;callsub,  @callsub&lt;br /&gt;        slt.b  @callsub,  #CORESIZE/2&lt;br /&gt;        jmp    @callsub&lt;br /&gt;        djn.a  @callsub,  @callsub&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1576622442654455628?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1576622442654455628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1576622442654455628&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1576622442654455628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1576622442654455628'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/01/call-return-macros-in-redcode-possible.html' title='Call / Return Macros in Redcode, a Possible Solution'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-8399931039991562712</id><published>2009-01-04T12:17:00.003Z</published><updated>2009-01-04T12:45:59.040Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='call'/><category scheme='http://www.blogger.com/atom/ns#' term='return'/><category scheme='http://www.blogger.com/atom/ns#' term='subroutine'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Call / Return Macros in Redcode</title><content type='html'>For a while I've been trying to implement &lt;code&gt;call&lt;/code&gt; / &lt;code&gt;ret&lt;/code&gt; macros in Redcode so I can call subroutines. The obvious solution is as follows and doesn't work correctly:&lt;br /&gt;&lt;pre&gt;; this code is buggy&lt;br /&gt;&lt;br /&gt;stack   dat    0&lt;br /&gt;&lt;br /&gt;call    equ    mov    #2-return, &amp;lt;stack&lt;br /&gt;        equ    jmp&lt;br /&gt;&lt;br /&gt;ret     equ    jmp    return&lt;br /&gt;&lt;br /&gt;return  mov.b  &amp;gt;stack,    #0&lt;br /&gt;        jmp    @return&lt;br /&gt;&lt;/pre&gt;Unfortunately, this only works for forward calls. The address offset is out by 1 for reverse calls and I can't find a simple fix. I've tried the following solutions, but I'm not particularly happy with any of them:&lt;div&gt;&lt;ul&gt;&lt;li&gt;adding a &lt;code&gt;nop&lt;/code&gt; to the top of all subroutines (extra code)&lt;/li&gt;&lt;li&gt;using a macro to automatically adjust the address, e.g. &lt;code&gt;call subroutine adjust&lt;/code&gt; (ugly)&lt;/li&gt;&lt;li&gt;adjusting the address the first time it is executed (extra code, slower)&lt;/li&gt;&lt;/ul&gt;Can you suggest a better solution?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-8399931039991562712?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/8399931039991562712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=8399931039991562712&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8399931039991562712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8399931039991562712'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2009/01/call-return-macros-in-redcode.html' title='Call / Return Macros in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1076952200605378213</id><published>2008-12-24T00:25:00.001Z</published><updated>2008-12-24T13:46:58.112Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='sts'/><category scheme='http://www.blogger.com/atom/ns#' term='output'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Write Number (implemented using a data stack)</title><content type='html'>Here's an alternative version of the routine to &lt;a href="http://impomatic.blogspot.com/2008/04/write-number.html"&gt;display numbers&lt;/a&gt; using exMARS Stream's &lt;code&gt;sts&lt;/code&gt; opcode. The code executes in 8&lt;i&gt;x&lt;/i&gt;+1 cycles, where &lt;i&gt;x&lt;/i&gt; is the number of digits. This implementation uses a data stack.&lt;br /&gt;&lt;pre&gt;printd  mov.a  *stack,    {stack&lt;br /&gt;        div.a  #10,       }stack&lt;br /&gt;        mod.a  #10,       *stack&lt;br /&gt;        add.a  #48,       *stack&lt;br /&gt;        add    #1,        pcount&lt;br /&gt;        jmn.a  printd,    {stack&lt;br /&gt;        add.a  #1,        stack&lt;br /&gt;ploop   sts.a  }stack,    0&lt;br /&gt;pcount  djn    ploop,     #0&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1076952200605378213?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1076952200605378213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1076952200605378213&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1076952200605378213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1076952200605378213'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/12/write-number-implemented-using-data.html' title='Write Number (implemented using a data stack)'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1659010501884628597</id><published>2008-12-07T21:34:00.000Z</published><updated>2008-12-09T21:35:16.262Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='sts'/><category scheme='http://www.blogger.com/atom/ns#' term='hello world'/><category scheme='http://www.blogger.com/atom/ns#' term='output'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Hello World in Redcode</title><content type='html'>Here's the shortest "Hello, World!" program I could implement, written using the &lt;code&gt;sts&lt;/code&gt; opcode which is available in exMARS Streams.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;write   sts.a  hello,     0&lt;br /&gt;        sts.b  }write,    0&lt;br /&gt;        djn    write,     #7&lt;br /&gt;&lt;br /&gt;hello   dat    72,        101&lt;br /&gt;        dat    108,       108&lt;br /&gt;        dat    111,       44&lt;br /&gt;        dat    32,        87&lt;br /&gt;        dat    111,       114&lt;br /&gt;        dat    108,       100&lt;br /&gt;        dat    33,        10&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1659010501884628597?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1659010501884628597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1659010501884628597&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1659010501884628597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1659010501884628597'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/12/hello-world-in-redcode.html' title='Hello World in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-7746033481881194445</id><published>2008-11-19T20:00:00.006Z</published><updated>2008-11-19T20:00:00.919Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='nano'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='nanowarrior'/><title type='text'>nanoWarrior Issue 3</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://corewar.co.uk/nw/nw03.txt"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 256px; height: 192px;" src="http://1.bp.blogspot.com/_kDyMtZ_dJwQ/SSQNIu-YoEI/AAAAAAAAAf0/GtSgz9s2iQg/s400/nw03.jpg" border="0" alt="corewar | nanoWarrior 3" id="BLOGGER_PHOTO_ID_5270351907630129218" /&gt;&lt;/a&gt;The third issue of &lt;a href="http://corewar.co.uk/nw"&gt;nanoWarrior&lt;/a&gt; has just been published, thanks to the hard work of S. Fernandes and Germán Labarga.  In this issue:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Exploring the Dynamics of the Corewar Nano Hill&lt;/span&gt; looks how the balance of power has changed and examines the interaction between different strategies.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Paper/Clear on the Nano Hill&lt;/span&gt; by Germán Labarga investigates the history and effectiveness of paper on the nano hill.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Optimizing Ripples in Space-Time&lt;/span&gt; by S.Fernandes describes the optimization process of a successful nano paper.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Enjoy the issue.  Any feedback would be greatly appreciated.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-7746033481881194445?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/7746033481881194445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=7746033481881194445&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7746033481881194445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7746033481881194445'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/11/nanowarrior-issue-3.html' title='nanoWarrior Issue 3'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_kDyMtZ_dJwQ/SSQNIu-YoEI/AAAAAAAAAf0/GtSgz9s2iQg/s72-c/nw03.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-3045384781193281123</id><published>2008-11-11T21:37:00.010Z</published><updated>2008-11-12T06:31:22.678Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='competition'/><category scheme='http://www.blogger.com/atom/ns#' term='challenge'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Mini Challenge #7 - Results</title><content type='html'>Neo's Corewar Mini Challenge #7 is over and the results are in.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Mini Challenge #7 - Part 1&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In &lt;a href="http://impomatic.blogspot.com/2008/10/mini-challenge-7-harmless-overrun.html"&gt;part 1&lt;/a&gt;, 6 players discovered a 1 line solution with 100% ties. In all of the entered solutions, the imp overwrites the wimp and the wimp's process becomes an imp.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Roy van Rijn and Rashnok found the following solution:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;    mov.i #1, }1&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Neogryzor and S. Fernandes discovered the following:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;    mov }0, }1&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;And finally, Ilmari Karonen and I entered the following:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;    mov.i #1, *1&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Mini Challenge #7 - Part 2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In &lt;a href="http://impomatic.blogspot.com/2008/10/roys-modification-to-mini-challenge-7.html"&gt;part 2&lt;/a&gt;, 5 players found a 2 line, 1 process solution with 100% ties.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Ilmari Karonen was first to submit an optimal solution. Ilmari's imp stops when it reaches the wimp and the process enters the &lt;code&gt;DJN&lt;/code&gt; loop:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;    mov.i }0, *1&lt;br /&gt;    mov.i }1, *1&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Rashnok and I both found the following solution. Our imp overwrites the wimp and the wimp's process becomes an imp:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;imp mov.i #3,*-1&lt;br /&gt;    jmp imp,{0&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;I also entered a slight variation:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;    mov {2, }0&lt;br /&gt;imp mov.i #3,*-1&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;S. Fernandes discovered the following.  The imp's process enters the &lt;code&gt;DJN&lt;/code&gt; loop:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;imp mov.i #4, *1&lt;br /&gt;    djn.a imp, #0&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Finally Roy van Rijn used his evolver to discover 58 solutions! Here are &lt;a href="http://labarga.atspace.com/mc7/2liners.txt"&gt;Roy's 58 entries&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thanks to Neo for organising the challenge.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-3045384781193281123?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/3045384781193281123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=3045384781193281123&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3045384781193281123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3045384781193281123'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/11/mini-challenge-7-results.html' title='Mini Challenge #7 - Results'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2584211670779413513</id><published>2008-10-21T20:33:00.003+01:00</published><updated>2008-10-21T22:30:34.149+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='competition'/><category scheme='http://www.blogger.com/atom/ns#' term='challenge'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Roy's Modification to Mini Challenge #7</title><content type='html'>Roy suggested an interesting modification to Neo's Mini Challenge #7 in &lt;span class="Apple-style-span" style="font-style: italic;"&gt;rec.games.corewar&lt;/span&gt;. Create an imp capable of passing through the following code:&lt;br /&gt;&lt;pre&gt;djn.f #0, &gt;-5&lt;br /&gt;&lt;/pre&gt;The aim is to tie as often as possible.  Lines of code and the number of processes should be kept to a minimum.&lt;div&gt;&lt;ul&gt;&lt;li&gt;Newbies should aim for &gt;95% ties in 7 lines or less.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Intermediate redcoders should be able to discover a solution with 100% ties in 5 lines.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Corewar pros should aim for a solution with 100% ties in 4 lines or less!&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2584211670779413513?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2584211670779413513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2584211670779413513&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2584211670779413513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2584211670779413513'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/10/roys-modification-to-mini-challenge-7.html' title='Roy&apos;s Modification to Mini Challenge #7'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2715464903064117835</id><published>2008-10-17T16:44:00.001+01:00</published><updated>2008-11-11T23:00:45.153Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='competition'/><category scheme='http://www.blogger.com/atom/ns#' term='challenge'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Mini Challenge #7 - "Harmless Overrun"</title><content type='html'>Neo has proposed a mini challenge in which players have to create an imp capable of passing through a wimp with imp-gate.  Both warriors must survive the encounter.&lt;div&gt;&lt;pre&gt;jmp 0, &lt;-5 &lt;/pre&gt;&lt;/div&gt;&lt;div&gt;For more details, see the &lt;a href="http://labarga.atspace.com/mc7.html"&gt;mini challenge homepage&lt;/a&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2715464903064117835?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2715464903064117835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2715464903064117835&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2715464903064117835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2715464903064117835'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/10/mini-challenge-7-harmless-overrun.html' title='Mini Challenge #7 - &quot;Harmless Overrun&quot;'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-754107256911501368</id><published>2008-10-11T21:26:00.008+01:00</published><updated>2008-10-11T21:56:02.106+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='semaphore'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>More Semaphores in Redcode</title><content type='html'>While not as elegant as the solution found by Neo and Roy, the following has the advantage of only requiring one DAT.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;semaphore: dat    1&lt;br /&gt;        ....&lt;br /&gt;reset:     mul.ab semaphore, semaphore&lt;br /&gt;wait:      djn    reset,     semaphore&lt;br /&gt;           mov.a  #0,        semaphore&lt;br /&gt;        ....&lt;br /&gt;signal:    mov    #1,        }sema&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The second technique kills waiting processes, then respawns them when signaled.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;semaphore: dat    1&lt;br /&gt;        ....&lt;br /&gt;kill:      dat    0&lt;br /&gt;        ....&lt;br /&gt;wait:      djn    kill,      semaphore&lt;br /&gt;next:&lt;br /&gt;        ....&lt;br /&gt;signal:    mov.a  #1,        semaphore&lt;br /&gt;           add.x  semaphore, semaphore&lt;br /&gt;           seq.a  #1,        semaphore&lt;br /&gt;           spl    next&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-754107256911501368?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/754107256911501368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=754107256911501368&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/754107256911501368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/754107256911501368'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/10/more-semaphores-in-redcode.html' title='More Semaphores in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2818543789085999976</id><published>2008-09-29T20:43:00.007+01:00</published><updated>2008-09-29T20:56:05.126+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='semaphore'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Semaphores in Redcode</title><content type='html'>&lt;div&gt;I'm looking for suggestions on how to code busy-waiting semaphores in Redcode.  The lack of an atomic test-and-set operation complicates matters.&lt;/div&gt;&lt;div&gt;The code below works for up to three processes, but under certain circumstances can fail with four processes.  The entry points are wait and signal.&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;semaphore: dat 1&lt;br /&gt;        ....&lt;br /&gt;fail:      add #1,   semaphore&lt;br /&gt;wait:      djn fail, semaphore&lt;br /&gt;        .....&lt;br /&gt;signal:    add #1,   semaphore&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div&gt;If you have any suggestions, please let me know in the comments below.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2818543789085999976?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2818543789085999976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2818543789085999976&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2818543789085999976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2818543789085999976'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/09/semaphores-in-redcode.html' title='Semaphores in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-3637596869712141434</id><published>2008-07-01T09:39:00.003+01:00</published><updated>2008-07-01T10:01:19.311+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='warrior'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Replicate - My First Corewar Warrior</title><content type='html'>I've been searching through some ancient printouts recently and discovered my first ever Corewar program.  I remember testing this on Stefan Strack's CoreWar Pro.  I didn't have a clue whether or not it was any good, but at least it seemed to work!  Can you remember your first warrior?&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;; -+REPLICATE+-&lt;br /&gt;; *JAM* 1997&lt;br /&gt;mov    7,    8&lt;br /&gt;add    6,    6&lt;br /&gt;mov   #8,   -3&lt;br /&gt;mov  @-4,   &lt;5&lt;br /&gt;djn   -1,   -5&lt;br /&gt;spl   -5&lt;br /&gt;jmp   @2&lt;br /&gt;dat  -10&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-3637596869712141434?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/3637596869712141434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=3637596869712141434&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3637596869712141434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3637596869712141434'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/07/replicate-my-first-corewar-warrior.html' title='Replicate - My First Corewar Warrior'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-4578095918889151265</id><published>2008-05-31T13:16:00.010+01:00</published><updated>2010-07-15T19:31:19.173+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='quick-scan'/><category scheme='http://www.blogger.com/atom/ns#' term='qscan'/><category scheme='http://www.blogger.com/atom/ns#' term='corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>An Improved '88 Quick-scanner</title><content type='html'>After reading how Paul Kline's &lt;a href="http://users.obs.carnegiescience.edu/birk/COREWAR/94/HILL/slowQscan.red"&gt;slowQscan&lt;/a&gt; achieves extra scans, I wondered how well a similar technique would work in '88 Standard Redcode. Previously published '88 quick-scanners include:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://users.obs.carnegiescience.edu/birk/COREWAR/88/HILL/quicksilver88.red"&gt;Quicksilver '88&lt;/a&gt; - 24 scans in 36 instuctions&lt;/li&gt;&lt;li&gt;&lt;a href="http://users.obs.carnegiescience.edu/birk/COREWAR/88/HILL/vala.red"&gt;Vala&lt;/a&gt; - 30 scans in 45 instuctions&lt;/li&gt;&lt;li&gt;&lt;a href="http://users.obs.carnegiescience.edu/birk/COREWAR/88/HILL/matreshka.red"&gt;Matreshka Rulez!&lt;/a&gt; - 37 scans in 56 instructions&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Using Kline's technique 36 scans are possible in 48 instructions:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;qfirst equ (qp2+2*qstep)&lt;br /&gt;qdist  equ qfirst+111&lt;br /&gt;qstep  equ 222&lt;br /&gt;&lt;br /&gt;qi  equ 7                       &lt;br /&gt;qr  equ 7&lt;br /&gt;&lt;br /&gt;qbomb   dat &amp;lt;qi/2-qi*qr,   &amp;lt;qi*qr-qi/2&lt;br /&gt;&lt;br /&gt;qa  equ qstep*16&lt;br /&gt;qb  equ qstep*5+2&lt;br /&gt;qc  equ qstep*10&lt;br /&gt;qd  equ qstep*2&lt;br /&gt;qe  equ qstep*1&lt;br /&gt;&lt;br /&gt;qgo     cmp qdist+qc,      qfirst+qc&lt;br /&gt;jmp qfast,         &amp;lt;qa&lt;br /&gt;cmp qdist+qe+qd,   qfirst+qe+qd&lt;br /&gt;qp1     jmp &amp;lt;qfast,        &amp;lt;qc&lt;br /&gt;qp2     cmp qdist,         qfirst&lt;br /&gt;qp3     jmp qskip,         &amp;lt;qe&lt;br /&gt;&lt;br /&gt;cmp qdist+qb,      qfirst+qb&lt;br /&gt;q1      djn qfast,         #qp1&lt;br /&gt;&lt;br /&gt;cmp qdist+qd+qc,   qfirst+qd+qc&lt;br /&gt;jmp qslow,         &amp;lt;qfirst+qd+qc+4&lt;br /&gt;cmp qdist+qd+qb,   qfirst+qd+qb&lt;br /&gt;x1      jmp qslow,         &amp;lt;q1&lt;br /&gt;cmp qdist+qc+qc,   qfirst+qc+qc&lt;br /&gt;q2      djn qslow,         #qp2&lt;br /&gt;cmp qdist+qd,      qfirst+qd&lt;br /&gt;jmp qslow,         &amp;lt;qfast&lt;br /&gt;cmp qdist+qa,      qfirst+qa&lt;br /&gt;jmp q1,            &amp;lt;q1&lt;br /&gt;&lt;br /&gt;cmp qdist+qa+qd,   qfirst+qa+qd&lt;br /&gt;jmp x1,            &amp;lt;q1&lt;br /&gt;cmp qdist+qc+qb,   qfirst+qc+qb&lt;br /&gt;jmp q2,            &amp;lt;q1&lt;br /&gt;cmp qdist+qe+qd+qc,qfirst+qe+qd+qc&lt;br /&gt;jmp qslower,       &amp;lt;qfirst+qe+qd+qc+4&lt;br /&gt;cmp qdist+qe+qd+qb,qfirst+qe+qd+qb&lt;br /&gt;jmp qslower,       &amp;lt;q1&lt;br /&gt;cmp qdist+qe+qc+qc,qfirst+qe+qc+qc&lt;br /&gt;jmp qslower,       &amp;lt;q2&lt;br /&gt;cmp qdist+qd+qd+qc,qfirst+qd+qd+qc&lt;br /&gt;q3      djn qslower,       #qp3&lt;br /&gt;cmp qdist+qe+qc,   qfirst+qe+qc&lt;br /&gt;jmp &amp;lt;qfast,        &amp;lt;q2&lt;br /&gt;cmp qdist+qd+qd,   qfirst+qd+qd&lt;br /&gt;jmp &amp;lt;qfast,        &amp;lt;q3&lt;br /&gt;cmp qdist+qd+qd+qb,qfirst+qd+qd+qb&lt;br /&gt;slt &amp;lt;q3,           &amp;lt;q1&lt;br /&gt;&lt;br /&gt;jmz pgo,           qdist+qe+qd+qc+10&lt;br /&gt;&lt;br /&gt;qslower add @q3,           @qslow&lt;br /&gt;qslow   add @q2,           qkil&lt;br /&gt;qfast   add @q1,           @qslow&lt;br /&gt;&lt;br /&gt;qskip   cmp &amp;lt;qdist+qstep+50, @qkil&lt;br /&gt;jmp qloop,         &amp;lt;1234&lt;br /&gt;&lt;br /&gt;add #qdist-qfirst, qkil&lt;br /&gt;qloop   mov qbomb,         @qkil&lt;br /&gt;qkil    mov &amp;lt;qfirst+qstep+50, &amp;lt;qfirst&lt;br /&gt;sub #qi,           @qloop&lt;br /&gt;djn qloop,         #qr+2&lt;br /&gt;&lt;br /&gt;pgo&lt;br /&gt;end qgo&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-4578095918889151265?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/4578095918889151265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=4578095918889151265&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4578095918889151265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4578095918889151265'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/05/improved-88-quickscanner.html' title='An Improved &apos;88 Quick-scanner'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-8839538734623498387</id><published>2008-05-14T02:45:00.002+01:00</published><updated>2008-05-31T13:31:04.813+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='power'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>x^n (mod CORESIZE) in Redcode</title><content type='html'>The following code implements the binary method to calculate &lt;span style="font-style: italic;"&gt;x&lt;/span&gt;^&lt;span style="font-style: italic;"&gt;n&lt;/span&gt; (mod CORESIZE) in Redcode.  For calculations with &lt;span style="font-style: italic;"&gt;n&lt;/span&gt; &gt; 13, the binary method out-performs a simple loop.&lt;br /&gt;&lt;pre&gt;power     mov    #1,             _powerr&lt;br /&gt;_powloop  mov.b  _powern,        temp&lt;br /&gt;           mod    #2,             temp&lt;br /&gt;           seq.b  temp,           #0&lt;br /&gt;           mul.b  _powerx,        _powerr&lt;br /&gt;           mul.b  _powerx,        _powerx&lt;br /&gt;           div    #2,             _powern&lt;br /&gt;           jmn    _powloop,       _powern&lt;br /&gt;&lt;br /&gt;_powern   dat    n&lt;br /&gt;_powerx   dat    x&lt;br /&gt;_powerr   dat    1&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-8839538734623498387?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/8839538734623498387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=8839538734623498387&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8839538734623498387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8839538734623498387'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/05/xn-mod-coresize-in-redcode.html' title='x^n (mod CORESIZE) in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2742762863220240651</id><published>2008-04-28T22:28:00.008+01:00</published><updated>2008-04-29T17:36:05.335+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='logarithmic search'/><category scheme='http://www.blogger.com/atom/ns#' term='search'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='binary search'/><title type='text'>Binary Search in Redcode</title><content type='html'>Binary search is an algorithm to find a value in a sorted list. Binary search finds the center element of the list and compares it to the target value.&lt;br /&gt;&lt;br /&gt;If the target value is higher than the value of the center element, all elements below the center element can be eliminated from the search. Otherwise, all elements above the center element can be eliminated.&lt;br /&gt;&lt;br /&gt;The search is then repeated on the remaining elements. In this way, binary search reduces the search space by 50% on each iteration. In Redcode, binary search is more efficient than &lt;a href="http://impomatic.blogspot.com/2008/04/linear-search.html"&gt;linear search&lt;/a&gt; for lists of 38 or more elements.&lt;br /&gt;&lt;br /&gt;The input parameters required are as follows:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;size - the number of elements&lt;/li&gt;&lt;li&gt;bot - a pointer to the top of the sequence&lt;/li&gt;&lt;li&gt;find - the target value to find&lt;/li&gt;&lt;/ul&gt;A pointer to the required element is returned in ptr.&lt;br /&gt;&lt;pre&gt;          nop    &amp;lt;bot,           &amp;gt;size&lt;br /&gt;_bsnext   mov.b  size,           ptr&lt;br /&gt;          div    #2,             ptr&lt;br /&gt;          jmn    _bscont,        ptr&lt;br /&gt;&lt;br /&gt;          mov.b  bot,            ptr&lt;br /&gt;          jmp    notfound,       &amp;gt;ptr&lt;br /&gt;&lt;br /&gt;_bscont   add.b  bot,            ptr&lt;br /&gt;          slt    @ptr,           find&lt;br /&gt;          jmp    _bstopadj&lt;br /&gt;&lt;br /&gt;          add.b  bot,            size&lt;br /&gt;          sub.b  ptr,            size&lt;br /&gt;          mov.b  ptr,            bot&lt;br /&gt;          jmp    _bsnext&lt;br /&gt;&lt;br /&gt;_bstopadj sne.b  @ptr,           find&lt;br /&gt;          jmp    found&lt;br /&gt;&lt;br /&gt;          div    #2,             size&lt;br /&gt;          jmp    _bsnext&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2742762863220240651?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2742762863220240651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2742762863220240651&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2742762863220240651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2742762863220240651'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/04/binary-search-in-redcode.html' title='Binary Search in Redcode'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1585222377943446138</id><published>2008-04-20T19:22:00.000+01:00</published><updated>2008-04-20T19:46:19.050+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sts'/><category scheme='http://www.blogger.com/atom/ns#' term='output'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Write Number</title><content type='html'>Here's a short iterative routine to write a number to standard out. Although longer than the recursive algorithm, it avoids the need to maintain a data / return stack. 9&lt;span style="font-style: italic;"&gt;x&lt;/span&gt;+1 cycles are required, where &lt;span style="font-style: italic;"&gt;x&lt;/span&gt; is the number of digits.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family: courier new;"&gt;sts&lt;/span&gt; opcode is available in exMARS Streams.&lt;br /&gt;&lt;pre&gt;writedec  mov    number,         temp&lt;br /&gt;          jmp    _wdloop+1,      &amp;gt;_wdloop&lt;br /&gt;&lt;br /&gt;_wdloop   mul    #10,            #0&lt;br /&gt;          div    #10,            temp&lt;br /&gt;          jmn    _wdloop,        temp&lt;br /&gt;&lt;br /&gt;_wdprint  mov    number,         temp&lt;br /&gt;          div.b  _wdloop,        temp&lt;br /&gt;          add    #48,            temp&lt;br /&gt;          sts    temp,           0&lt;br /&gt;          mod.b  _wdloop,        number&lt;br /&gt;          div    #10,            _wdloop&lt;br /&gt;          jmn    _wdprint,       _wdloop&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1585222377943446138?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1585222377943446138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1585222377943446138&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1585222377943446138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1585222377943446138'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/04/write-number.html' title='Write Number'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-631239779414386962</id><published>2008-04-12T03:56:00.000+01:00</published><updated>2008-04-21T21:16:16.811+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sign'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Sign v2</title><content type='html'>Shortly after publishing a &lt;a href="http://impomatic.blogspot.com/2008/03/sign.html"&gt;five line snippet&lt;/a&gt; to return the sign of the input value, &lt;a href="http://www.redcode.nl"&gt;Roy van Rijn&lt;/a&gt; commented with the following improvement.&lt;br /&gt;&lt;br /&gt;As with the original, Roy's code calculates the sign of &lt;em&gt;location&lt;/em&gt;'s b-field, returning -1, 0 or 1.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;sign      jmz.b  done,           location&lt;br /&gt;          div    #1+CORESIZE/2,  location&lt;br /&gt;          mul.ab #-2,            location&lt;br /&gt;          nop    &amp;gt;location&lt;br /&gt;done&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-631239779414386962?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/631239779414386962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=631239779414386962&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/631239779414386962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/631239779414386962'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/04/sign-v2.html' title='Sign v2'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2915777513752123942</id><published>2008-04-03T02:27:00.003+01:00</published><updated>2008-04-29T17:40:49.283+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linear search'/><category scheme='http://www.blogger.com/atom/ns#' term='search'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Linear Search</title><content type='html'>This short snippet of code performs a linear search on a sorted list.  The average time to find a value in a sequence of &lt;span style="font-style: italic;"&gt;x&lt;/span&gt; cells is &lt;span style="font-style: italic;"&gt;x&lt;/span&gt;+3 cycles.  This outperforms &lt;a href="http://impomatic.blogspot.com/2008/04/binary-search-in-redcode.html"&gt;binary search&lt;/a&gt; on sequences up to 38 cells.&lt;br /&gt;&lt;br /&gt;If the required values isn't in the sequence, a pointer to the first higher value is returned.&lt;br /&gt;&lt;pre&gt;lsearch   slt    &amp;gt;ptr,           find&lt;br /&gt;          jmp    _lsdone&lt;br /&gt;          djn    lsearch,        #length&lt;br /&gt;          jmp    notfound&lt;br /&gt;&lt;br /&gt;_lsdone   sne    find,           &amp;lt;ptr&lt;br /&gt;          jmp    found&lt;br /&gt;          jmp    notfound&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2915777513752123942?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2915777513752123942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2915777513752123942&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2915777513752123942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2915777513752123942'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/04/linear-search.html' title='Linear Search'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-5175530759158128844</id><published>2008-03-19T09:03:00.000Z</published><updated>2008-04-21T20:42:25.068+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lagged fibonacci'/><category scheme='http://www.blogger.com/atom/ns#' term='pseudo-random'/><category scheme='http://www.blogger.com/atom/ns#' term='random'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Lagged Fibonacci Pseudo-Random Generator</title><content type='html'>If you need a pseudo-random number generator which works regardless of the coresize, a Lagged Fibonacci generator is one of the better options.&lt;br /&gt;&lt;br /&gt;Here's an implementation in 3 instructions with _rndj fixed at 1. _rndk can take the values 3, 4, 6, 7, 15, 22, 60 or 63 depending on the period required. With _rndk = 4 and coresize 8000, the period is 31200.&lt;br /&gt;&lt;br /&gt;For more variations, see the Wikipedia article on &lt;a href="http://en.wikipedia.org/wiki/Lagged_Fibonacci_generator"&gt;Lagged Fibonacci generators&lt;/a&gt;.&lt;br /&gt;&lt;pre&gt;           _rndk  equ 4&lt;br /&gt;&lt;br /&gt;random    mov.a  &amp;gt;rdata,        random_out&lt;br /&gt;          mod.ab #_rndk,        rdata&lt;br /&gt;          add.a  *stack,        @rdata&lt;br /&gt;&lt;br /&gt;rdata     dat    3711,           0&lt;br /&gt;          dat    1674,           0&lt;br /&gt;          dat    4323,           0&lt;br /&gt;          dat    7835,           0&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-5175530759158128844?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/5175530759158128844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=5175530759158128844&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/5175530759158128844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/5175530759158128844'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/03/lagged-fibonacci-pseudo-random.html' title='Lagged Fibonacci Pseudo-Random Generator'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1490212035708109123</id><published>2008-03-08T17:43:00.000Z</published><updated>2008-03-31T06:26:26.425+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sign'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Sign</title><content type='html'>Calculates the sign of &lt;em&gt;location&lt;/em&gt;'s b-field, returning -1, 0 or 1.&lt;br /&gt;&lt;pre&gt;sign      jmz.b  done,           location&lt;br /&gt;          slt.b  location,       #1+CORESIZE/2&lt;br /&gt;          mov.ab #-1,            location&lt;br /&gt;          seq.ab #-1,            location&lt;br /&gt;          mov.ab #1,             location&lt;br /&gt;done&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1490212035708109123?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1490212035708109123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1490212035708109123&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1490212035708109123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1490212035708109123'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/03/sign.html' title='Sign'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-5096684929544285380</id><published>2008-03-08T06:12:00.000Z</published><updated>2008-03-31T06:19:01.992+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='abs'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Absolute Value</title><content type='html'>This two-line redcode snippet returns the absolute value of &lt;em&gt;location&lt;/em&gt;'s b-field.&lt;br /&gt;&lt;pre&gt;abs       slt.b  location,       #1+CORESIZE/2&lt;br /&gt;          mul.ab #-1,            location&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-5096684929544285380?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/5096684929544285380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=5096684929544285380&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/5096684929544285380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/5096684929544285380'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/03/absolute-value.html' title='Absolute Value'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-5333450976013158816</id><published>2008-03-04T16:29:00.000Z</published><updated>2008-03-07T19:30:29.157Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='euclid'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><title type='text'>Euclid's extended</title><content type='html'>The extended Euclidean algorithm is used to calculate &lt;span style="font-style: italic;"&gt;x&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;y&lt;/span&gt; given &lt;span style="font-style: italic;"&gt;a&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;b&lt;/span&gt; in the following equation:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ax&lt;/span&gt; + &lt;span style="font-style: italic;"&gt;by&lt;/span&gt; = gcd(&lt;span style="font-style: italic;"&gt;a&lt;/span&gt;,&lt;span style="font-style: italic;"&gt;b&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          org    start&lt;br /&gt;&lt;br /&gt;          temp   equ r-1&lt;br /&gt;&lt;br /&gt;r         dat    55,            89 ; input a b - output gcd(a,b)&lt;br /&gt;s         dat    1,             0&lt;br /&gt;t         dat    0,             1  ; output x y&lt;br /&gt;&lt;br /&gt;euclidext mov    r,             temp&lt;br /&gt;          div.ab temp,          temp&lt;br /&gt;          mov.ba temp,          temp&lt;br /&gt;          mul    s,             temp&lt;br /&gt;          sub    temp,          t&lt;br /&gt;&lt;br /&gt;          mov    s,             temp&lt;br /&gt;          mov    t,             s&lt;br /&gt;          mov    temp,          t&lt;br /&gt;&lt;br /&gt;          mod.ab r,             r&lt;br /&gt;          mov.x  r,             r&lt;br /&gt;start     jmn.a  euclidext,     r&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-5333450976013158816?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/5333450976013158816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=5333450976013158816&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/5333450976013158816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/5333450976013158816'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/03/euclids-extended.html' title='Euclid&apos;s extended'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2664067477235979786</id><published>2008-02-27T21:54:00.000Z</published><updated>2008-03-07T22:15:51.801Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='selection sort'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><title type='text'>selection sort</title><content type='html'>Selection sort in an algorithm which sorts a sequence of elements. The smallest element is removed from the sequence and added to the end of a new sorted sequence. This continues until all elements have been moved to the new sequence.&lt;br /&gt;&lt;br /&gt;Selection sort is an O(n²) algorithm. The redcode implemention is 10 instructions long and requires 1.5n²+5.5n-8 cycles in the worst case, making it approximately twice as fast as &lt;a href="http://impomatic.blogspot.com/2008/02/bubble-sort.html"&gt;Bubble Sort&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          org    outer+1&lt;br /&gt;&lt;br /&gt;          temp   equ (outer-1)&lt;br /&gt;&lt;br /&gt;outer     mov.b  x,              y&lt;br /&gt;          mov    &amp;lt;p,             temp&lt;br /&gt;p         mov.ba #FIRST+LENGTH-1,#FIRST+LENGTH&lt;br /&gt;inner     slt    &amp;lt;p,             *p&lt;br /&gt;          mov.ba p,              p&lt;br /&gt;y         djn    inner,          #LENGTH-1&lt;br /&gt;          add.b  x,              p&lt;br /&gt;          mov    *p,             @p&lt;br /&gt;          mov    temp,           *p&lt;br /&gt;x         djn    outer,          #LENGTH-1&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2664067477235979786?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2664067477235979786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2664067477235979786&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2664067477235979786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2664067477235979786'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/02/selection-sort.html' title='selection sort'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-4829438188973544656</id><published>2008-02-25T04:36:00.000Z</published><updated>2008-03-05T16:28:35.486Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='bubble sort'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><title type='text'>Bubble sort</title><content type='html'>Bubble sort is an O(n²) algorithm to sort a sequence of elements into order.  Ilmari Karonen's &lt;a href="http://vyznev.net/corewar/planar/BubblySort1b.red"&gt;Bubbly Sort 1b&lt;/a&gt; is a 10 line implementation of Bubble sort which requires 3.5n²-0.5n-4 cycles in the worst case.&lt;br /&gt;&lt;br /&gt;My alternative code is shown below:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          org    inner&lt;br /&gt;&lt;br /&gt;          temp   equ (outer-1)&lt;br /&gt;&lt;br /&gt;outer     mov.b  x,              y&lt;br /&gt;          mov.f  q,              p&lt;br /&gt;&lt;br /&gt;inner     slt    {p,             &amp;lt;p&lt;br /&gt;y         djn    inner,          #LENGTH-1&lt;br /&gt;          jmz    next,           y&lt;br /&gt;&lt;br /&gt;          mov    @p,             temp&lt;br /&gt;p         mov    FIRST+LENGTH,   FIRST+LENGTH-1&lt;br /&gt;          mov    temp,           *p&lt;br /&gt;          djn    inner,          y&lt;br /&gt;x&lt;br /&gt;next      djn    outer,          #LENGTH-1&lt;br /&gt;&lt;br /&gt;q         dat    FIRST+LENGTH-p, FIRST+LENGTH-p-1&lt;br /&gt;&lt;/pre&gt;This alternative implementation runs slightly faster than Ilmari's, at the cost of 1 extra line of code.  The number of cycles in the worst case is 3n²-5, which also beats &lt;a href="http://impomatic.blogspot.com/2008/01/gnome-sort.html"&gt;Gnome sort&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-4829438188973544656?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/4829438188973544656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=4829438188973544656&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4829438188973544656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4829438188973544656'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/02/bubble-sort.html' title='Bubble sort'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-1202841851216275673</id><published>2008-02-19T01:56:00.000Z</published><updated>2008-03-08T21:44:14.231Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='comb sort'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><category scheme='http://www.blogger.com/atom/ns#' term='Dobosiewicz sort'/><title type='text'>Comb sort</title><content type='html'>Comb sort (also known as Dobosiewicz sort) makes a number of passes through a sequence of elements, exchanging any elements which are out of order.  With each pass the distance between compared elements decreases.  The algorithm terminates when all elements are in order.&lt;br /&gt;&lt;br /&gt;In the redcode implementation, the value of the temp element is used as a flag to determine whether or not any exchanges occurred in the last pass.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          ra     equ 4&lt;br /&gt;          rb     equ 5&lt;br /&gt;&lt;br /&gt;          org    inner&lt;br /&gt;&lt;br /&gt;          temp   equ (outer-1)&lt;br /&gt;&lt;br /&gt;outer     mov    #LENGTH,        y&lt;br /&gt;          sub.b  gap,            y&lt;br /&gt;          mov.f  q,              p&lt;br /&gt;          sub.b  gap,            p&lt;br /&gt;          sub    temp,           temp&lt;br /&gt;&lt;br /&gt;inner     slt    {p,             &amp;lt;p&lt;br /&gt;y         djn    inner,          #LENGTH-(LENGTH*ra/rb)&lt;br /&gt;          jmz    done,           y&lt;br /&gt;&lt;br /&gt;          mov    @p,             temp&lt;br /&gt;p         mov    FIRST+LENGTH,   FIRST+LENGTH-(LENGTH*ra/rb)&lt;br /&gt;          mov    temp,           *p&lt;br /&gt;          djn    inner,          y&lt;br /&gt;&lt;br /&gt;done      mul    #ra,            gap&lt;br /&gt;gap       div    #rb,            #(LENGTH*ra/rb)&lt;br /&gt;&lt;br /&gt;          jmn    outer,          gap&lt;br /&gt;          nop    &amp;gt;gap,           {outer&lt;br /&gt;          jmn    outer,          temp&lt;br /&gt;&lt;br /&gt;q         dat    FIRST+LENGTH-p, FIRST+LENGTH-p&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-1202841851216275673?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/1202841851216275673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=1202841851216275673&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1202841851216275673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/1202841851216275673'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/02/comb-sort.html' title='Comb sort'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-8395394527900829174</id><published>2008-02-12T15:58:00.000Z</published><updated>2008-03-11T09:39:03.936Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='quicksort'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><title type='text'>Quicksort</title><content type='html'>Quicksort is an algorithm developed by C. A. R. Hoare in 1960 to sort a sequence of elements into order.  Quicksort works by dividing a sequence into two sub-sequences.&lt;br /&gt;&lt;br /&gt;An element is selected from the sequence and called the pivot.  The sequence is then re-arranged so all elements with a value less than the pivot are before the pivot and all elements with a greater value are after it.&lt;br /&gt;&lt;br /&gt;The sub-sequences before and after the pivot are then recursively sorted.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          org    qsort&lt;br /&gt;&lt;br /&gt;          stack  equ outer-2&lt;br /&gt;          pivot  equ outer-1&lt;br /&gt;&lt;br /&gt;outer     mov    p,              &amp;lt;stack&lt;br /&gt;          mov    {p,             pivot&lt;br /&gt;&lt;br /&gt;inner     slt    pivot,          &amp;gt;p&lt;br /&gt;y         djn    inner,          #LENGTH-1&lt;br /&gt;          jmz    done,           y&lt;br /&gt;          mov    &amp;lt;p,             *p&lt;br /&gt;          mov    {p,             @p&lt;br /&gt;          djn    inner,          y&lt;br /&gt;&lt;br /&gt;done      mov.a  @stack,         p&lt;br /&gt;          mov.ba p,              @stack&lt;br /&gt;          mov    pivot,          &amp;gt;p&lt;br /&gt;&lt;br /&gt;qsort     mov.ab p,              y&lt;br /&gt;          sub.b  p,              y&lt;br /&gt;&lt;br /&gt;          slt    y,              #2&lt;br /&gt;          jmp    outer,          &amp;lt;y&lt;br /&gt;&lt;br /&gt;          mov.f  &amp;gt;stack,         p&lt;br /&gt;          jmn    qsort,          p&lt;br /&gt;&lt;br /&gt;p         dat    FIRST+LENGTH,   FIRST&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-8395394527900829174?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/8395394527900829174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=8395394527900829174&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8395394527900829174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8395394527900829174'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/02/quicksort.html' title='Quicksort'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-3460975121728052061</id><published>2008-01-31T21:28:00.000Z</published><updated>2008-03-07T22:11:41.608Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='stooge sort'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><title type='text'>stooge sort</title><content type='html'>Stooge sort is discussed in Cormen, Leiserson, Rivest and Stein's &lt;span style="font-style: italic;"&gt;Introduction to Algorithms&lt;/span&gt;. Wikipedia's article on &lt;a href="http://en.wikipedia.org/wiki/Stooge_sort"&gt;Stooge sort&lt;/a&gt; describes the algorithm as follows:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If the value at the end is smaller than the value at the start, swap them.&lt;/li&gt;&lt;li&gt;If there are 3 or more elements in the current list subset, &lt;ul&gt;&lt;li&gt;Stooge sort the initial 2/3 of the list&lt;/li&gt;&lt;li&gt;Stooge sort the final 2/3 of the list&lt;/li&gt;&lt;li&gt;Stooge sort the initial 2/3 of the list again&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;/ul&gt;Stooge sort is extremely inefficient. For example, sorting 100 elements requires in the region of 2.4 million cycles compared to around 3500 for quicksort and 8000 for insertion sort.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          org    inner&lt;br /&gt;&lt;br /&gt;          stack  equ outer-2&lt;br /&gt;          temp   equ outer-1&lt;br /&gt;&lt;br /&gt;outer     mov    p,              &amp;lt;stack&lt;br /&gt;          sub.ba temp,           @stack&lt;br /&gt;          mov    p,              &amp;lt;stack&lt;br /&gt;          add.b  temp,           @stack&lt;br /&gt;          sub.ba temp,           p&lt;br /&gt;inner     slt    {p,             @p&lt;br /&gt;          jmp    noexch,         }p&lt;br /&gt;&lt;br /&gt;          mov    @p,             temp&lt;br /&gt;p         mov    FIRST+LENGTH,   FIRST&lt;br /&gt;          mov    temp,           }p&lt;br /&gt;&lt;br /&gt;noexch    mov.ab p,              temp&lt;br /&gt;          sub.b  p,              temp&lt;br /&gt;          div    #3,             temp&lt;br /&gt;          jmn    outer,          temp&lt;br /&gt;&lt;br /&gt;finished  mov.f  &amp;gt;stack,         p&lt;br /&gt;          jmn    inner,          p&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-3460975121728052061?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/3460975121728052061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=3460975121728052061&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3460975121728052061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/3460975121728052061'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/01/stooge-sort.html' title='stooge sort'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-7030124974628891210</id><published>2008-01-20T20:07:00.000Z</published><updated>2008-03-08T20:37:03.597Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><category scheme='http://www.blogger.com/atom/ns#' term='insertion sort'/><title type='text'>insertion sort</title><content type='html'>Insertion sort is an algorithm to arrange a sequence of elements into order. Elements are removed one by one from the unsorted sequence and inserted into the correct position in a new, sorted sequence.&lt;br /&gt;&lt;br /&gt;For the worst case the Redcode Insertion sort requires 1.5n²+5.5n-7 cycles to sort n elements.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          org    outer&lt;br /&gt;&lt;br /&gt;          temp   equ (outer-1)&lt;br /&gt;&lt;br /&gt;outer     nop    }z,             {q&lt;br /&gt;z         mov    #0,             y&lt;br /&gt;q         mov.a  #FIRST+LENGTH-p,p&lt;br /&gt;p         mov    #0,             #0&lt;br /&gt;          mov    {p,             temp&lt;br /&gt;inner     slt    @p,             temp&lt;br /&gt;          jmp    found&lt;br /&gt;          mov    &amp;gt;p,             }p&lt;br /&gt;y         djn    inner,          #0&lt;br /&gt;found     mov    temp,           *p&lt;br /&gt;          djn    outer,          #LENGTH-1&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-7030124974628891210?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/7030124974628891210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=7030124974628891210&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7030124974628891210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/7030124974628891210'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/01/insertion-sort.html' title='insertion sort'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-5959645683613933382</id><published>2008-01-16T06:04:00.000Z</published><updated>2008-03-05T15:29:58.336Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='gnome sort'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><title type='text'>gnome sort</title><content type='html'>Gnome sort is a compact O(n²) algorithm to re-arrange a sequence of elements into order.  In his article on &lt;a href="http://www.cs.vu.nl/%7Edick/gnomesort.html"&gt;Gnome sort&lt;/a&gt;, Dick Grune describes the algorithm as follows:&lt;br /&gt;&lt;blockquote&gt; Gnome Sort is based on the technique used by the standard Dutch Garden Gnome (Du.: tuinkabouter). Here is how a garden gnome sorts a line of flower pots. Basically, he looks at the flower pot next to him and the previous one; if they are in the right order he steps one pot forward, otherwise he swaps them and steps one pot backwards. Boundary conditions: if there is no previous pot, he steps forwards; if there is no pot next to him, he is done.&lt;br /&gt;&lt;/blockquote&gt;The &lt;a href="http://en.wikipedia.org/wiki/Gnome_sort"&gt;Gnome sort&lt;/a&gt; article on Wikipedia describes a slightly modified algorithm.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          org    inner&lt;br /&gt;&lt;br /&gt;          temp   equ (outer-1)&lt;br /&gt;&lt;br /&gt;outer     mov    }p,             temp&lt;br /&gt;p         mov    FIRST+LENGTH-1, {p&lt;br /&gt;          nop    &amp;gt;y,             }p&lt;br /&gt;          mov    temp,           }p&lt;br /&gt;          sne    y,              #LENGTH&lt;br /&gt;          nop    &amp;lt;y,             {p&lt;br /&gt;inner     slt    *p,             {p&lt;br /&gt;y         djn    inner,          #LENGTH-1&lt;br /&gt;          jmn    outer,          y&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The redcode implementation is just 9 lines long, and requires 4.5n²-3.5n cycles to sort the sequence in the worse case.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-5959645683613933382?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/5959645683613933382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=5959645683613933382&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/5959645683613933382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/5959645683613933382'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/01/gnome-sort.html' title='gnome sort'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-2253272217436325312</id><published>2008-01-07T22:07:00.000Z</published><updated>2008-03-06T22:57:59.060Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='euclid'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='gcd'/><title type='text'>Euclid's algorithm</title><content type='html'>Euclid's algorithm is used to determine the Greatest Common Divisor of two values.  Despite it's simplicity, the only previous redcode implementation I can find is broken.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Implementation in Redcode:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;          org    euclid+2&lt;br /&gt;&lt;br /&gt;euclid    mod.ab #a,                #b&lt;br /&gt;          mov.x  euclid,            euclid&lt;br /&gt;          jmn.a  euclid,            euclid&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-2253272217436325312?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/2253272217436325312/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=2253272217436325312&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2253272217436325312'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/2253272217436325312'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/01/euclids-algorithm.html' title='Euclid&apos;s algorithm'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-8730912257312723683</id><published>2008-01-05T22:59:00.000Z</published><updated>2008-03-05T23:06:57.160Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='parallel processes'/><category scheme='http://www.blogger.com/atom/ns#' term='redcode'/><category scheme='http://www.blogger.com/atom/ns#' term='macro'/><title type='text'>parallel processes</title><content type='html'>This macro uses the preprocessor to generate Redcode which creates a given number of parallel processes.&lt;br /&gt;&lt;pre&gt;processes equ 100 ; works for 1 to 1048576&lt;br /&gt;for 20+0*(a=1048576)&lt;br /&gt;for ((processes-1)/(a=a/2))%2==1 &amp;amp;&amp;amp; processes&amp;gt;a&lt;br /&gt;spl 1&lt;br /&gt;rof&lt;br /&gt;for ((processes-1)/a)%2==0 &amp;amp;&amp;amp; processes&amp;gt;a&lt;br /&gt;mov.i -1,#0&lt;br /&gt;rof&lt;br /&gt;rof&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-8730912257312723683?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/8730912257312723683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=8730912257312723683&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8730912257312723683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/8730912257312723683'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/01/parallel-processes.html' title='parallel processes'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-6406706693904702420</id><published>2008-01-04T08:22:00.001Z</published><updated>2008-11-09T07:40:29.986Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='thoughts on corewar'/><category scheme='http://www.blogger.com/atom/ns#' term='privacy'/><title type='text'>Privacy Policy</title><content type='html'>&lt;span class="Apple-style-span"  style=" ;font-family:'Times New Roman';"&gt;&lt;div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "&gt;&lt;span class="Apple-style-span"  style=" ;font-size:18px;"&gt;Privacy&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I respect your privacy. The following policy explains how information is collected on &lt;a href="http://impomatic.blogspot.com/"&gt;Thoughts on Corewar&lt;/a&gt;. Your personal information will never be sold or disclosed to a third party, except where required by law.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style=" ;font-size:18px;"&gt;Statistics&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I use Google Analytics to track aggregate statistics about visitors to Thoughts on Corewar. This information is not linked to personally identifiable information.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style=" ;font-size:18px;"&gt;Cookies&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Cookies are small data files stored by a website on a user's computer. Thoughts on Corewar does not uses cookies. However, some of my advertising partners use cookies.  I have no access to cookies set by advertisers.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style=" ;font-size:18px;"&gt;Advertisers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I use advertising partners to display ads on Thoughts on Corewar. These partners may use cookies. I work with Google Adsense and Entrecard. I receive a list of Entrecard members who use the 'drop' feature. Please check the advertising partners' websites for their privacy policies.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style=" ;font-size:18px;"&gt;Contact Information&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have any questions please contact John Metcalf at digital.wilderness@googlemail.com.&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-6406706693904702420?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/6406706693904702420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=6406706693904702420&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/6406706693904702420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/6406706693904702420'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/01/privacy-policy.html' title='Privacy Policy'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6722581740507471912.post-4325852175287327737</id><published>2008-01-03T13:57:00.000Z</published><updated>2008-03-05T14:01:04.507Z</updated><title type='text'>why a new blog?</title><content type='html'>I've been inspired to create a new blog for two reasons:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;I love corewar and programming in redcode. I spend far too much of my online time creating websites that provide me with an income. Now I'd like to claim back some of that time for something I enjoy.&lt;/li&gt;&lt;li&gt;To show corewar is alive and well in 2008!&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6722581740507471912-4325852175287327737?l=impomatic.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://impomatic.blogspot.com/feeds/4325852175287327737/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6722581740507471912&amp;postID=4325852175287327737&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4325852175287327737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6722581740507471912/posts/default/4325852175287327737'/><link rel='alternate' type='text/html' href='http://impomatic.blogspot.com/2008/01/why-new-blog.html' title='why a new blog?'/><author><name>John</name><uri>http://www.blogger.com/profile/09108374348083307900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_kDyMtZ_dJwQ/SPJWvCQ5QpI/AAAAAAAAAWY/cnwIw9hloA0/S220/me.jpg'/></author><thr:total>0</thr:total></entry></feed>
