Game of Life (Java version)

About the Game

Game of Life (game of life) 1970 by the British mathematician JH Conway proposed
a neighbor of a cell, including the cells of the adjacent rules down, left, right, upper left, lower left, upper right and lower right game as follows:
lonely death if is less than a neighbor cell, the cell will die next state
congestion death if four or more neighbor cells, the cells would die next state
stable if the neighbor cell is two or three, the next state stable survival
resurrection if a location of the original cell-free survival, and a neighbor of the three positions, the position will be resurrected a cell.

solution

The rules of the game can be simplified to a determination of the switch-case:
when the number of neighbor 0,1,4,5,7,8, into the state of the cell death;
when the number of neighbors is 2, 3, cells survival stable;
if the number of neighbors is 2 and no cell current position, the position of the next cell will be resurrected.

Source

The source code is too long, provide a download link here (0 Points can be downloaded):
https://download.csdn.net/download/weixin_44155115/12089508
can change the number of grid modifications in the source code, to get a different visual effect, display characters can be changed to a solid color background

Results preview

Here Insert Picture Description

Published 18 original articles · won praise 16 · views 1390

Guess you like

Origin blog.csdn.net/weixin_44155115/article/details/103884572