Dear Sir: The program you had on there called SimpleModel has the wrong algorithm. It is plotting rule 222. Under the method NextGen you have this comment:
// Set the array list element to an asterix when one or the
// other neighbour is an asterix, but not both.
Those are not the rules that you want. Rule 30 looks like this in binary:
00011110
You want to simulate this situation according to Mr. Wolfram.
111 110 101 100 011 010 001 000 This is converted to the next row
0 0 0 1 1 1 1 0 = 30
You have to reflect that in your rectangle drawing method. Ex.
for (int i=0; i<=80; i++) {
if ((arlPrev.get(i) == ASTERIX) && (i > 0) && (i < 80)) {
// byte 1
if (arlPrev.get(i-1).equals(ASTERIX) && (arlPrev).get(i+1).equals(ASTERIX)) {
arList.set(i, BLANKS);
}
// byte 2
if (arlPrev.get(i-1).equals(ASTERIX) && (arlPrev.get(i+1)).equals(BLANKS)){
arList.set(i,BLANKS);
}
// byte 5
if (arlPrev.get(i-1).equals(BLANKS) && (arlPrev.get(i+1)).equals(ASTERIX)){
arList.set(i,ASTERIX);
}
etc.
After those changes it ought to work. At least I got it to. Good luck.
Dear Sir: Ignore a good part of what I had written. SimpleModel was one of my old programs, not yours! It's been a while since I worked with that stuff. I didn't recognize one of my programs. However the algorithm works and when I made changes for Rule 30, the random patterns pop up. There are probably other approaches, ie. bit pushing. I just used simple line by line processing of blanks and astericks in an ArrayList to build the next generation. Hope that wasn't too confusing! Good Luck!
Bookmarks