Xref: utzoo comp.theory.cell-automata:177 comp.lang.misc:5116 Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!hiebeler From: hiebeler@raven.lanl.gov (David Hiebeler) Newsgroups: comp.theory.cell-automata,comp.lang.misc Subject: Re: Languages for programming cellular automata Message-ID: Date: 9 Jul 90 04:45:02 GMT References: <1142@rucs.runet.edu> Organization: Theoretical Division, Los Alamos Nat. Lab; RPI CS Dept Lines: 95 In article <1142@rucs.runet.edu> dana@rucs.runet.edu (Dana Eckart) writes: > I'm interested in learning what (if any) languages have been designed > for programming cellular automata. I am aware of CAM-FORTH (used for > programming the CAM-6 machine), but am unaware of any other languages. This is a great question, which I've been thinking about for some time. There aren't any other real "languages" for doing CA that I'm aware of. Some packages (e.g. Cellsim, CA Lab, CA Sim) have pseudo-environments for generating CA rules though. Cellsim and CA Lab both let the user program the rule himself/herself (at least the main part of the rule, i.e. the lookup-table or compute-new-cell-value functionality). Fortunately, that's pretty simple to do in most languages. For example, in C, to program the game of Life, you just need a few handy macros, variables, a good Makefile, and a main() to link in. Then, the only burden placed on the user is to write a simple function like: cell LifeRule(center, north, south, east, west, nwest, neast, swest, seast) cell center, north, south, east, west, nwest, neast, swest, seast; { int nbor_sum; nbor_sum = north + south + east + west + nwest + neast + swest + seast; if (nbor_sum == 3) /* if 3 neighbors alive, become alive */ return 1; if (nbor_sum == 2) /* if 2 neighbors alive, stay in current state */ return center; else /* if less than 2 or more than 3 active neighbors, die */ return 0; } (where "cell" is typically typedef'ed to unsigned char or unsigned int) That's roughly (although not exactly) how it looks in Cellsim. (In Cellsim, the function gets 1 parameter of type "moore_nbors", and then you call a "Get_moore_nbors" macro to extract them. There are also linear_nbors, vonn_nbors, and margolus_nbors). I believe CA Lab is pretty similar, although it has support for Pascal and BASIC as well. Cellsim only supports C, although it would be very easy to write the support-routines for Pascal or other languages. Cellsim also supports similar functions for generating rules that are too large for lookup-tables. In fact, it looks at the number of states and the neighborhood of the rule (determined by the filename), and decides whether to make it a lookup-table, or a "computed-function" rule. With computed-function rules, the update function is called once for every cell in the array, to compute the new value. It's pretty slow, but what else can you do if the rule is too big for a lookup table? Cellsim runs on Suns, but also can attach to a Connection Machine. To write computed-function rules on the CM, you write the rule in C/Paris, a collection of data-parallel routines specific to the CM. They run very quickly on the CM, since the update-function operates in parallel. CA Sim, on the other hand, supports a graphical programming system for constructing CA rules. You get a big window full of buttons and items that you select to construct your rule. CA Sim runs on a Mac and was written by Ken Karakotsios, who reads this newsgroup. Ken, maybe you'd like to summarize the features in CA Sim that help users construct rules? I've used the CAM-Forth software with CAM-6 for a few years now. Although I'm still not crazy about Forth, the environment is nice in the sense that it's very interactive and flexible. Right now, I'm developing a new software library to control the newer jazzed-up version of CAM-6, called CAM-PC. I'm attempting to incorporate the most useful features (in my opinion) for CA programming and to keep the system fairly easy-to-use and readable. (CAM rules written in Forth are often hard to read; it's very easy to write messy Forth). After it's well-along, I plan to take that environment and attach it to a purely-software CA simulator, for those who can't afford the special-purpose hardware. I expect that I'll first do a PC-based simulator, since the CAM plugs into PC's, but I'll probably port it to X-windows shortly after that. I expect to complete the CAM-PC software within a month or two, but probably won't have time to start porting the stuff to a software simulator until the Spring. I'll probably write at least one paper about all this sometime in the next six months, so I'll mention it here when I have something more definite. At some point, I may post a rough outline of the specifics of the environment, to get some feedback from people here. -- Dave Hiebeler | Internet: hiebeler@heretic.lanl.gov Complex Systems Group | Bitnet: userF3JL@rpitsmts MS B213, Theoretical Division | UUCP: crdgw1!automtrx!hiebeler Los Alamos National Laboratory / Los Alamos, NM 87545 USA