hiebeler@TURING.CS.RPI.EDU (Dave Hiebeler) (03/02/90)
Here's Wireworld for CAM and for Cellsim. I only spent a few minutes writing them, so I won't say they're great, but they seem to work. Actually, I'd like to issue a challenge for CAM-users: if you have a better (which I guess means "more interesting and/or compact") way of implementing this, I'd like to hear about it! The Cellsim version of the rule is easier to read, but the nice thing about CAM is you can run 60 generations/sec on a 256x256 array, so you can do large circuits pretty quickly if you want. Cellsim will go pretty fast for smaller arrays. You can't run this rule on the Connection Machine using Cellsim, because the lookup-table would be too large for a CM with 8Kbytes/processor (that's what I use now). Of course, if you were to re-write it in Paris, it would run at several hundred generations/sec, if you turn off the display! I'm not really motivated to write it in Paris at the moment though.. (Paris is the Parallel Instruction Set, a semi-low-level language on the CM that you can call from C, Lisp and Fortran, for those who don't know.) ===== CAM version of Wireworld Wires are on plane 1, electron heads on plane 0, and I store electron tails on CAM-B. To non-CAM users, this might look a little scary. It's written in Forth, a stack-based language. If you've used an HP calculator, Forth is nothing fundamentally new. Plus, you only have to know a little Forth to use CAM. So here's the rule. I hope I didn't make a typo; I am not able to transfer files from my PC to Sun right now, so I just scribbled it down on paper from the PC screen and typed it in here. \ Wireworld, simple logic-circuits as described in \ A.K. Dewdney's "Computer Recreations" column in the \ January 1990 Scientific American. NEW-EXPERIMENT N/MOORE &/CENTERS CAM-A : 8SUM NORTH SOUTH EAST WEST N.WEST N.EAST S.WEST S.EAST + + + + + + + ; : EH 1 ; \ Electron Head : W 2 ; \ Wire : WIRERULE 8SUM { W EH EH W W W W W W } ; : WIREWORLD \ If not E-Tail, do normal rule, else become wire &CENTER IF W ELSE CENTERS { 0 W WIRERULE 0 } THEN >PLNA ; MAKE-TABLE WIREWORLD CAM-B N/MOORE &/CENTERS : ET-RULE &CENTERS EH = IF 1 ELSE 0 THEN >PLN2 ; MAKE-TABLE ET-RULE ===== Cellsim version of Wireworld Here it is for Cellsim. It uses the "m4" neighborhood, so it generates a lookup-table rather than running in computed-function mode. This form of the rule is fairly portable, and should be very easy to plug into CA Lab and other packages, I think. Of course, this rule is so simple, it's no big feat to rewrite it for other systems. /* * File: wireworld.m4.c * By: Dave Hiebeler * hiebeler@heretic.lanl.gov * February 1990 * * Wireworld CA rule, as described in A.K. Dewdney's Jan 1990 "Computer * Recreations" column, in Scientific American. */ #include "nborhood.h" byte wireworld_rule(); #define EMPTY 0 #define EHEAD 1 /* electron heads on plane 0 */ #define WIRE 2 /* wires on plane 2 */ #define ETAIL 3 /* electron tail is a 1 in both planes */ /* Little boolean macro, equals 1 if cell is e-head, otherwise equals 0 */ #define ehead(cell) ((cell==EHEAD) & 0x01) void init_function() { update_function = wireworld_rule; } byte wireworld_rule(nbors) moore_nbors *nbors; { int eightsum; Get_moore_nbors; eightsum = ehead(tl) + ehead(l) + ehead(bl) + ehead(t) + ehead(b) + ehead(tr) + ehead(r) + ehead(br); switch (center) { case EMPTY: return EMPTY; break; case EHEAD: return ETAIL; break; case ETAIL: return WIRE; break; case WIRE: if ((eightsum == 1) || (eightsum == 2)) return EHEAD; else return WIRE; break; } } If someone out there using CAM or Cellsim would like me to crank out a little program to convert those text-diagrams we've been seeing into CAM or Cellsim image-format, let me know. It's easy enough to draw stuff in both systems, that I haven't bothered writing a program to convert. It would only take a couple of minutes to do, though. Dave Hiebeler hiebeler@turing.cs.rpi.edu Computer Science Dept hiebeler@heretic.lanl.gov Amos Eaton Bldg. hiebeler@rpitsmts.bitnet Rensselaer Polytechnic Institute Troy, NY 12180-3590