Newsgroups: comp.sources.unix From: dana@rucs.faculty.cs.runet.edu (J Dana Eckart) Subject: v26i088: cellular-2.0 - a cellular automata language, Part01/03 Sender: unix-sources-moderator@vix.com Approved: paul@vix.com Submitted-By: dana@rucs.faculty.cs.runet.edu (J Dana Eckart) Posting-Number: Volume 26, Issue 88 Archive-Name: cellular-2.0/part01 [ my apologies for the TeX here, but the author of this package did not say in her cover letter or README file what this is or what it does, and i do not have a TeX interpreter so i can't make this prettier other than with a lot of hand-editing. it's from the "tutorial.tex" file. --vix ] \section{Introduction} With the growing popularity of cellular automata in both recreation \cite{life}\cite{wireworld}\cite{fluids}\cite{crystals} and the modeling of physical systems\cite{toffoli}\cite{Wolf-Gladrow}\cite{Chen}\cite{Lavallee}\cite{Lim}, the need for an easy--to--use system for cellular automata programming is greater than ever. {\em Cellular} is a system designed and implemented by the author to meet these needs. The system consists of: a programming language, {\em Cellang 2.0}\footnote{ Pronounced cell ' ang. }, and associated compiler, {\tt cellc}; an ``abstract'' virtual machine\footnote{ The construction of an actual machine embodying the pe--scam architecture is under development.\cite{pe-scam} for execution, {\tt pe-scam}; and a viewer, {\tt cellview}. Compiled {\em Cellang 2.0} programs can be run with input provided at any specified time during the execution. The results of an execution can either be viewed directly or output as a stream of cell locations and values. This stream of output data can then be fed into {\tt cellview} for viewing, or it may be passed through a filter that compiles statistics, massages the data, or merely acts as a valve to control the flow of data from the cellular automaton program to the viewer. This simple UNIX\footnote{ UNIX is a registered trademark of AT\&T. } toolkit view of the simulation process provides greater control than systems which combine the language and viewer (i.e. cellsim\cite{cellsim} and CAM--6\cite{toffoli}). {\em Cellang 2.0} provides greater flexibility, particularly in the formation of neighborhoods, than does {\em Cal} (part of the {\em Scamper} system)\cite{Scamper}. And although the {\em SLANG}\cite{SLANG} system supports probablistic possibilities, {\em Cellang 2.0} is a far simpler language for constructing deterministic cellular automata. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'MANIFEST' <<'END_OF_FILE' X File Name Archive # Description X----------------------------------------------------------- X COPYING 2 X MANIFEST 1 This shipping list X Makefile 1 X README 1 X Version 1 X compiler 1 X compiler/Cellang.tex 2 X compiler/Makefile 1 X compiler/README 1 X compiler/attribute.h 1 X compiler/boolean.h 1 X compiler/cellc.man 1 X compiler/cellc.sh 1 X compiler/error.c 1 X compiler/error.h 1 X compiler/io.h 1 X compiler/parse 1 X compiler/scanner.c 2 X compiler/scanner.h 1 X compiler/semantic.c 3 X compiler/semantic.h 1 X compiler/stack.h 1 X compiler/symtable.c 1 X compiler/symtable.h 1 X driver 1 X driver/Makefile 1 X driver/pe-scam.man 2 X driver/pe-scam.sh 1 X examples 1 X examples/Makefile 1 X examples/README 1 X examples/bin 1 X examples/data 1 X examples/data/cparity 1 X examples/data/life 1 X examples/data/parity 1 X examples/dist_data_gen.c 1 X examples/gas_data_gen.c 1 X examples/map 1 X examples/map/srdp 1 X examples/show.sh 1 X examples/src 1 X examples/src/cparity 1 X examples/src/dist 1 X examples/src/gas 1 X examples/src/life 1 X examples/src/parity 1 X examples/src/srdp 1 X examples/srdp_data_gen.c 1 X tutorial.tex 3 X viewer 1 X viewer/Makefile 1 X viewer/README 1 X viewer/boolean.h 1 X viewer/bw-map 1 X viewer/cellview.man 2 X viewer/color-map 1 X viewer/curses-map 1 X viewer/curses.c 1 X viewer/curses.h 1 X viewer/view.c 2 X viewer/view.h 1 X viewer/x11.c 2 X viewer/x11.h 1 END_OF_FILE if test 2098 -ne `wc -c <'MANIFEST'`; then echo shar: \"'MANIFEST'\" unpacked with wrong size! # end of 'MANIFEST' if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" echo shar: Extracting \"'Makefile'\" \(4029 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# Makefile X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# Installation directories. BIN=/usr/local/bin LIB=/usr/local/lib/cellular MAN=/usr/man/manl MAN_EXT=l X# The default (maximum) size of each dimension associated with Cellang programs. MAX_DIM_SIZE=64 X# If you want to have the Cellang compiler configured to compile the viewer X# into the executables then assign COMBINED the value "1", otherwise assign X# a "0". This makes for faster display of many automata, though it does need X# X11 to run them. COMBINED=1 # 0 or 1 X# Choose a C compiler and options. CC = gcc CFLAGS = -O X# Rules (default.mk on SunOS uses a -target option not supported by GNU C) COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c X# Dependencies all: tutorial.PS X (cd compiler; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X CC='${CC}' CFLAGS='${CFLAGS}' \ X CDEFINES='-DCOMBINED=${COMBINED}' \ X MAX_DIM_SIZE='${MAX_DIM_SIZE}' \ X COMBINED='${COMBINED}' \ X all) X (cd viewer; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X CC='${CC}' CFLAGS='${CFLAGS}' \ X CDEFINES='-DLIB_DIR=\"${LIB}\"' \ X COMBINED='${COMBINED}' \ X all) X (cd driver; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X MAX_DIM_SIZE='${MAX_DIM_SIZE}' \ X COMBINED='${COMBINED}' \ X all) X (cd examples; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X CC='${CC}' CFLAGS='${CFLAGS}' \ X MAX_DIM_SIZE='${MAX_DIM_SIZE}' \ X all) install: tutorial.PS X (cd compiler; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X CC='${CC}' CFLAGS='${CFLAGS}' \ X CDEFINES='-DCOMBINED=${COMBINED}' \ X MAX_DIM_SIZE='${MAX_DIM_SIZE}' \ X COMBINED='${COMBINED}' \ X install) X (cd viewer; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X CC='${CC}' CFLAGS='${CFLAGS}' \ X CDEFINES='-DLIB_DIR=\"${LIB}\"' \ X COMBINED='${COMBINED}' \ X install) X (cd driver; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X MAX_DIM_SIZE='${MAX_DIM_SIZE}' \ X COMBINED='${COMBINED}' \ X install) X (cd examples; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X CC='${CC}' CFLAGS='${CFLAGS}' \ X MAX_DIM_SIZE='${MAX_DIM_SIZE}' \ X install) deinstall: X (cd compiler; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X deinstall) X (cd viewer; \ X make BIN='${BIN}' LIB='${LIB}' \ X MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X deinstall) X (cd driver; \ X make BIN='${BIN}' MAN='${MAN}' MAN_EXT='${MAN_EXT}' \ X deinstall) X (cd examples; \ X make LIB='${LIB}' deinstall) clean: X /bin/rm -f *.aux *.dvi *.log *.toc core X (cd compiler; make MAN_EXT='${MAN_EXT}' clean) X (cd viewer; make MAN_EXT='${MAN_EXT}' clean) X (cd driver; make MAN_EXT='${MAN_EXT}' clean) X (cd examples; make clean) realclean: clean X /bin/rm -f tutorial.PS X (cd compiler; make realclean) X (cd viewer; make realclean) X (cd driver; make realclean) X (cd examples; make realclean) tutorial.PS: tutorial.tex X - latex tutorial.tex X - latex tutorial.tex X - dvi2ps -r tutorial.dvi > tutorial.PS END_OF_FILE if test 4029 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! # end of 'Makefile' if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" echo shar: Extracting \"'README'\" \(2358 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' X# README X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. To install the Cellular system, edit the Makefile to reflect the proper values of: X BIN - installation directory for executables X LIB - installation directory for supporting software X MAN - installation directory for manual pages X MAX_EXT - manual page extension to use for installation X MAX_DIM_SIZE - size of each dimension in Cellang 2.0 programs X COMBINED - whether or not to compile the viewer into Cellang 2.0 programs Do "make install" to build and install everything. In addition, the Makefile also supports the targets: X all: compile, but not install, the software X deinstall: remove an installation X clean: remove all but the distributed files (and postscript versions of X LaTeX documents) X realclean: remove all but the distributed files A tutorial is written in LaTeX and appears in ./tutorial.tex, while the Cellang 2.0 Language Reference Manual appears in compiler/Cellang.tex (and is also written in LaTeX). The "examples" directory (found in the LIB directory specified in the Makefile) contains some sample Cellang programs with data. It is a good place to start for becoming familiar with the system. NOTE: When compiled with COMBINED turned on, only the first two dimensions X (when present) are displayed if the output option is not chosen when X the automata is executed. X QUESTIONS, COMMENTS, BUG REPORTS and SUGGESTED PATCHES can be sent to me at either: X J Dana Eckart X Box 6933 X Computer Science Department X Radford University X Radford, VA 24142 X dana@rucs.faculty.cs.runet.edu END_OF_FILE if test 2358 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! # end of 'README' if test -f 'Version' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Version'\" echo shar: Extracting \"'Version'\" \(802 characters\) sed "s/^X//" >'Version' <<'END_OF_FILE' X# Version X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X13 Apr 1992 : initial release by J Dana Eckart END_OF_FILE if test 802 -ne `wc -c <'Version'`; then echo shar: \"'Version'\" unpacked with wrong size! # end of 'Version' if test ! -d 'compiler' ; then echo shar: Creating directory \"'compiler'\" mkdir 'compiler' if test -f 'compiler/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/Makefile'\" echo shar: Extracting \"'compiler/Makefile'\" \(3502 characters\) sed "s/^X//" >'compiler/Makefile' <<'END_OF_FILE' X# Makefile X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# Installation directories. BIN=/usr/local/bin LIB=/usr/local/lib/cellular MAN=/usr/man/manl MAN_EXT=l X# The default (maximum) sizes associated with Cellang programs. MAX_DIM_SIZE=64 MAX_SUPPORTED_DIMENSIONS=16 MAX_SUPPORTED_FIELDS=32 X# If you want to have the Cellang compiler configured to compile the viewer X# into the executables then assign COMBINED the value "1", otherwise assign X# a "0". This makes for faster display of many automata, though it does need X# X11 to run them. COMBINED=0 # 0 or 1 X# The C type declaration to use for cell field declarations and the upper X# and lower bounds on the range of values supported by that data type. X# The range of values should be taken from the limits.h file used by your X# C compiler. XFIELD_TYPE = "unsigned char" MAX_RANGE_LB = 0 MAX_RANGE_UB = 255 X# Choose a C compiler and options. CC= gcc CFLAGS= -O -ansi -pedantic CDEFINES= -DCOMBINED=$(COMBINED) X# Rules (default.mk on SunOS uses a -target option not supported by GNU C) COMPILE.c=$(CC) $(CFLAGS) $(CDEFINES) -DFIELD_TYPE=\"$(FIELD_TYPE)\" \ X -DMAX_RANGE_LB=$(MAX_RANGE_LB) -DMAX_RANGE_UB=$(MAX_RANGE_UB) \ X $(CPPFLAGS) -c X# Dependencies all: cellfront cellc Cellang.PS cellc.${MAN_EXT} install: all X - mkdir -p ${BIN} X - mkdir -p ${LIB} X - mkdir -p ${MAN} X install cellfront ${LIB}/cellfront X install cellc ${BIN}/cellc X install -m 644 cellc.${MAN_EXT} ${MAN}/cellc.${MAN_EXT} deinstall: X /bin/rm -f ${LIB}/cellfront X /bin/rm -f ${BIN}/cellc X /bin/rm -f ${MAN}/cellc.${MAN_EXT} clean: X /bin/rm -f *.o *.tab.h *.tab.c *.aux *.dvi *.log *.toc \ X cellc cellfront core cellc.${MAN_EXT} size.h realclean: clean X /bin/rm -f *.PS cellfront: scanner.o semantic.o symtable.o y.tab.o error.o X ${CC} ${CFLAGS} -o cellfront *.o cellc.${MAN_EXT}: cellc.man X sed -e 's?LIB_DIR?$(LIB)?' \ X -e 's?MAN_EXT?$(MAN_EXT)?g' cellc.man > cellc.${MAN_EXT} size.h: ../Makefile X echo "#define MAX_DIM_SIZE ${MAX_DIM_SIZE}" > size.h X echo "#define MAX_SUPPORTED_DIMENSIONS ${MAX_SUPPORTED_DIMENSIONS}" >> size.h X echo "#define MAX_SUPPORTED_FIELDS ${MAX_SUPPORTED_FIELDS}" >> size.h semantic.o: semantic.c semantic.h symtable.h stack.h size.h\ X attribute.h boolean.h error.h symtable.o: symtable.c symtable.h attribute.h boolean.h scanner.o: scanner.c scanner.h y.tab.h error.h error.o: error.c error.h y.tab.h y.tab.c: parse error.h X yacc -d parse y.tab.o: parse attribute.h semantic.h symtable.h boolean.h error.h cellc: cellc.sh X sed -e 's?YOUR_LIB?$(LIB)?' \ X -e 's?YOUR_CC?$(CC)?' \ X -e 's?YOUR_CFLAGS?$(CFLAGS)?' \ X -e 's?YOUR_COMBINED?$(COMBINED)?' \ X cellc.sh > cellc X chmod u+rx cellc Cellang.PS: Cellang.tex X - latex Cellang.tex X - latex Cellang.tex X - dvi2ps -r Cellang.dvi > Cellang.PS END_OF_FILE if test 3502 -ne `wc -c <'compiler/Makefile'`; then echo shar: \"'compiler/Makefile'\" unpacked with wrong size! # end of 'compiler/Makefile' if test -f 'compiler/README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/README'\" echo shar: Extracting \"'compiler/README'\" \(1930 characters\) sed "s/^X//" >'compiler/README' <<'END_OF_FILE' X# README X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. To install the Cellang compiler, edit the Makefile to reflect the proper values of: X BIN - installation directory for executables X LIB - installation directory for supporting software X MAN - installation directory for manual pages X MAX_EXT - manual page extension to use for installation X MAX_DIM_SIZE - size of each dimension in Cellang 2.0 programs X MAX_SUPPORTED_DIMENSIONS - maximum allowed dimensions in programs X MAX_SUPPORTED_FIELDS - maximum allowed fields per cell in programs X FIELD_TYPE - C data type to use for cell fields X MAX_RANGE_LB - smallest value of FIELD_TYPE X MAX_RANGE_UB - largest value of FIELD_TYPE Do "make install" to build and install the compiler. In addition, the Makefile also supports the targets: X all: compile, but not install, the software X deinstall: remove an installation X clean: remove all but the distributed files (and postscript version of X the language reference manual) within this directory X realclean: remove all but the distributed files within this directory The Cellang language reference manual is written in LaTeX and appears in Cellang.tex. END_OF_FILE if test 1930 -ne `wc -c <'compiler/README'`; then echo shar: \"'compiler/README'\" unpacked with wrong size! # end of 'compiler/README' if test -f 'compiler/attribute.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/attribute.h'\" echo shar: Extracting \"'compiler/attribute.h'\" \(1069 characters\) sed "s/^X//" >'compiler/attribute.h' <<'END_OF_FILE' X/* attribute.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X#include "boolean.h" X/* The exported declarations for attributes appearing in the symbol table. */ typedef struct { X boolean assignable; /* True iff assignable. */ X boolean field_name; /* True iff the symbol is a cell field. */ X boolean structured; /* True iff the value is structured. */ X} attr_rec; END_OF_FILE if test 1069 -ne `wc -c <'compiler/attribute.h'`; then echo shar: \"'compiler/attribute.h'\" unpacked with wrong size! # end of 'compiler/attribute.h' if test -f 'compiler/boolean.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/boolean.h'\" echo shar: Extracting \"'compiler/boolean.h'\" \(817 characters\) sed "s/^X//" >'compiler/boolean.h' <<'END_OF_FILE' X/* boolean.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X#define boolean int X#define true 1 X#define false 0 END_OF_FILE if test 817 -ne `wc -c <'compiler/boolean.h'`; then echo shar: \"'compiler/boolean.h'\" unpacked with wrong size! # end of 'compiler/boolean.h' if test -f 'compiler/cellc.man' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/cellc.man'\" echo shar: Extracting \"'compiler/cellc.man'\" \(1147 characters\) sed "s/^X//" >'compiler/cellc.man' <<'END_OF_FILE' X.TH cellc 1 X.SH NAME cellc \- X.I "Cellang 2.0" X(cellular automata) compiler X.SH SYNOPSIS X.B cellc X.B \-o X.I outputfile X.SH DESCRIPTION X.I cellc is the Cellang celluar automata compiler. X.I cellc compiles and builds the executable for the Cellang program contained within file. By default, the executable is placed in a.pe-scam. X.BI \-o " outputfile" Name the output file X.IR outputfile . X.I outputfile cannot be the same as X.I sourcefile X(the compiler will not overwrite the source file). The default is X.I a.pe-scam. X.ne 5 X.SH FILES X file program text file X a.pe-scam default executable file X LIB_DIR/cellfront program which actually generates the pe-scam object code X.SH "SEE ALSO" cellview(MAN_EXT), pe-scam(MAN_EXT) J Dana Eckart, X.I "A Cellular Automata Simulation System: Version 2.0" X(1992) J Dana Eckart, X.I "Cellang 2.0: Language Reference Manual" X(1992) X.SH DIAGNOSTICS The diagnostics produced by cellc are intended to be self-explanatory. X.SH BUGS The current implementation does not check to ensure that the values assigned to fields are within the associated ranges. END_OF_FILE if test 1147 -ne `wc -c <'compiler/cellc.man'`; then echo shar: \"'compiler/cellc.man'\" unpacked with wrong size! # end of 'compiler/cellc.man' if test -f 'compiler/cellc.sh' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/cellc.sh'\" echo shar: Extracting \"'compiler/cellc.sh'\" \(1702 characters\) sed "s/^X//" >'compiler/cellc.sh' <<'END_OF_FILE' X#!/bin/sh X# cellc.sh X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. LIB=YOUR_LIB CC=YOUR_CC CFLAGS=YOUR_CFLAGS COMBINED=YOUR_COMBINED C_FILE=.cellang.c H_FILE=.cellang.h USAGE="usage: `basename $0` [-o outputfile] filename" trap "/bin/rm -f $C_FILE $H_FILE;exit" 0 X# Get options and check usage if (test $# -lt 1) then X echo $USAGE X exit 1 while (test $# -gt 1) X case $1 in X '-o') OUT_FILE="-o $2" X shift X ;; X *) echo "Unknown flag, '$1'." X echo $USAGE X exit 1 X ;; X esac X shift X# By default, put the executable in "a.pe-scam". if test -z "$OUT_FILE" X OUT_FILE="-o a.pe-scam" XFILE=$1 X# Perform conversion to C and then do a c compilation. if test -r $FILE X $LIB/cellfront < $FILE X if test -s $C_FILE X then X if test "$COMBINED" = "1" X then X $CC $CFLAGS $OUT_FILE $C_FILE $LIB/*.o \ X -lm -lcurses -ltermcap -lX11 X else X $CC $CFLAGS $OUT_FILE $C_FILE X fi X echo "`basename $0`: file $FILE not found" X/bin/rm -f $C_FILE $H_FILE END_OF_FILE if test 1702 -ne `wc -c <'compiler/cellc.sh'`; then echo shar: \"'compiler/cellc.sh'\" unpacked with wrong size! # end of 'compiler/cellc.sh' if test -f 'compiler/error.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/error.c'\" echo shar: Extracting \"'compiler/error.c'\" \(1191 characters\) sed "s/^X//" >'compiler/error.c' <<'END_OF_FILE' X/* error.c X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X#include X#include X#include "error.h" X/************************************************************************/ X/* SUPPORT ROUTINE X ACTION - Malloc's the desired amount of space, issuing an X error message if the space is not forthcoming. char* mymalloc(size) unsigned int size; { X char *pointer = malloc(size); X if (NULL == pointer) X error("Out of memory", (char*) NULL); X return pointer; END_OF_FILE if test 1191 -ne `wc -c <'compiler/error.c'`; then echo shar: \"'compiler/error.c'\" unpacked with wrong size! # end of 'compiler/error.c' if test -f 'compiler/error.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/error.h'\" echo shar: Extracting \"'compiler/error.h'\" \(895 characters\) sed "s/^X//" >'compiler/error.h' <<'END_OF_FILE' X/* error.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. extern void error_prefix(); /* Prints prefix for error messages. */ extern char* mymalloc(); /* A malloc that checks for success. */ END_OF_FILE if test 895 -ne `wc -c <'compiler/error.h'`; then echo shar: \"'compiler/error.h'\" unpacked with wrong size! # end of 'compiler/error.h' if test -f 'compiler/io.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/io.h'\" echo shar: Extracting \"'compiler/io.h'\" \(884 characters\) sed "s/^X//" >'compiler/io.h' <<'END_OF_FILE' X/* io.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. extern FILE *file_h; /* Denotes the C header output stream. */ extern FILE *file_c; /* Denotes the C code output stream. */ END_OF_FILE if test 884 -ne `wc -c <'compiler/io.h'`; then echo shar: \"'compiler/io.h'\" unpacked with wrong size! # end of 'compiler/io.h' if test -f 'compiler/parse' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/parse'\" echo shar: Extracting \"'compiler/parse'\" \(5776 characters\) sed "s/^X//" >'compiler/parse' <<'END_OF_FILE' X/* parse X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X#include "semantic.h" X#include "scanner.h" X%token DIMENSIONS X%token IF X%token THEN X%token ELSIF X%token ELSE X%token END X%token WHEN X%token OTHERWISE X%token OF X%token ASSIGN X%token PLUS X%token MINUS X%token TIMES X%token DIVIDE X%token MOD X%token EQUAL X%token LESSER X%token GREATER X%token LESSEQ X%token GREATEQ X%token NOTEQ X%token AND X%token OR X%token NOT X%token LEFTPAREN X%token RIGHTPAREN X%token LEFTBRACKET X%token RIGHTBRACKET X%token COMMA X%token DOTS X%token DOT X%token IDENTIFIER X%token NUMERICLITERAL X/* Unlike most yacc specifications, the following have also been X written in LL(1) form. This prevents yacc from making improper X assumptions about breaking up a production because of embedded X actions. It also allows the use of an LL(1) parser generator, X hopefully sometime in the near future. X%start program program : declare_cells { begin_rules(); } X statement_list { end_rules(); } declare_cells : number { set_dimensions(); } DIMENSIONS X OF fields_or_range fields_or_range : range { declare_default_field(); } X | { begin_decl_cells(); } field rest_fields X END { end_decl_cells(); } rest_fields : field rest_fields field : ident_list OF range { declare_fields(); } range : integer DOTS integer { make_range(); } ident_list : { push_mark(); } identifier rest_ident_list rest_ident_list : COMMA identifier rest_ident_list integer : unary_add number { mk_signed_int(); } X | number number : NUMERICLITERAL { process_literal(yytext); } statement_list : statement statement_list statement : assign_statement X | if_statement assign_statement: identifier { assignable_base(); } field_option X ASSIGN expression rest_assign X/* rest_assign is included solely for the jump_if semantic action; which X for rest_when is a jump_elseif. rest_assign : WHEN expression { jump_if(); do_assign(); } expression_list X | OTHERWISE X { do_assign(); end_assign(); } X | { do_assign(); end_assign(); } rest_when : WHEN expression { jump_elsif(); do_assign(); } expression_list X | OTHERWISE X { start_else(); do_assign(); end_if(); end_assign(); } expression_list : ASSIGN expression rest_when X | { end_if(); end_assign(); } if_statement : IF expression { jump_if(); } THEN statement_list X elsif_list else { end_if(); } END elsif_list : elsif elsif_list X | elsif : ELSIF expression { jump_elsif(); } THEN statement_list else : ELSE { start_else(); } statement_list X | X/* The numbered suffix is the precedence of that expression/operator. */ expression : expression_1 expression_1 : expression_2 rest_expr_1 X | unary_boolean expression_2 { unary_op(); } rest_expr_1 rest_expr_1 : binary_boolean expression_1 { binary_op(); } expression_2 : expression_3 rest_expr_2 rest_expr_2 : binary_relation expression_2 { binary_op(); } expression_3 : expression_4 rest_expr_3 X | unary_add expression_4 { unary_op(); } rest_expr_3 rest_expr_3 : binary_add expression_3 { binary_op(); } expression_4 : primary rest_expr_4 rest_expr_4 : binary_mult expression_4 { binary_op(); } primary : identifier { get_variable(); } field_option X | number X | LEFTPAREN expression RIGHTPAREN X | LEFTBRACKET { push_mark(); } X integer rest_index_list X RIGHTBRACKET { cell_reference(); } field_option rest_index_list : COMMA integer rest_index_list field_option : DOT identifier { field_reference(); } identifier : IDENTIFIER { push(yytext); } binary_boolean : AND { push("&&"); } X | OR { push("||"); } unary_boolean : NOT { push("!"); } binary_relation : EQUAL { push("=="); } X | NOTEQ { push("!="); } X | LESSER { push("<"); } X | GREATER { push(">"); } X | LESSEQ { push("<="); } X | GREATEQ { push(">="); } binary_add : PLUS { push("+"); } X | MINUS { push("-"); } unary_add : binary_add binary_mult : TIMES { push("*"); } X | DIVIDE { push("/"); } X | MOD { push("%"); } X#include X#include X#include "io.h" boolean syntax_error; /* True iff a syntax error was encountered. */ void main(argc, argv) int argc; char *argv[]; { X if (argc-1 != 0) { X fprintf(stderr, "%s: No argument should be given\n", argv[0]); X exit(0); X syntax_error = false; X start_up(); X /* Read and compile the user's program. */ X startscan(); X yyparse(); X /* If no errors occurred, then finishup. */ X if (!scan_error && !syntax_error && !semantic_error) X finish_up(); X /* If errors occurred, then empty files and indicate an error. */ X if (scan_error || syntax_error || semantic_error) { X fclose(file_h); X fclose(file_c); X file_h = fopen(".cellang.h", "w"); X fclose(file_h); X file_c = fopen(".cellang.c", "w"); X fclose(file_c); X exit(1); X#include "error.h" void yyerror(s) char *s; { X syntax_error = true; X error_prefix(); X fprintf(stderr, "%s\n", s); END_OF_FILE if test 5776 -ne `wc -c <'compiler/parse'`; then echo shar: \"'compiler/parse'\" unpacked with wrong size! # end of 'compiler/parse' if test -f 'compiler/scanner.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/scanner.h'\" echo shar: Extracting \"'compiler/scanner.h'\" \(1077 characters\) sed "s/^X//" >'compiler/scanner.h' <<'END_OF_FILE' X/* scanner.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X#include "y.tab.h" X#include "boolean.h" extern boolean scan_error; /* True iff a scanning error was encountered. */ extern char yytext[]; /* Holds the text of a scanned token. */ extern void startscan(); /* Setup for scanning a new file. */ extern int yylex(); /* Function used to acquire the next token. */ END_OF_FILE if test 1077 -ne `wc -c <'compiler/scanner.h'`; then echo shar: \"'compiler/scanner.h'\" unpacked with wrong size! # end of 'compiler/scanner.h' if test -f 'compiler/semantic.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/semantic.h'\" echo shar: Extracting \"'compiler/semantic.h'\" \(2117 characters\) sed "s/^X//" >'compiler/semantic.h' <<'END_OF_FILE' X/* semantic.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X/* These are the declarations for all of the semantic actions. */ X#include "boolean.h" extern boolean semantic_error; /* True iff a semantic error was encountered. */ X/* initialization and cleanup for the compilation */ extern void start_up(); extern void finish_up(); X/* declare the dimensionality and fields of the cells of the universe. */ extern void begin_decl_cells(); extern void end_decl_cells(); extern void declare_fields(); extern void declare_default_field(); extern void make_range(); extern void set_dimensions(); X/* Group the cellular automata rules into a function. */ extern void begin_rules(); extern void end_rules(); X/* assignment statement */ extern void do_assign(); extern void end_assign(); X/* when statment */ extern void jump_when(); X/* if-then-elsif-else statment */ extern void jump_if(); extern void jump_elsif(); extern void start_else(); extern void end_if(); X/* simple push operations */ extern void push_mark(); extern void push(); X/* simple processing */ extern void process_literal(); extern void mk_signed_int(); X/* setup variables (left hand side of assignments) */ extern void assignable_base(); X/* expressions */ extern void get_variable(); extern void binary_op(); extern void unary_op(); X/* Getting the value from a neighboring cell. */ extern void cell_reference(); extern void field_reference(); END_OF_FILE if test 2117 -ne `wc -c <'compiler/semantic.h'`; then echo shar: \"'compiler/semantic.h'\" unpacked with wrong size! # end of 'compiler/semantic.h' if test -f 'compiler/stack.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/stack.h'\" echo shar: Extracting \"'compiler/stack.h'\" \(1714 characters\) sed "s/^X//" >'compiler/stack.h' <<'END_OF_FILE' X/* stack.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X/* The following define the different stack_entry kinds. */ X#define StackMark 1 X#define StackExpr 2 X#define StackToken 3 X#define StackError 4 X#define StackRange 5 typedef struct { X char *addr; /* Reference name of the expression. */ X char *field; /* Field name of the expression. This X is used only for doing the implicit X variable declarations to keep the X field separate from the variable until X its type can be inferred. X */ X boolean assignable; /* True iff assignable. */ X boolean pre_declared; /* True iff identifier was previous declared. */ X boolean unstructured; /* True iff expr_entry is NOT structured. */ X} expr_entry; typedef struct { X int lower_bound; /* Lower bound of a field range. */ X int upper_bound; /* Upper bound of a field range. */ X} range_entry; typedef struct { X int kind; X union { X expr_entry expr; X char *token; X range_entry range; X } data; X} stack_entry; END_OF_FILE if test 1714 -ne `wc -c <'compiler/stack.h'`; then echo shar: \"'compiler/stack.h'\" unpacked with wrong size! # end of 'compiler/stack.h' if test -f 'compiler/symtable.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/symtable.c'\" echo shar: Extracting \"'compiler/symtable.c'\" \(3217 characters\) sed "s/^X//" >'compiler/symtable.c' <<'END_OF_FILE' X/* symtable.c X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X/* This file implements the symbol table. Bucket hashing is used, X associating an attribute with each identifier. New identifiers X are always added to the front of the chain representing the bucket. X#include X#include "attribute.h" X#include "symtable.h" X#include "error.h" X#define TableSize 27 typedef struct bucket_fubar { X char* name; X attr_rec *attribute; X struct bucket_fubar *next; X} bucket; bucket *table[TableSize]; X/* Initializes every bucket in the hash table to be empty. */ void initsymboltable() { X int i; X for (i = 0; i < TableSize; i++) table[i] = NULL; X/* Calculates a hash value for the string based upon the first and X last characters in the string. If the string contains only one X character, then it is used as both the first and last character. int hash(string) char *string; { X return ( string[0] + string[strlen(string)-1] ) % TableSize; X/* Returns a pointer to the bucket in the hash table corresponding to X the specified string and name type. If none is found then NULL is X returned. bucket *findid(string, name_type) char *string; int name_type; { X bucket *entry; X entry = table[hash(string)]; X while (entry != NULL && (strcmp(string, entry->name) != 0 X || entry->attribute->field_name != name_type)) X entry = entry->next; X return entry; X/* Returns true iff a string of name type already appears in the symbol X table. boolean intable(string, name_type) char *string; int name_type; { X if (findid(string, name_type) != NULL) X return true; X else X return false; X/* Enters the identifier, string, into the symbol table along with X its associated attribute, attr. A copy of the string is made. void enterid(string, attr) char *string; attr_rec attr; { X bucket *entry; X entry = findid(string, attr.field_name); X /* If string is not present, then add it. */ X if (entry == NULL) { X int index; X index = hash(string); X entry = (bucket*) mymalloc(sizeof(bucket)); X entry->name = mymalloc(strlen(string) + 1); X strcpy(entry->name, string); X entry->attribute = (attr_rec*) mymalloc(sizeof(attr_rec)); X *(entry->attribute) = attr; X entry->next = table[index]; X table[index] = entry; X/* Returns the attribute associated with the specified string and name type. */ attr_rec *get_attribute(string, name_type) char *string; int name_type; { X bucket *entry; X entry = findid(string, name_type); X if (entry != NULL) return entry->attribute; X else return NULL; END_OF_FILE if test 3217 -ne `wc -c <'compiler/symtable.c'`; then echo shar: \"'compiler/symtable.c'\" unpacked with wrong size! # end of 'compiler/symtable.c' if test -f 'compiler/symtable.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'compiler/symtable.h'\" echo shar: Extracting \"'compiler/symtable.h'\" \(976 characters\) sed "s/^X//" >'compiler/symtable.h' <<'END_OF_FILE' X/* symtable.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X/* The exported declarations for using the symbol table. */ X#define VARIABLE 0 X#define FIELD 1 extern void initsymboltable(); extern void enterid(); extern boolean intable(); extern attr_rec *get_attribute(); END_OF_FILE if test 976 -ne `wc -c <'compiler/symtable.h'`; then echo shar: \"'compiler/symtable.h'\" unpacked with wrong size! # end of 'compiler/symtable.h' if test ! -d 'driver' ; then echo shar: Creating directory \"'driver'\" mkdir 'driver' if test -f 'driver/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'driver/Makefile'\" echo shar: Extracting \"'driver/Makefile'\" \(2056 characters\) sed "s/^X//" >'driver/Makefile' <<'END_OF_FILE' X# Makefile X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# Installation directories. BIN=/usr/local/bin LIB=/usr/local/lib/cellular MAN=/usr/man/manl MAN_EXT=l X# The default maximum size of a single dimension within Cellang programs. MAX_DIM_SIZE=64 X# If you want to have the Cellang compiler configured to compile the viewer X# into the executables then assign COMBINED the value "1", otherwise assign X# a "0". This makes for faster display of many automata, though it does need X# X11 to run them. COMBINED=0 # 0 or 1 X# Dependencies all: pe-scam pe-scam.${MAN_EXT} install: all X - mkdir -p ${BIN} X - mkdir -p ${MAN} X install pe-scam ${BIN}/pe-scam X install -m 644 pe-scam.${MAN_EXT} ${MAN}/pe-scam.${MAN_EXT} deinstall: X /bin/rm -f ${BIN}/pe-scam X /bin/rm -f ${MAN}/pe-scam.${MAN_EXT} clean: X /bin/rm -f *.o *.tab.h *.tab.c *.aux *.dvi *.log *.toc \ X pe-scam core pe-scam.${MAN_EXT} realclean: clean pe-scam: pe-scam.sh X sed -e 's?YOUR_LIB?$(LIB)?' \ X -e 's?YOUR_BIN?$(BIN)?' \ X -e 's?YOUR_CC?$(CC)?' \ X -e 's?YOUR_CFLAGS?$(CFLAGS)?' \ X -e 's?YOUR_MAX_DIM_SIZE?$(MAX_DIM_SIZE)?' \ X -e 's?YOUR_COMBINED?$(COMBINED)?' \ X pe-scam.sh > pe-scam X chmod u+rx pe-scam pe-scam.${MAN_EXT}: pe-scam.man X sed -e 's?LIB_DIR?$(LIB)?' \ X -e 's?MAN_EXT?$(MAN_EXT)?g' \ X -e 's?MAX_DIM_SIZE?$(MAX_DIM_SIZE)?g' \ X pe-scam.man > pe-scam.${MAN_EXT} END_OF_FILE if test 2056 -ne `wc -c <'driver/Makefile'`; then echo shar: \"'driver/Makefile'\" unpacked with wrong size! # end of 'driver/Makefile' if test -f 'driver/pe-scam.sh' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'driver/pe-scam.sh'\" echo shar: Extracting \"'driver/pe-scam.sh'\" \(3453 characters\) sed "s/^X//" >'driver/pe-scam.sh' <<'END_OF_FILE' X#!/bin/sh X# pe-scam.sh X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. LIB=YOUR_LIB BIN=YOUR_BIN CC=YOUR_CC MAX_DIM_SIZE=YOUR_MAX_DIM_SIZE COMBINED=YOUR_COMBINED CFLAGS='YOUR_CFLAGS' USAGE="usage: ... | `basename $0` [-r timefile] [-c codefile] \ X (-o | [-curses | -x11] [-display X11_display]\ X [-p n] [-s n] [-map mapfile] [-f n]\ X [-dim [n|n..n]{,n|,n..n}])" trap "exit" 0 CODEFILE="a.pe-scam" while (test $# -gt 0) X case $1 in X '-o') if test -n "$CURSES" -o \ X -n "$X11" -o \ X -n "$X_DISPLAY" -o \ X -n "$MAPFILE" -o \ X -n "$PAUSE" -o \ X -n "$SIZE" -o \ X -n "$FIELD" X then X echo $USAGE X exit 1 X else X OUTPUT=yes X fi X ;; X '-c') CODEFILE=$2 X shift X ;; X '-r') if test "$COMBINED" = "0" X then X TIMEFILE=$2 X else X TIMEFILE="-r $2" X fi X shift X ;; X '-curses') X if test -n "$OUTPUT" X then X echo $USAGE X exit 1 X else X CURSES=$1 X fi X ;; X '-x11') if test -n "$OUTPUT" X then X echo $USAGE X exit 1 X else X X11=$1 X fi X ;; X '-display') X if test -n "$OUTPUT" X then X echo $USAGE X exit 1 X else X X_DISPLAY="-display $2" X fi X shift X ;; X '-map') if test -n "$OUTPUT" X then X echo $USAGE X exit 1 X else X MAPFILE="-map $2" X fi X shift X ;; X '-p') if test -n "$OUTPUT" X then X echo $USAGE X exit 1 X else X PAUSE="-p $2" X fi X shift X ;; X '-s') if test -n "$OUTPUT" X then X echo $USAGE X exit 1 X else X SIZE="-s $2" X fi X shift X ;; X '-f') if test -n "$OUTPUT" X then X echo $USAGE X exit 1 X else X FIELD="-f $2" X fi X shift X ;; X '-dim') if test -n "$OUTPUT" X then X echo $USAGE X exit 1 X else X DIM="$2" X fi X shift X ;; X *) echo "Unknown flag, '$1'." X echo $USAGE X exit 1 X ;; X esac X shift X# Fix up the TIMEFILE is necessary. if test "$COMBINED" = "0" -a -z "$TIMEFILE" X TIMEFILE="-" X# Make sure there is a valid codefile if test ! -x $CODEFILE X echo $USAGE X exit 1 X# Perform the pe-scam simulation. if test "$OUTPUT" = "yes" X if test "$COMBINED" = "0" X then X $CODEFILE $TIMEFILE X else X $CODEFILE $TIMEFILE -o X # If no -dim option given, then use the default. X if test -z "$DIM" X then X # Display only a small portion if using curses. X if test -n "$CURSES" X then X DIM=0..20,0..20 X else X MAX_DIM_SIZE=`echo "$MAX_DIM_SIZE 1 - p" | dc` X DIM=0..${MAX_DIM_SIZE},0..${MAX_DIM_SIZE} X fi X if test "$COMBINED" = "0" X then X $CODEFILE $TIMEFILE | \ X $BIN/cellview $CURSES $X11 $MAPFILE $SIZE $PAUSE \ X $FIELD $X_DISPLAY -dim $DIM X else X $CODEFILE $TIMEFILE \ X $CURSES $X11 $MAPFILE $SIZE $PAUSE \ X $FIELD $X_DISPLAY -dim $DIM END_OF_FILE if test 3453 -ne `wc -c <'driver/pe-scam.sh'`; then echo shar: \"'driver/pe-scam.sh'\" unpacked with wrong size! # end of 'driver/pe-scam.sh' if test ! -d 'examples' ; then echo shar: Creating directory \"'examples'\" mkdir 'examples' if test -f 'examples/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/Makefile'\" echo shar: Extracting \"'examples/Makefile'\" \(2393 characters\) sed "s/^X//" >'examples/Makefile' <<'END_OF_FILE' X# Makefile X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# The place where cellc can be found BIN=/usr/local/bin X# The default (maximum) sizes associated with Cellang programs. MAX_DIM_SIZE=64 X# Choose a C compiler and options. CC = gcc CFLAGS = -O -ansi -pedantic X# Rules (default.mk on SunOS uses a -target option not supported by GNU C) COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c X# Dependencies all: show \ X bin/life bin/gas bin/dist bin/srdp bin/parity bin/cparity \ X data/srdp data/gas data/dist install: all X - mkdir -p ${LIB} X cp -r . ${LIB}/examples X /bin/rm -f ${LIB}/examples/show.sh X /bin/rm -f ${LIB}/examples/Makefile X /bin/rm -f ${LIB}/examples/gas_data_gen* X /bin/rm -f ${LIB}/examples/srdp_data_gen* X /bin/rm -f ${LIB}/examples/dist_data_gen* X chmod -R uog+r ${LIB}/examples clean: X /bin/rm -f show bin/* X /bin/rm -f gas_data_gen srdp_data_gen dist_data_gen X /bin/rm -f data/gas data/srdp data/dist X find . -name core -exec /bin/rm -f {} \; realclean: clean deinstall: X /bin/rm -rf ${LIB}/examples show: show.sh X sed -e 's?YOUR_BIN?$(BIN)?' show.sh > show X chmod uog+rx show bin/life: src/life X ../compiler/cellc -o bin/life src/life bin/gas: src/gas X ../compiler/cellc -o bin/gas src/gas bin/dist: src/dist X ../compiler/cellc -o bin/dist src/dist bin/srdp: src/srdp X ../compiler/cellc -o bin/srdp src/srdp bin/parity: src/parity X ../compiler/cellc -o bin/parity src/parity bin/cparity: src/cparity X ../compiler/cellc -o bin/cparity src/cparity data/srdp: srdp_data_gen X ./srdp_data_gen ${MAX_DIM_SIZE} > data/srdp data/gas: gas_data_gen X ./gas_data_gen ${MAX_DIM_SIZE} > data/gas data/dist: dist_data_gen X ./dist_data_gen ${MAX_DIM_SIZE} > data/dist END_OF_FILE if test 2393 -ne `wc -c <'examples/Makefile'`; then echo shar: \"'examples/Makefile'\" unpacked with wrong size! # end of 'examples/Makefile' if test -f 'examples/README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/README'\" echo shar: Extracting \"'examples/README'\" \(1312 characters\) sed "s/^X//" >'examples/README' <<'END_OF_FILE' X# README X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This directory contains several sample Cellang programs. The command "show" shows which programs are available. To see one of them do either: X show name X show name host both will run the Cellang program corresponding to name (found in the "src" directory), but the second will assume that the results are being displayed in X windows and should be displayed on the named host. The "bin" directory contains the executables for the Cellang programs which appear in the "src" directory. The input files to each automata appear in the "data" directory. END_OF_FILE if test 1312 -ne `wc -c <'examples/README'`; then echo shar: \"'examples/README'\" unpacked with wrong size! # end of 'examples/README' if test ! -d 'examples/bin' ; then echo shar: Creating directory \"'examples/bin'\" mkdir 'examples/bin' if test ! -d 'examples/data' ; then echo shar: Creating directory \"'examples/data'\" mkdir 'examples/data' if test -f 'examples/data/cparity' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/data/cparity'\" echo shar: Extracting \"'examples/data/cparity'\" \(15 characters\) sed "s/^X//" >'examples/data/cparity' <<'END_OF_FILE' X[32, 32] = 1 END_OF_FILE if test 15 -ne `wc -c <'examples/data/cparity'`; then echo shar: \"'examples/data/cparity'\" unpacked with wrong size! # end of 'examples/data/cparity' if test -f 'examples/data/life' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/data/life'\" echo shar: Extracting \"'examples/data/life'\" \(713 characters\) sed "s/^X//" >'examples/data/life' <<'END_OF_FILE' X[27, 16] = 1 X[27, 17] = 1 X[20, 17] = 1 X[20, 21] = 1 X[21, 18] = 1 X[21, 19] = 1 X[21, 20] = 1 X[22, 18] = 1 X[22, 19] = 1 X[22, 20] = 1 X[28, 23] = 1 X[29, 24] = 1 X[29, 25] = 1 X[30, 23] = 1 X[30, 24] = 1 X[28, 18] = 1 X[28, 19] = 1 X[29, 18] = 1 X[29, 19] = 1 X[30, 18] = 1 X[30, 19] = 1 X[31, 19] = 1 X[31, 20] = 1 X[27, 18] = 1 X[19, 22] = 1 X[18, 17] = 1 X[19, 16] = 1 X[17, 18] = 1 X[17, 19] = 1 X[17, 20] = 1 X[18, 21] = 1 X[6, 19] = 1 X[6, 20] = 1 X[7, 19] = 1 X[7, 20] = 1 X[28, 15] = 1 X[28, 16] = 1 X[29, 15] = 1 X[29, 16] = 1 X[30, 15] = 1 X[30, 16] = 1 X[30, 17] = 1 X[31, 14] = 1 X[31, 15] = 1 X[40, 18] = 1 X[41, 18] = 1 X[40, 17] = 1 X[41, 17] = 1 X[59, 54] = 1 X[56, 51] = 1 X[56, 52] = 1 X[57, 51] = 1 X[57, 53] = 1 X[58, 53] = 1 X[59, 53] = 1 END_OF_FILE if test 713 -ne `wc -c <'examples/data/life'`; then echo shar: \"'examples/data/life'\" unpacked with wrong size! # end of 'examples/data/life' if test -f 'examples/data/parity' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/data/parity'\" echo shar: Extracting \"'examples/data/parity'\" \(15 characters\) sed "s/^X//" >'examples/data/parity' <<'END_OF_FILE' X[32, 32] = 1 END_OF_FILE if test 15 -ne `wc -c <'examples/data/parity'`; then echo shar: \"'examples/data/parity'\" unpacked with wrong size! # end of 'examples/data/parity' if test -f 'examples/dist_data_gen.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/dist_data_gen.c'\" echo shar: Extracting \"'examples/dist_data_gen.c'\" \(1457 characters\) sed "s/^X//" >'examples/dist_data_gen.c' <<'END_OF_FILE' X/* dist_data_gen.c X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X/* Generate the input data used by dist. A single command line argument X indicates the size of each of two dimensions of the cell universe. X#include int main(argc, argv) int argc; char *argv[]; { X int max_size = atoi(argv[1]); X int x, y; X printf("0\n"); X for (x = 0; x < max_size; x++) X for (y = 0; y < max_size; y++) { X /* Write cell location. */ X printf("[%d, %d] = ", x, y); X /* Write "which" field value. */ X if ((x+y)%2 == 0) X printf("1"); X else X printf("0"); X /* Write "dist" field value. */ X if (x == max_size/2 && X (y == max_size/2 || X y == max_size/2 + (max_size%2?1:-1))) X printf(", 1"); X printf("\n"); X return 0; END_OF_FILE if test 1457 -ne `wc -c <'examples/dist_data_gen.c'`; then echo shar: \"'examples/dist_data_gen.c'\" unpacked with wrong size! # end of 'examples/dist_data_gen.c' if test -f 'examples/gas_data_gen.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/gas_data_gen.c'\" echo shar: Extracting \"'examples/gas_data_gen.c'\" \(1640 characters\) sed "s/^X//" >'examples/gas_data_gen.c' <<'END_OF_FILE' X/* gas_data_gen.c X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X/* Generate the input data used by gas. A single command line argument X indicates the size of each of two dimensions of the cell universe. X#include int main(argc, argv) int argc; char *argv[]; { X int max_size = atoi(argv[1]); X int x, y; X printf("0\n"); X for (x = 0; x < max_size; x++) X for (y = 0; y < max_size; y++) { X /* Write cell location. */ X printf("[%d, %d] = ", x, y); X /* Write "which" field value. */ X if (x%2 == 0 && y%2 == 0) X printf("3"); X else if (x%2 == 0 && y%2 == 1) X printf("1"); X else if (x%2 == 1 && y%2 == 0) X printf("2"); X else X printf("0"); X /* Write "rand" field value. */ X printf(", %d", random()%2); X /* Write "gas" field value. */ X if (0.33*max_size < x && x < 0.66*max_size X && X 0.33*max_size < y && y < 0.66*max_size) X printf(", 1"); X printf("\n"); X return 0; END_OF_FILE if test 1640 -ne `wc -c <'examples/gas_data_gen.c'`; then echo shar: \"'examples/gas_data_gen.c'\" unpacked with wrong size! # end of 'examples/gas_data_gen.c' if test ! -d 'examples/map' ; then echo shar: Creating directory \"'examples/map'\" mkdir 'examples/map' if test -f 'examples/map/srdp' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/map/srdp'\" echo shar: Extracting \"'examples/map/srdp'\" \(100 characters\) sed "s/^X//" >'examples/map/srdp' <<'END_OF_FILE' X0 65535 0 0 X1 0 65535 0 X2 0 65535 65535 X3 0 0 65535 X4 65535 0 65535 END_OF_FILE if test 100 -ne `wc -c <'examples/map/srdp'`; then echo shar: \"'examples/map/srdp'\" unpacked with wrong size! # end of 'examples/map/srdp' if test -f 'examples/show.sh' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/show.sh'\" echo shar: Extracting \"'examples/show.sh'\" \(2621 characters\) sed "s/^X//" >'examples/show.sh' <<'END_OF_FILE' X#!/bin/sh X# show.sh X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# Compile and run with the appropriate data file (if needed/available) X# a Cellang program contained within the filename given. X# Location of cellview BIN=YOUR_BIN WD=`dirname $0` CC=gcc X# Check the usage USAGE="usage: `basename $1` filename [ x11_display ]" if test $# -eq 0 X echo "The available examples are:" X echo " " X echo " life -- the game of life (with gun and eater)" X echo " gas -- simulates diffusion of two gases" X echo " dist -- shows distance using hexagonal neighborhood" X echo " srdp -- scissors, rock, dynamite, paper" X echo " parity -- a black & white position parity matrix" X echo " cparity -- a color position parity matrix" X echo " " X exit 0 elif test $# -gt 2 X echo $USAGE X exit 1 X# Find the executable NAME=$1 if test ! -x $WD/bin/$NAME X if test ! -r $WD/src/$NAME X then X echo "`basename $0`: file '$WD/src/$NAME' not found" X else X echo "`basename $0`: file '$WD/src/$NAME' not compiled" X exit 1 echo "displaying results of '$NAME' ..." X# Determine the type of display, use x11 if either the current terminal X# type is an xterm, or if another machine was given on which to display X# the results. if test "$TERM" = "xterm" -o $# -eq 2 X DISPLAY=-x11 X if (test $# -eq 2) then X DISPLAY="$DISPLAY -display $2:0" X else X DISPLAY="$DISPLAY -display `hostname`:0" X DISPLAY=-curses X# Use the proper color map. if test "$NAME" = "srdp" X MAP="-map map/srdp" X MAP="" X# Display the proper field value. if test "$NAME" = "gas" X FIELD="-f 3" elif test "$NAME" = "dist" X FIELD="-f 2" X FIELD="-f 1" X# Display the proper proportion for cells. if test "$NAME" = "dist" X SIZE="-s 5,3" X SIZE="-s 3,3" X# Run the program(s). X$BIN/pe-scam -c $WD/bin/$NAME $DISPLAY $SIZE $FIELD $MAP < $WD/data/$NAME END_OF_FILE if test 2621 -ne `wc -c <'examples/show.sh'`; then echo shar: \"'examples/show.sh'\" unpacked with wrong size! # end of 'examples/show.sh' if test ! -d 'examples/src' ; then echo shar: Creating directory \"'examples/src'\" mkdir 'examples/src' if test -f 'examples/src/cparity' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/src/cparity'\" echo shar: Extracting \"'examples/src/cparity'\" \(924 characters\) sed "s/^X//" >'examples/src/cparity' <<'END_OF_FILE' X# cparity X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# A color version of the parity program. X2 dimensions of 0..255 sum := [0, 1] + [1, 1] + [1, 0] + [-1, 1] + [-1, 0] + [-1, -1] X + [0, -1] + [1, -1] cell := sum % 256 END_OF_FILE if test 924 -ne `wc -c <'examples/src/cparity'`; then echo shar: \"'examples/src/cparity'\" unpacked with wrong size! # end of 'examples/src/cparity' if test -f 'examples/src/dist' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/src/dist'\" echo shar: Extracting \"'examples/src/dist'\" \(2060 characters\) sed "s/^X//" >'examples/src/dist' <<'END_OF_FILE' X# dist X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# Use a hexagonal neighborhood to compute the distance(s) from X# established points (cells with non-zero values for the dist field). X# The hexagonal neighborhood is composed of stagered blocks of two X# cells stacked upon one another (imagine a hexagon which has been X# pushed in at the sides to form a rectangle). The which fields are X# set according the the following scheme (with 1 being the top of a X# hexagon and 0 the bottom). X# 0 1 0 1 0 1 X# 1 0 1 0 1 0 X# 0 1 0 1 0 1 X# 1 0 1 0 1 0 X2 dimensions of X which of 0..1 X dist of 0..255 X# Identification of the neighboring cells. if cell.which = 0 then X north := [0, 1] X ne := [1, 0] X se := [1, -1] X south := [0, -2] X sw := [-1, -1] X nw := [-1, 0] X north := [0, 2] X ne := [1, 1] X se := [1, 0] X south := [0, -1] X sw := [-1, 0] X nw := [-1, 1] min_dist := 255 min_dist := north.dist when north.dist < min_dist & north.dist > 0 min_dist := ne.dist when ne.dist < min_dist & ne.dist > 0 min_dist := se.dist when se.dist < min_dist & se.dist > 0 min_dist := south.dist when south.dist < min_dist & south.dist > 0 min_dist := sw.dist when sw.dist < min_dist & sw.dist > 0 min_dist := nw.dist when nw.dist < min_dist & nw.dist > 0 cell.dist := min_dist+4 when cell.dist = 0 & min_dist < 255 END_OF_FILE if test 2060 -ne `wc -c <'examples/src/dist'`; then echo shar: \"'examples/src/dist'\" unpacked with wrong size! # end of 'examples/src/dist' if test -f 'examples/src/gas' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/src/gas'\" echo shar: Extracting \"'examples/src/gas'\" \(2712 characters\) sed "s/^X//" >'examples/src/gas' <<'END_OF_FILE' X# gas X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# Simulate gas diffusion by `randomly' rotating the cell values in a X# Margolus-neighborhood either clockwise or counter-clockwise. The X# groupings are alternations of the two overlapping square neighborhoods: X# 0 1 X# 2 3 2 X# 1 0 X2 dimensions of X which of 0..3 X rand of 0..1 X gas of 0..1 X# Calculate the sum of the random fields in the neighborhood. random := cell.rand + [1, 0].rand + [1, -1].rand + [0, -1].rand X when (cell.which=0 & time%2=1) | (cell.which=3 & time%2=0) X := [-1, 0].rand + cell.rand + [0, -1].rand + [-1, -1].rand X when (cell.which=1 & time%2=1) | (cell.which=2 & time%2=0) X := [-1, 1].rand + [0, 1].rand + cell.rand + [-1, 0].rand X when (cell.which=3 & time%2=1) | (cell.which=0 & time%2=0) X := [0, 1].rand + [1, 1].rand + [1, 0].rand + cell.rand X otherwise X# Alternate between the overlapping neighborhoods if time%2 = 1 then X if random%2 = 1 then X # Clockwise rotation X cell.gas := [0, -1].gas when cell.which = 0 X := [-1, 0].gas when cell.which = 1 X := [0, 1].gas when cell.which = 3 X := [1, 0].gas when cell.which = 2 X else X # Counter-clockwise rotation X cell.gas := [1, 0].gas when cell.which = 0 X := [0, -1].gas when cell.which = 1 X := [-1, 0].gas when cell.which = 3 X := [0, 1].gas when cell.which = 2 X end X if random%2 = 1 then X # Clockwise rotation X cell.gas := [0, -1].gas when cell.which = 3 X := [-1, 0].gas when cell.which = 2 X := [0, 1].gas when cell.which = 0 X := [1, 0].gas when cell.which = 1 X else X # Counter-clockwise rotation X cell.gas := [1, 0].gas when cell.which = 3 X := [0, -1].gas when cell.which = 2 X := [-1, 0].gas when cell.which = 0 X := [0, 1].gas when cell.which = 1 X end X# Stir the random values, so that they keep changing. cell.rand := ([1, 0].rand + [0, 1].rand + [-1, 0].rand + [0, -1].rand X + cell.rand)%2 END_OF_FILE if test 2712 -ne `wc -c <'examples/src/gas'`; then echo shar: \"'examples/src/gas'\" unpacked with wrong size! # end of 'examples/src/gas' if test -f 'examples/src/life' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/src/life'\" echo shar: Extracting \"'examples/src/life'\" \(982 characters\) sed "s/^X//" >'examples/src/life' <<'END_OF_FILE' X# life X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# This program implements a 2 dimensional game of life. X2 dimensions of 0..1 sum := [0, 1] + [1, 1] + [1, 0] + [-1, 1] + [-1, 0] + [-1, -1] X + [0, -1] + [1, -1] cell := 1 when (sum = 2 & cell = 1) | sum = 3 X := 0 otherwise END_OF_FILE if test 982 -ne `wc -c <'examples/src/life'`; then echo shar: \"'examples/src/life'\" unpacked with wrong size! # end of 'examples/src/life' if test -f 'examples/src/parity' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/src/parity'\" echo shar: Extracting \"'examples/src/parity'\" \(904 characters\) sed "s/^X//" >'examples/src/parity' <<'END_OF_FILE' X# parity X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# A simple parity program X2 dimensions of 0..1 sum := [0, 1] + [1, 1] + [1, 0] + [-1, 1] + [-1, 0] + [-1, -1] X + [0, -1] + [1, -1] cell := sum % 2 END_OF_FILE if test 904 -ne `wc -c <'examples/src/parity'`; then echo shar: \"'examples/src/parity'\" unpacked with wrong size! # end of 'examples/src/parity' if test -f 'examples/src/srdp' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/src/srdp'\" echo shar: Extracting \"'examples/src/srdp'\" \(1967 characters\) sed "s/^X//" >'examples/src/srdp' <<'END_OF_FILE' X# srdp X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# scissors (0), rock (1), dynamite (2), paper (3) X2 dimensions of 0..2 X# Get the Moore neighborhood north := [0, 1] ne := [1, 1] east := [1, 0] se := [1, -1] south := [0, -1] sw := [-1, -1] west := [-1, 0] nw := [-1, 1] threshold := 3 scissors := 0 rock := 1 dynamite := 2 paper := 3 scissors_sum := (north = scissors) + (ne = scissors) + (east = scissors) + X (se = scissors) + (south = scissors) + (sw = scissors) + X (west = scissors) + (nw = scissors) rock_sum := (north = rock) + (ne = rock) + (east = rock) + (se = rock) + X (south = rock) + (sw = rock) + (west = rock) + (nw = rock) dynamite_sum := (north = dynamite) + (ne = dynamite) + (east = dynamite) + X (se = dynamite) + (south = dynamite) + (sw = dynamite) + X (west = dynamite) + (nw = dynamite) paper_sum := (north = paper) + (ne = paper) + (east = paper) + (se = paper) + X (south = paper) + (sw = paper) + (west = paper) + (nw = paper) X# Find out who lives and who dies. cell := scissors when scissors_sum >= threshold & cell = paper X := rock when rock_sum >= threshold & cell = scissors X := dynamite when dynamite_sum >= threshold & cell = rock X := paper when paper_sum >= threshold & cell = dynamite END_OF_FILE if test 1967 -ne `wc -c <'examples/src/srdp'`; then echo shar: \"'examples/src/srdp'\" unpacked with wrong size! # end of 'examples/src/srdp' if test -f 'examples/srdp_data_gen.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examples/srdp_data_gen.c'\" echo shar: Extracting \"'examples/srdp_data_gen.c'\" \(1166 characters\) sed "s/^X//" >'examples/srdp_data_gen.c' <<'END_OF_FILE' X/* srdp_data_gen.c X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X/* Generate the input data used by srdp. A single command line argument X indicates the size of each of two dimensions of the cell universe. X#include int main(argc, argv) int argc; char *argv[]; { X int max_size = atoi(argv[1]); X int x, y; X printf("0\n"); X for (x = 0; x < max_size; x++) X for (y = 0; y < max_size; y++) X printf("[%d, %d] = %d\n", x, y, random()%4); X return 0; END_OF_FILE if test 1166 -ne `wc -c <'examples/srdp_data_gen.c'`; then echo shar: \"'examples/srdp_data_gen.c'\" unpacked with wrong size! # end of 'examples/srdp_data_gen.c' if test ! -d 'viewer' ; then echo shar: Creating directory \"'viewer'\" mkdir 'viewer' if test -f 'viewer/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/Makefile'\" echo shar: Extracting \"'viewer/Makefile'\" \(2650 characters\) sed "s/^X//" >'viewer/Makefile' <<'END_OF_FILE' X# Makefile X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X# Installation directories. BIN=/usr/local/bin LIB=/usr/local/lib/cellular MAN=/usr/man/manl MAN_EXT=l X# If you want to have the Cellang compiler configured to compile the viewer X# into the executables then assign COMBINED the value "1", otherwise assign X# a "0". This makes for faster display of many automata, though it does need X# X11 to run them. COMBINED=0 # 0 or 1 X# Choose a C compiler and options. CC = gcc CFLAGS = -O -ansi -pedantic CDEFINES= -DLIB_DIR=\"${LIB}\" CLIB = -lm -lcurses -ltermcap -lX11 X# Rules (default.mk on SunOS uses a -target option not supported by GNU C) COMPILE.c=$(CC) $(CFLAGS) $(CDEFINES) $(CPPFLAGS) -c X# Dependencies all: cellview cellview.${MAN_EXT} install: all X - mkdir -p ${BIN} X - mkdir -p ${LIB} X - mkdir -p ${MAN} X install cellview ${BIN}/cellview X install -m 644 color-map ${LIB}/color-map X install -m 644 bw-map ${LIB}/bw-map X install -m 644 curses-map ${LIB}/curses-map X install -m 644 cellview.${MAN_EXT} ${MAN}/cellview.${MAN_EXT} X make CC='$(CC)' CFLAGS='$(CFLAGS)' \ X CDEFINES='${CDEFINES} -DCOMBINED=${COMBINED}' \ X MAN_EXT='${MAN_EXT}' LIB='${LIB}' ${COMBINED} deinstall: X /bin/rm -f ${BIN}/cellview X /bin/rm -f ${MAN}/cellview.${MAN_EXT} X /bin/rm -f ${LIB}/color-map X /bin/rm -f ${LIB}/bw-map X /bin/rm -f ${LIB}/curses-map X /bin/rm -f ${LIB}/*.o clean: X /bin/rm -f *.o core cellview cellview.${MAN_EXT} realclean: clean cellview: curses.o x11.o view.o X ${CC} ${CFLAGS} -o cellview *.o ${CLIB} cellview.${MAN_EXT}: cellview.man X sed -e 's?LIB_DIR?$(LIB)?' \ X -e 's?MAN_EXT?$(MAN_EXT)?g' cellview.man > cellview.${MAN_EXT} view.o: view.c view.h curses.h x11.h boolean.h curses.o: curses.c curses.h view.h boolean.h x11.o: x11.c x11.h view.h boolean.h object_files: curses.o x11.o view.o X make clean X make CC='$(CC)' CFLAGS='$(CFLAGS)' CDEFINES='$(CDEFINES)' object_files X install *.o ${LIB} X make clean END_OF_FILE if test 2650 -ne `wc -c <'viewer/Makefile'`; then echo shar: \"'viewer/Makefile'\" unpacked with wrong size! # end of 'viewer/Makefile' if test -f 'viewer/README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/README'\" echo shar: Extracting \"'viewer/README'\" \(1379 characters\) sed "s/^X//" >'viewer/README' <<'END_OF_FILE' X# README X# Copyright (C) 1992 J Dana Eckart X# This program is free software; you can redistribute it and/or modify X# it under the terms of the GNU General Public License as published by X# the Free Software Foundation; either version 1, or (at your option) X# any later version. X# This program is distributed in the hope that it will be useful, X# but WITHOUT ANY WARRANTY; without even the implied warranty of X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X# GNU General Public License for more details. X# You should have received a copy of the GNU General Public License X# along with CELLULAR-2.0; see the file COPYING. If not, write to the X# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. To install the cellview cellular automata viewer, edit the Makefile to reflect the proper values of: X BIN - installation directory for executables X LIB - installation directory for supporting software X MAN - installation directory for manual pages X MAX_EXT - manual page extension to use for installation Do "make install" to build and install the viewer. In addition, the Makefile also supports the targets: X all: compile, but not install, the software X deinstall: remove an installation X clean: remove all but the distributed files within this directory X realclean: (same as clean) END_OF_FILE if test 1379 -ne `wc -c <'viewer/README'`; then echo shar: \"'viewer/README'\" unpacked with wrong size! # end of 'viewer/README' if test -f 'viewer/boolean.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/boolean.h'\" echo shar: Extracting \"'viewer/boolean.h'\" \(817 characters\) sed "s/^X//" >'viewer/boolean.h' <<'END_OF_FILE' X/* boolean.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X#define boolean int X#define true 1 X#define false 0 END_OF_FILE if test 817 -ne `wc -c <'viewer/boolean.h'`; then echo shar: \"'viewer/boolean.h'\" unpacked with wrong size! # end of 'viewer/boolean.h' if test -f 'viewer/bw-map' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/bw-map'\" echo shar: Extracting \"'viewer/bw-map'\" \(8 characters\) sed "s/^X//" >'viewer/bw-map' <<'END_OF_FILE' END_OF_FILE if test 8 -ne `wc -c <'viewer/bw-map'`; then echo shar: \"'viewer/bw-map'\" unpacked with wrong size! # end of 'viewer/bw-map' if test -f 'viewer/color-map' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/color-map'\" echo shar: Extracting \"'viewer/color-map'\" \(5522 characters\) sed "s/^X//" >'viewer/color-map' <<'END_OF_FILE' X0 0 0 0 X1 65535 1542 0 X2 65535 3084 0 X3 65535 4626 0 X4 65535 6168 0 X5 65535 7710 0 X6 65535 9252 0 X7 65535 10794 0 X8 65535 12336 0 X9 65535 13878 0 X10 65535 15420 0 X11 65535 16962 0 X12 65535 18504 0 X13 65535 20046 0 X14 65535 21588 0 X15 65535 23130 0 X16 65535 24672 0 X17 65535 26214 0 X18 65535 27756 0 X19 65535 29298 0 X20 65535 30840 0 X21 65535 32382 0 X22 65535 33924 0 X23 65535 35466 0 X24 65535 37008 0 X25 65535 38550 0 X26 65535 40092 0 X27 65535 41634 0 X28 65535 43176 0 X29 65535 44718 0 X30 65535 46260 0 X31 65535 47802 0 X32 65535 49344 0 X33 65535 50886 0 X34 65535 52428 0 X35 65535 53970 0 X36 65535 55512 0 X37 65535 57054 0 X38 65535 58596 0 X39 65535 60138 0 X40 65535 61680 0 X41 65535 63222 0 X42 65535 64764 0 X43 65535 65535 0 X44 65535 65535 0 X45 65535 65535 0 X46 65535 65535 0 X47 65535 65535 0 X48 65535 65535 0 X49 65535 65535 0 X50 65535 65535 0 X51 65535 65535 0 X52 65535 65535 0 X53 65535 65535 0 X54 65535 65535 0 X55 65535 65535 0 X56 65535 65535 0 X57 65535 65535 0 X58 65535 65535 0 X59 65535 65535 0 X60 65535 65535 0 X61 63993 65535 0 X62 62451 65535 0 X63 60909 65535 0 X64 59367 65535 0 X65 57825 65535 0 X66 56283 65535 0 X67 54741 65535 0 X68 53199 65535 0 X69 51657 65535 0 X70 50115 65535 0 X71 48573 65535 0 X72 47031 65535 0 X73 45489 65535 0 X74 43947 65535 0 X75 42405 65535 0 X76 40863 65535 0 X77 39321 65535 0 X78 37779 65535 0 X79 36237 65535 0 X80 34695 65535 0 X81 33153 65535 0 X82 31611 65535 0 X83 30069 65535 0 X84 28527 65535 0 X85 26985 65535 0 X86 25443 65535 0 X87 23901 65535 0 X88 22359 65535 0 X89 20817 65535 0 X90 19275 65535 0 X91 17733 65535 0 X92 16191 65535 0 X93 14649 65535 0 X94 13107 65535 0 X95 11565 65535 0 X96 10023 65535 0 X97 8481 65535 0 X98 6939 65535 0 X99 5397 65535 0 X100 3855 65535 0 X101 2313 65535 0 X102 771 65535 0 X103 0 65535 0 X104 0 65535 0 X105 0 65535 0 X106 0 65535 1542 X107 0 65535 3084 X108 0 65535 4626 X109 0 65535 6168 X110 0 65535 7710 X111 0 65535 9252 X112 0 65535 10794 X113 0 65535 12336 X114 0 65535 13878 X115 0 65535 15420 X116 0 65535 16962 X117 0 65535 18504 X118 0 65535 20046 X119 0 65535 21588 X120 0 65535 23130 X121 0 65535 24672 X122 0 65535 26214 X123 0 65535 27756 X124 0 65535 29298 X125 0 65535 30840 X126 0 65535 32382 X127 0 65535 33924 X128 0 65535 35466 X129 0 65535 37008 X130 0 65535 38550 X131 0 65535 40092 X132 0 65535 41634 X133 0 65535 43176 X134 0 65535 44718 X135 0 65535 46260 X136 0 65535 47802 X137 0 65535 49344 X138 0 65535 50886 X139 0 65535 52428 X140 0 65535 53970 X141 0 65535 55512 X142 0 65535 57054 X143 0 65535 58596 X144 0 65535 60138 X145 0 65535 61680 X146 0 65535 63222 X147 0 65535 64764 X148 0 65535 65535 X149 0 65535 65535 X150 0 65535 65535 X151 0 65535 65535 X152 0 65535 65535 X153 0 65535 65535 X154 0 65535 65535 X155 0 65535 65535 X156 0 65535 65535 X157 0 65535 65535 X158 0 65535 65535 X159 0 65535 65535 X160 0 65535 65535 X161 0 65535 65535 X162 0 65535 65535 X163 0 65535 65535 X164 0 65535 65535 X165 0 65535 65535 X166 0 63993 65535 X167 0 62451 65535 X168 0 60909 65535 X169 0 59367 65535 X170 0 57825 65535 X171 0 56283 65535 X172 0 54741 65535 X173 0 53199 65535 X174 0 51657 65535 X175 0 50115 65535 X176 0 48573 65535 X177 0 47031 65535 X178 0 45489 65535 X179 0 43947 65535 X180 0 42405 65535 X181 0 40863 65535 X182 0 39321 65535 X183 0 37779 65535 X184 0 36237 65535 X185 0 34695 65535 X186 0 33153 65535 X187 0 31611 65535 X188 0 30069 65535 X189 0 28527 65535 X190 0 26985 65535 X191 0 25443 65535 X192 0 23901 65535 X193 0 22359 65535 X194 0 20817 65535 X195 0 19275 65535 X196 0 17733 65535 X197 0 16191 65535 X198 0 14649 65535 X199 0 13107 65535 X200 0 11565 65535 X201 0 10023 65535 X202 0 8481 65535 X203 0 6939 65535 X204 0 5397 65535 X205 0 3855 65535 X206 0 2313 65535 X207 0 771 65535 X208 0 0 65535 X209 0 0 65535 X210 0 0 65535 X211 1542 0 65535 X212 3084 0 65535 X213 4626 0 65535 X214 6168 0 65535 X215 7710 0 65535 X216 9252 0 65535 X217 10794 0 65535 X218 12336 0 65535 X219 13878 0 65535 X220 15420 0 65535 X221 16962 0 65535 X222 18504 0 65535 X223 20046 0 65535 X224 21588 0 65535 X225 23130 0 65535 X226 24672 0 65535 X227 26214 0 65535 X228 27756 0 65535 X229 29298 0 65535 X230 30840 0 65535 X231 32382 0 65535 X232 33924 0 65535 X233 35466 0 65535 X234 37008 0 65535 X235 38550 0 65535 X236 40092 0 65535 X237 41634 0 65535 X238 43176 0 65535 X239 44718 0 65535 X240 46260 0 65535 X241 47802 0 65535 X242 49344 0 65535 X243 50886 0 65535 X244 52428 0 65535 X245 53970 0 65535 X246 55512 0 65535 X247 57054 0 65535 X248 58596 0 65535 X249 60138 0 65535 X250 61680 0 65535 X251 63222 0 65535 X252 64764 0 65535 X253 65535 0 65535 X254 65535 0 65535 X255 65535 65535 65535 END_OF_FILE if test 5522 -ne `wc -c <'viewer/color-map'`; then echo shar: \"'viewer/color-map'\" unpacked with wrong size! # end of 'viewer/color-map' if test -f 'viewer/curses-map' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/curses-map'\" echo shar: Extracting \"'viewer/curses-map'\" \(1938 characters\) sed "s/^X//" >'viewer/curses-map' <<'END_OF_FILE' X0 '-' X1 '+' X2 'o' X3 'x' X4 '#' X5 '*' X6 '+' X7 'o' X8 'x' X9 '#' X10 '*' X11 '+' X12 'o' X13 'x' X14 '#' X15 '*' X16 '+' X17 'o' X18 'x' X19 '#' X20 '*' X21 '+' X22 'o' X23 'x' X24 '#' X25 '*' X26 '+' X27 'o' X28 'x' X29 '#' X30 '*' X31 '+' X32 'o' X33 'x' X34 '#' X35 '*' X36 '+' X37 'o' X38 'x' X39 '#' X40 '*' X41 '+' X42 'o' X43 'x' X44 '#' X45 '*' X46 '+' X47 'o' X48 'x' X49 '#' X50 '*' X51 '+' X52 'o' X53 'x' X54 '#' X55 '*' X56 '+' X57 'o' X58 'x' X59 '#' X60 '*' X61 '+' X62 'o' X63 'x' X64 '#' X65 '*' X66 '+' X67 'o' X68 'x' X69 '#' X70 '*' X71 '+' X72 'o' X73 'x' X74 '#' X75 '*' X76 '+' X77 'o' X78 'x' X79 '#' X80 '*' X81 '+' X82 'o' X83 'x' X84 '#' X85 '*' X86 '+' X87 'o' X88 'x' X89 '#' X90 '*' X91 '+' X92 'o' X93 'x' X94 '#' X95 '*' X96 '+' X97 'o' X98 'x' X99 '#' X100 '*' X101 '+' X102 'o' X103 'x' X104 '#' X105 '*' X106 '+' X107 'o' X108 'x' X109 '#' X110 '*' X111 '+' X112 'o' X113 'x' X114 '#' X115 '*' X116 '+' X117 'o' X118 'x' X119 '#' X120 '*' X121 '+' X122 'o' X123 'x' X124 '#' X125 '*' X126 '+' X127 'o' X128 'x' X129 '#' X130 '*' X131 '+' X132 'o' X133 'x' X134 '#' X135 '*' X136 '+' X137 'o' X138 'x' X139 '#' X140 '*' X141 '+' X142 'o' X143 'x' X144 '#' X145 '*' X146 '+' X147 'o' X148 'x' X149 '#' X150 '*' X151 '+' X152 'o' X153 'x' X154 '#' X155 '*' X156 '+' X157 'o' X158 'x' X159 '#' X160 '*' X161 '+' X162 'o' X163 'x' X164 '#' X165 '*' X166 '+' X167 'o' X168 'x' X169 '#' X170 '*' X171 '+' X172 'o' X173 'x' X174 '#' X175 '*' X176 '+' X177 'o' X178 'x' X179 '#' X180 '*' X181 '+' X182 'o' X183 'x' X184 '#' X185 '*' X186 '+' X187 'o' X188 'x' X189 '#' X190 '*' X191 '+' X192 'o' X193 'x' X194 '#' X195 '*' X196 '+' X197 'o' X198 'x' X199 '#' X200 '*' X201 '+' X202 'o' X203 'x' X204 '#' X205 '*' X206 '+' X207 'o' X208 'x' X209 '#' X210 '*' X211 '+' X212 'o' X213 'x' X214 '#' X215 '*' X216 '+' X217 'o' X218 'x' X219 '#' X220 '*' X221 '+' X222 'o' X223 'x' X224 '#' X225 '*' X226 '+' X227 'o' X228 'x' X229 '#' X230 '*' X231 '+' X232 'o' X233 'x' X234 '#' X235 '*' X236 '+' X237 'o' X238 'x' X239 '#' X240 '*' X241 '+' X242 'o' X243 'x' X244 '#' X245 '*' X246 '+' X247 'o' X248 'x' X249 '#' X250 '*' X251 '+' X252 'o' X253 'x' X254 '#' X255 '*' END_OF_FILE if test 1938 -ne `wc -c <'viewer/curses-map'`; then echo shar: \"'viewer/curses-map'\" unpacked with wrong size! # end of 'viewer/curses-map' if test -f 'viewer/curses.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/curses.c'\" echo shar: Extracting \"'viewer/curses.c'\" \(4139 characters\) sed "s/^X//" >'viewer/curses.c' <<'END_OF_FILE' X/* curses.c X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X#include X#include X#include X#include X#include X#include "view.h" X#include "boolean.h" X/* The ratio of the number of columns/lines to be used to make a reasonablly X nice (squarish) display. X#define aspect_ratio 2 X/* When exiting curses, move the cursor to the bottom of the screen, X refresh the screen and exit. void finish_curses() { X erase(); X refresh(); X echo(); X nl(); X move(0, 0); X refresh(); X endwin(); X/* Updates a single cell in the display, but no refresh is done. Use X the lower left hand corner of the screen as the origin. void update_curses(x, y, c) long int x, y; char c; { X int i = x - lower[range_dim_1_index]; X int j = y - lower[range_dim_2_index]; X /* Ignore moves off of the screen area and remember to save X the extra line for printing the time step value. X if (ERR != move(LINES-j-2, i*aspect_ratio)) X addch(c); X/* Display all the cell_vals in the universe. */ void display_curses_cells() { X refresh(); X/* Does the necessary setup so that everything works correctly. */ void setup_curses(map_name) char *map_name; { X /* The "real" curses setup. */ X initscr(); X noecho(); X /* Make sure the desired cell_vals will fit in a curses view of X the world. Unfortunately, this view is limited because X stdin is already being used to get the cell values from, X and thus cannot be used to get commands for moving the X window into the cellular universe around. Remember to X save an extra line for displaying the time step. X if (range[range_dim_1_index]*aspect_ratio-1 > COLS) { X fprintf(stderr, X "First dimension is limited to %d indices.\n", X COLS/aspect_ratio); X finish_curses(); X exit(1); X if (range_dim_given == 2 && range[range_dim_2_index] > LINES-1) { X fprintf(stderr, X "Second dimension is limited to %d indices.\n", X LINES-1); X finish_curses(); X exit(1); X /* If a map file was given, read it; otherwise use the default. */ X if (NULL == map_name) { X char *default_file = "curses-map"; X map_name = (char*) malloc((unsigned int) (strlen(LIB_DIR) + X strlen(default_file) + 2)); X if (NULL == map_name) X error("Out of memory", (char*) NULL); X sprintf(map_name, "%s/%s", LIB_DIR, default_file); X read_map(map_name, MAX_MAP_SIZE); X/* Display the cell_vals visible within the curses window. */ void display_curses (field) int field; { X long int i, j; X /* Initialize the curses positions to the character values. */ X for (i = lower[range_dim_1_index]; i <= upper[range_dim_1_index]; i++) X for (j = lower[range_dim_2_index]; j <= upper[range_dim_2_index]; j++) X update_curses(i, j, (char) X map_value(cell_vals[(i - X lower[range_dim_1_index]) * X range[range_dim_2_index] + X j - lower[range_dim_2_index]])); X display_curses_cells(); X while (1) { X#if !COMBINED X if (next_time >= 0) X#endif X char string[MAX_STRING_SIZE]; X /* Write out the current time step. */ X sprintf(string, "time = %d", _time); X move(LINES-1, 0); X addstr(string); X /* Read and display the cell_vals. */ X#if COMBINED X cellang_main(false, field); X#else X read_cell_block(); X#endif X display_curses_cells(); X#if !COMBINED X if (next_time >= 0) _time++; X#endif X /* Pause times of 0 or less are ignored. */ X if (pause_time > 0) sleep((unsigned int) pause_time); END_OF_FILE if test 4139 -ne `wc -c <'viewer/curses.c'`; then echo shar: \"'viewer/curses.c'\" unpacked with wrong size! # end of 'viewer/curses.c' if test -f 'viewer/curses.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/curses.h'\" echo shar: Extracting \"'viewer/curses.h'\" \(878 characters\) sed "s/^X//" >'viewer/curses.h' <<'END_OF_FILE' X/* curses.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. extern void finsih_curses(); extern void setup_curses(); extern void display_curses(); extern void update_curses(); END_OF_FILE if test 878 -ne `wc -c <'viewer/curses.h'`; then echo shar: \"'viewer/curses.h'\" unpacked with wrong size! # end of 'viewer/curses.h' if test -f 'viewer/view.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/view.h'\" echo shar: Extracting \"'viewer/view.h'\" \(1823 characters\) sed "s/^X//" >'viewer/view.h' <<'END_OF_FILE' X/* view.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X#include X#include X#include "boolean.h" X#define MAX_STRING_SIZE 256 X#define MAX_MAP_SIZE 256 X/* Contains the current time. */ extern unsigned long int _time; X#if !COMBINED X/* Contains the next time at which to read data. */ extern long int next_time; X#endif X/* Time to pause between time steps, in order to slow things down. */ extern long int pause_time; X/* The cellular universe which contains the colors/characters that X correspond to the cell values which are read. typedef long int celltype; extern celltype *cell_vals; X/* The following variables are the lower and upper bounds of the X dimensions to display. X#define MAX_DIMS 256 extern int dim_given, range_dim_given, range_dim_1_index, range_dim_2_index; extern long int lower[], upper[], range[]; X/* Holds the number of character/color map entries given. */ extern int max_map_entry; extern void read_cell_block(); extern void read_map(); extern void error(); extern celltype map_value(); X#if COMBINED X extern void cellang_main(); X extern void init_cells(); X#endif END_OF_FILE if test 1823 -ne `wc -c <'viewer/view.h'`; then echo shar: \"'viewer/view.h'\" unpacked with wrong size! # end of 'viewer/view.h' if test -f 'viewer/x11.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'viewer/x11.h'\" echo shar: Extracting \"'viewer/x11.h'\" \(891 characters\) sed "s/^X//" >'viewer/x11.h' <<'END_OF_FILE' X/* x11.h X Copyright (C) 1992 J Dana Eckart X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X You should have received a copy of the GNU General Public License X along with CELLULAR-2.0; see the file COPYING. If not, write to the X Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. extern celltype setcolor(); extern void finish_x11(); extern void setup_x11(); extern void display_x11(); extern void update_x11(); END_OF_FILE if test 891 -ne `wc -c <'viewer/x11.h'`; then echo shar: \"'viewer/x11.h'\" unpacked with wrong size! # end of 'viewer/x11.h' echo shar: End of archive 1 \(of 3\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi if test "${MISSING}" = "" ; then echo You have unpacked all 3 archives. rm -f ark[1-9]isdone echo You still need to unpack the following archives: echo " " ${MISSING} ## End of shell archive. exit 0