
#RULES FOR LIFE GAME UPDATE#
Is there any update to a cell dependent on other cells updates?Īnswer to the Question 1 is rather simple.

Let us analyze the below questions before moving on: How can we update all cells at the same time? This is very important point on simultaneously updating all cells in the Game of Life Grid. Considerations for simultaneous update to all cells A Cell can be alive or dead based on this property - true = alive and false = dead public Boolean IsAlive Also, if any other behavior is required to be added at the cell level then it cal be easily done in the Cell class. Let us have a look at how will our Grid look like: Therefore, our grid will contain a list of such rows, which in turn contains a list of Columns. This will make the implementation more extensible.įurther, to hold a list of cell a custom object called Row which contains a list of cells. We have a custom class for cell having a boolean property as Isalive. It gives a sense of a list as we need not refer a cell from its index but need to enumerate from first item till the last element.įrom the above discussion, it is clear that we are moving into the utilizing list collection classes in C#. new row could be added to top as well as bottom and new column can be added before first column and last column. This two dimensional structure should be able to grow in either side e.g. We need to implement a two dimensional matrix having every cell containing one of two boolean values live or dead. Considerations for two dimensional matrix Once a generation is complete, we will do a swapping of Output Grid to Input Grid and the process will continue. In other words, consider Input Grid as grid with freezed cells and Output Grid will change until all cells in Input Grid is evaluated. Please note that the state of Input grid will not be updated to get the next generation, so there is no run-time consideration of cell state changes. In case, where Row or Column growth is required then these will be added to Output Grid. We need to apply rules for each cell in Input Grid and get the Cell's next generation in Output Grid. Output grid will contain the next generation of Input Grid. Input Grid is the initial state of game off life to start with. In the beginning, we will have two grids say Input Grid and Output Grid. The first idea which comes into my mind is to keep separate Grid in initial generation and next Generation. However, we will come up with a design which obeys object oriented principles.

To be able to implement such solution in object oriented manner is quite a challenging task. I think we may need some sort of Threading implementation here to provide simultaneous updates on all cells. Rules simultaneously to every cell in the seed.

The first generation is created by applying the above.The other catch is the need of implementation in Object oriented fashion.However, there are a couple of catch here. This looks interesting and it seems that implementing the logic in a structured language will not be very difficult. Thus, the next state will include two new auto grown rows. Any dead cell with exactly three live neighbours comes It is important to note that in Output D, the two new rows have been due to Rule #4 i.e. Next tick (one run of the application of all the rules), represented in the The output is the state of the system in the The below inputs provide the provide pattern The inputs below represent the cells in the universe as X or. (In other words, each generation is a pure function of the oneīefore.) The rules continue to be applied repeatedly to create further Simultaneously, and the discrete moment at which this happens is sometimesĬalled a tick. Rules Simultaneously to every cell in the seed - births and deaths happen

The first generation is created by applying the above At each step inĪny live cell with fewer than two live neighbours dies,Īny live cell with more than three live neighboursĪny live cell with two or three live neighbours lives,Īny dead cell with exactly three live neighbours comes Of square cells, each of which is in one of two possible states, live or dead.Įvery cell interacts with its eight neighbours, which are the cells that areĭirectly horizontally, vertically, or diagonally adjacent. The universe of the Game of Life is an infinite two-dimensional orthogonal grid One interacts with the Game of Life byĬreating an initial configuration and observing how it evolves. Zero-player game, meaning that its evolution is determined by its initial Life, is a cellular automaton devised by the British mathematician John Horton As per wiki “The Game of Life, also known simply as
