class Cell { boolean state; // alive or dead boolean evolution; // next state boolean fixed; // static value for QR public Cell(boolean s, boolean f){ state = s; fixed = f; } public void preProcess(int neighbours){ // input is number of neighbours alive if (state){ evolution = (neighbours==2)||(neighbours==3); } else { evolution = (neighbours==3); } } public void process (){ if (!fixed) state = evolution; } public boolean isAlive(){ return state; } public boolean isFixed(){ return fixed; } public void randomize(){ if (!fixed) state = (random(0,1)>0.5); } }