See System Requirements. Available on PC. Description The "Game Of Life", from mathematician Conway is a fascinating simulation that produces awesome patterns and structures while it's running. What's new in this version Several rules are now selectable. Additional information Published by Bytewire Software. Published by Bytewire Software.
Copyright Copyright by Bytewire Software, Developed by Bytewire Software. Available to United States residents. By clicking sign up, I agree that I would like information, tips, and offers about Microsoft Store and other Microsoft products and services.
Privacy Statement. Conway's GameOfLife. Official Club. See System Requirements. Available on HoloLens. Capabilities Single player. Description Interesting version of computer realization of the mathematical game of "Life" invented by British mathematician John Conway in Show More. Indentation isn't quite correct in the liveOrDie function: the 3 rd for loop should be indented further to the right.
The biggest improvement I can think of would be to avoid storing and processing the entire grid. Although there are exceptions , generally Conway's game of life patterns have a lot of empty space. At present your program is spending a lot of time and memory on this empty space. I would recommend just storing the live cells, and calculating the next generation of live cells from this. For example, you could use an unordered set which has O 1 access time and just consider those cells which are either in the set or in an adjacent cell.
No other cell will become alive in that generation, so you don't need to consider them. For large patterns you will find that this approach is considerably more efficient in both time and space requirements, and also you don't need to specify the grid size up front, which is useful for new patterns for which you don't yet know how they will grow.
To me, this would make the code clearer. In the liveOrDie function, I would also change the variable name life to the more descriptive neighbors or parents. Koradalien and others have captured the key points on overall structure, but I'd add a couple of local changes that might also be useful. OK, some would say the lives array is overkill, but I put it here to demonstrate the technique. Note how you could tinker with the count array to get some easy changes to the rule.
Another thought on unrelated issues. The system "CLR" ; is likely to cause flicker. For a console app, you are better just sending the cursor home. See existing question. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Asked 7 years, 9 months ago. Detailed steps of this approach are as follows: For the present grid position, we will look at all the neighbors.
Traverse the whole grid. Now, generate the required new generation grid using the modified grid. Else change the value to 0. If the value is 3 then change it to 1. Else change it to 0. Below is the implementation of the above approach:. Skip to content. Change Language. Related Articles. Table of Contents. Improve Article.
0コメント