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

  1. /*
  2.  * File: heat.l256r2.c
  3.  *   By: Dave Hiebeler
  4.  *       hiebeler@turing.cs.rpi.edu
  5.  *       August 1989
  6.  *
  7.  * The "heat" rule in the linear neighborhood.  See the "heat.m256.c" file
  8.  * for more information on the heat rule itself.
  9.  *
  10.  * This rule works pretty well starting from random initial configurations.
  11.  *
  12.  * Try this with parm1 = 100 and parm2 = 2
  13.  *  Also, try slight variations on both parameters to see the effects
  14.  * You also get interesting behavior with parm1 = 100 and parm2 = 113.
  15.  */
  16.  
  17. #include "nborhood.h"
  18.  
  19. byte heat();
  20.  
  21. void
  22. init_function()
  23. {
  24.     update_function = heat;
  25.     parm1 = 100;
  26.     parm2 = 2;
  27. }
  28.  
  29.  
  30. byte
  31. heat(nbors)
  32. lr2_nbors *nbors;
  33. {
  34.     int heat_avg;
  35.  
  36.     Get_lr2_nbors;
  37.     heat_avg = (ll + l + c + r + rr)/5;
  38.     return (c + (heat_avg - c) * parm1 / 100 + parm2) % 256;
  39. }
  40.