staff project download information miscellaneous
Trend Download   One Dimensional Cellular Automata
  Download

Trend Tutorials
Trend Basics
Game of Life
One Dimensional CA
Mouse Maze
1-D Bubble Sort
Animation


More Trend Examples

 
MangoVect DownloadPicky DownloadLucy2 DownloadGRAMAUBViz DownloadgeneDBN Download
2. Examining the Rule (Continued)

Lines 21 - 23 are again just comments to show the next set of lines are related to a particular action.

21 /*******************************************************************************/
22 /************Code to Perform the Movement Down the Screen*********************/
23 /*******************************************************************************/

Lines 25 - 30 affect the appearance of the path moving down the screen.

25 if (no:ctrl==top:ctrl+1 || no:ctrl==0 && top:ctrl==255)

Line 25 states that if the NO:CTRL is equal to the value of the TOP:CTRL, OR the NO:CTRL has a value of 0 (zero) and the TOP:CTRL has a value of 255, then execute the statement that follows.

Line 26 is just an { (open brace) that allows more than one line to be included in the statement. Just as it does in C++.
Line 27 says to make the particular CTRL that is applicable to the rule equal to it's NO:CTRL +1.

27 ctrl=no:ctrl+1;

Line 28 takes the 3 neighbors just above the particular CTRL and adds their values together to get a sum. That sum is an integer declared earlier in line 8. Sum is used in line 29. CELL is assigned the value of the value found in the table for sum. Line 30 is a close brace to show the end of the statements grouped under the "if" condition in line 25.

25 if (no:ctrl==top:ctrl+1 || no:ctrl==0 && top:ctrl==255)
26 {
27 ctrl=no:ctrl+1;
28 sum=nw:cell+no:cell+ne:cell;
29 cell=table[sum];
30 }
31 /*If NO CTRL is equal to TOP CTRL plus 1, then CTRL is assigned the value of NO CTRL plus 1 and sum is
32 assigned the value of NW:CELL + NO:CELL + NE:CELL and cell is assigned the value of the array sum. */

Lines 31 and 32 are just comments to complete the rule.


Last modified June 13, 2008 . All rights reserved.

Contact Webmaster

lab