home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / cellsim / v2_5 / rule_src / cyclm256.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-26  |  925 b   |  44 lines

  1. /*
  2.  * File: cycle.m256.c
  3.  *   By: Dave Hiebeler
  4.  *       hiebeler@turing.cs.rpi.edu
  5.  *       September 1989
  6.  *
  7.  * A rule based on A.K. Dewdney's "Computer Recreations" article
  8.  * in the August 1989 scientific american
  9.  *
  10.  * "parm1" says how many states to use.
  11.  * Start with a random configuration of cells with values between
  12.  * 0 and parm-1.  For example, with 16 states, start with a random
  13.  * array of values between 0 and 15 inclusive (use the "general"
  14.  * random array generator to do this).
  15.  *
  16.  * Observe the effects of varying parm1 slightly.
  17.  */
  18.  
  19. #include "nborhood.h"
  20.  
  21. byte cycle();
  22.  
  23. void
  24. init_function()
  25. {
  26.     update_function = cycle;
  27.     parm1 = 16;
  28. }
  29.  
  30. byte
  31. cycle(nbors)
  32. moore_nbors *nbors;
  33. {
  34.     int tmp;
  35.  
  36.     Get_moore_nbors;
  37.     tmp = (c + 1) % parm1;
  38.     if ((tmp == tl) || (tmp == l) || (tmp == bl) || (tmp == t) ||
  39.     (tmp == b) || (tmp == tr) || (tmp == r) || (tmp == br))
  40.     return tmp;
  41.     else
  42.     return c;
  43. }
  44.