DOWNLOAD THE CODE:
Download the Code 24425.zip

You can begin testing your solution by randomly generating the first state and storing it in a table or using the PRINT command to print it. For example, suppose you randomly generated the following (abbreviated) first state: 002222030011...0. You'd generate the next state by using the algorithm above (Steps 1, 2, and 3), then store or PRINT the values of that state. Using the replication rule "0102030201," here's how you'd calculate the first few digits of the next state:

  • Set first digit to 0 manually
  • Step 1: m=0+0+2+1=3; Step 2: third digit of replication rule is 0; Step 3: second digit in new state is 0
  • Step 1: m=0+2+2+1=5; Step 2: fifth digit of replication rule is 0; Step 3: third digit in new state is 0
  • Step 1: m=2+2+2+1=7; Step 2: seventh digit of replication rule is 0; Step 3: fourth digit in new state is 0
  • Step 1: m=2+2+2+1=7; Step 2: seventh digit of replication rule is 0; Step 3: fifth digit in new state is 0
  • Step 1: m=2+2+0+1=5; Step 2: fifth digit of replication rule is 0; Step 3: sixth digit in new state is 0
  • Step 1: m=2+0+3+1=6; Step 2: sixth digit of replication rule is 3; Step 3: seventh digit in new state is 3
  • Step 1: m=0+3+0+1=4; Step 2: fourth digit of replication rule is 2; Step 3: eighth digit in new state is 2
  • Step 1: m=3+0+0+1=4; Step 2: fourth digit of replication rule is 2; Step 3: ninth digit in new state is 2
  • Step 1: m=0+0+1+1=2; Step 2: second digit of replication rule is 1; Step 3: tenth digit in new state is 1
  • Step 1: m=0+1+1+1=3; Step 2: third digit of replication rule is 0; Step 3: eleventh digit in new state is 0
  • Perform the same calculation for all digits through the 79th digit
  • Set 80th digit to 0 manually

As a result of running the process, the next state (abbreviated) is 00000032210...0.

Run the automation through, say, 25 generations (this size is convenient because most screens can show 80 characters * 25 rows), and you'll see an interesting abstract pattern in the output. Applications with a UI can represent each value as a colored pixel, and you can generate patterned wallpaper. Figure 1 contains some abbreviated sample output; note the interesting pattern. After you achieve an output similar to Figure 1's sample output, you might want to replace the digits 0, 1, 2, and 3 with other symbols to make it look like a drawing. Later in the article, I provide an example of how to achieve this effect.

Prev. page     1 [2] 3 4     next page



You must log on before posting a comment.

If you don't have a username & password, please register now.

 
 

ADS BY GOOGLE