You appear to be computing ruleCase incorrectly. For example, in the general case you do ... ruleCase=1*previous[cell-1]+2*previous[cell]+3*previous[cell+1] ... but you are trying to interpret the cell values as binary digits. Therefore, the coefficients should be powers of 2: ruleCase=1*previous[cell-1]+2*previous[cell]+4*previous[cell+1] Likewise for the special cases....

language-agnostic,cellular-automata

It's a cellular automaton with 5 states. The rule is 3457/357/5 using golly's notation. It has 5 states: 0, 1, 2, 3, 4. In each step, cells behave as follows: 0 -> 1 if 3, 5 or 7 of its eight neighbors are 1, or 0 otherwise 1 -> 1...