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

  1. /*
  2.  * File: heat.l256r2.c
  3.  *   By: Dave Hiebeler
  4.  *       hiebeler@turing.cs.rpi.edu
  5.  *       Feb. 1990
  6.  *
  7.  * The "heat" rule in the linear neighborhood.
  8.  *
  9.  * Parm2 is the constant added in to every cell after it takes on the
  10.  * average value of the neighborhood.
  11.  *
  12.  * A random starting config works with some settings of the parameters.
  13.  * For other settings, you may want to use a "hot array with a cold hole",
  14.  * as described in "heat.m256.c".  In this case, however, the "hole"
  15.  * should be on the bottom line of the array.
  16.  *
  17.  */
  18.  
  19.  
  20. #include "CMnborhood.h"
  21.  
  22. byte heat(), heat_exit();
  23. static CM_field_id_t heat_sum;
  24.  
  25.  
  26. void
  27. init_function()
  28. {
  29.  
  30.     update_function = heat;
  31.     exit_function = heat_exit;
  32.     parm2 = 2;
  33.     heat_sum = CM_allocate_heap_field(11);
  34. }
  35.  
  36.  
  37. byte
  38. heat()
  39. {
  40.     CM_u_move_zero_1L(heat_sum, 11);
  41.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_LL, 11, 11, 8);
  42.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_L, 11, 11, 8);
  43.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_C, 11, 11, 8);
  44.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_R, 11, 11, 8);
  45.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_RR, 11, 11, 8);
  46.     CM_u_truncate_constant_3_1L(heat_sum, heat_sum, 5, 11);
  47.     CM_u_add_constant_2_1L(heat_sum, parm2, 8);
  48.     CM_u_move_1L(cell, heat_sum, 8);
  49. }
  50.  
  51.  
  52. byte
  53. heat_exit()
  54. {
  55.     CM_deallocate_heap_field(heat_sum);
  56. }
  57.