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

  1. /*
  2.  * File: cycle.v256.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.  
  20. #include "nborhood.h"
  21.  
  22. byte v_cycle();
  23.  
  24. void
  25. init_function()
  26. {
  27.     update_function = v_cycle;
  28.     parm1 = 8;
  29. }
  30.  
  31. byte
  32. v_cycle(nbors)
  33. vonn_nbors *nbors;
  34. {
  35.     int tmp;
  36.  
  37.     Get_vonn_nbors;
  38.     tmp = (c + 1) % parm1;
  39.     if ((tmp == tl) || (tmp == l) || (tmp == bl) || (tmp == t) ||
  40.     (tmp == b) || (tmp == tr) || (tmp == r) || (tmp == br))
  41.     return tmp;
  42.     else
  43.     return c;
  44. }
  45.