Cellular Automaton - Conway's Game of Life (en.wikipedia.org/wiki/Conway's_Game_of_Life)
Rules
- Any living cell with < 2 living neighbors dies.
- Any living cell with == (2||3) living neighbors lives.
- Any living cell with > 3 living neighbors dies.
- Any dead cell with == 3 living neighbors becomes a live cell.
Border Rules
Conway designed this Game of Life for an infinitive grid, but in real world of small apps (like this) the border is inevitable, real, and it must have rules. In any case they are arbitrary. Borders are non-canonical.
- Border of the Board is a dead edge, any nonexistend but imaginable Cell behind it has turned out possibility to became Black (aka living) in any conditions
- Cells on the border have counted values only of an existing (visilble) neighbors
Info
At this moment engine works, and transformation is correct (glider moves fine). As far as I tested all is OK. Engine can be much more optimized.
- Click on a square to change its color black/white - white is default at start, this is non-life. Living Cell is black.
- Button click makes one cycle of Life.
- Cell can be clicked/modified at any moment.
ToDo
- Optimising the engine
- Make it pseudoinfinitive: add two or three row on each side, all invisible for user with killing border on the real edge, in fact I started doing it, but this is real boring and tedious work.