From news-rocq.inria.fr!couchey.inria.fr!doligez Thu Nov 16 20:24:55 1995 Article: 2922 of rec.games.corewar Path: news-rocq.inria.fr!couchey.inria.fr!doligez From: Planar Newsgroups: rec.games.corewar Subject: fun with imp rings & a bit of useful code Date: 16 Nov 1995 18:53:39 GMT Organization: "Brilliance is typically the act of an individual, but incredible stupidity can usually be traced to an organization." -- Jon Bentley Lines: 48 Distribution: world Message-ID: <48g1bk$d9f@news-rocq.inria.fr> NNTP-Posting-Host: couchey.inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit I have discovered a new way of launching imp rings. Unfortunately, it only works for imp sizes of CORESIZE-1 and CORESIZE-2, which are a little unwieldy. CORESIZE-1 works in any core size, with a step of -1, and CORESIZE-2 works in any odd core size, with a step of (CORESIZE-1)/2. Essentially, it is a vector launch, except that the vector is [imp, imp-1, imp-2, ...] so we can replace it with a predecrement. Here is the program for CORESIZE-1. It works in any core of at least 2 cells. The case CORESIZE==1 is left as an exercise. I limited myself to less than 2**31, but you could easily extend it (you'll need a MARS with more than 32-bit integers...) ;redcode-94 ;name MaxImp ;author Planar ;strategy (CORESIZE-1)-point imp ring ;assert CORESIZE >= 2 && CORESIZE <= 2147483647 ; to launch N processes ;assert MAXPROCESSES >= CORESIZE-1 ; for the imp ring to work N equ (CORESIZE-1) ; number of processes to launch i for 31 + ((n=1073741824) && 0) ; generate N processes for N-1 >= n && (N-1) / n % 2 == 1 ; no need to do this by hand ! spl 1 ; rof ; for N-1 >= n && (N-1) / n % 2 == ((n=n/2) && 0) mov.i -1, 0 ; rof ; rof ; N processes generated jmp imp, {0 ; launch the ring imp mov 0, -1 end For a (CORESIZE-2)-point ring, you would use one more cell as a pointer, and a JMP