package ca; import java.awt.*; import java.awt.image.*; import java.util.*; public class Zhabotinsky extends CAs { private protected static final boolean DEBUG = false; public Zhabotinsky(){} public void setTarget(Component target){ STATE=16; cols = new int[16]; int a = 0xff000000; int r,g,b; for(int i = 0; i < STATE; i ++){ r = ((int)(Math.sin(i*4)*255) << 16) & 0xff0000; g = ((int)(Math.cos(i*0.3+2.5)*255) << 8) & 0xff00; b = (int)(Math.cos(i*0.1)*255) & 0xff; cols[i] = (a|r|g|b); } /* for(int i = 0; i < 256; i ++){ r = ((255-i)<<16) &0x00ff0000; g = ((i/2)<<8) &0x0000ff00; b = ((i % 64)*4) &0x000000ff; cols[i] = (a|r|g|b); } */ super.setTarget(target); } public void check(int x1,int x2,int x3,int y1,int y2,int y3){ if (cells[x2][y2] == STATE-1){ cells2[x2][y2]=(short)(0); return; }else{ int count = cells[x1][y1] + cells[x1][y2] + cells[x1][y3] + cells[x2][y1] + cells[x2][y3] + cells[x3][y1] + cells[x3][y2] + cells[x3][y3]; short test = (short)(((count >> 3) + 1)); if(test >= STATE - 1){test = (short)( STATE - 1 ); }else if (test < 0){test = (short)0;} cells2[x2][y2] = test; return; } } }