May 16th, 1999, 03:38 PM
Can some one help me with some pointers on the game of life.
|
Click to See Complete Forum and Search --> : the game of life May 16th, 1999, 03:38 PM Can some one help me with some pointers on the game of life. sally May 17th, 1999, 04:16 AM you know the rules? Sally Sally May 17th, 1999, 04:16 AM you know the rules? Sally May 17th, 1999, 04:16 PM Microsoft makes the rules and we hope they include us. Then we die and we have a choice of ceasing to exist, reincarnating, reincarnating to a lower life form, or staying in pugatory for a while, or maybe even other choices depending on whether we lived the A, B, C, or '98 life. ;-) May 17th, 1999, 07:59 PM I believe the rules are as follows: For each cell on a rectangular grid, whether it is "dead" or "alive" in the next generation depends on how many of its eight neighbors are alive in the current generation. If 0,1 or >3 three neighbors are alive, the cell becomes or stays dead (think of it as "dying of loneliness" in the case of 0 or 1, or being crowded out in the case of >3). If 2 neighbors are alive, the state of the cell stays the same. If 3 neighbors are alive, a living cell stays alive and a dead cell springs to life. Note that I do not know how people typically deal with edge or corner cells (that is, are cells beyond the edge regarded as dead or alive?) -- you could consider them all dead, all alive or implement a "toroidal" geometry by regarding a cell beyond the left edge being the right edge cell, etc. Thus, you need to: 1. Implement a bit array representing the current stated of each cell. 2. For each cell in the array, count the number of live cells in the current generation. 3. Using the above rules, enter into an array representing the next generation an indication of whether the cell will be alive or die. 4. Swap next generation array for current generation array then call your display function (I assume that you will have some bitmaps to represent whether a cell is alive or not -- these could be as simple as a black or white dot or a more detailed bitmap of a 3D ball, etc.). Good luck! G Squared June 16th, 1999, 08:45 PM A friend of mine recently wrote this program in pure assembly language. Definitely a fun program. To speed things up some, you can make things a little complicated and only use 1 array. Each value in the array can then be between 0-3 accordingly: 0=currently dead, and dead next round too 1=currently dead, about to be alive on next round of the game 2=currently alive, but will die next time it gets displayed. 3=currently alive, alive next round too You can go through the array and edit the numbers, using neighbor>1 (or a bit test of the second bit, if in ASM) as a binary value as whether or not to count them as dead or alive and !neighbor%2 as a binary value for output during the next turn. You then go through the array and change the values accordingly every round. Did that make any sense? If you would like, I can probably get you the source and/or the .com for the program in Assembly. It is really pretty neat. The same person also did some other versions such as where the organisms dont die and where it takes 4 neighbors to overcrowding. Also some nice looking results. ~G² balak yap June 16th, 1999, 11:06 PM No rules in our life..this is the only rule we have Hello World!!! balak yap June 16th, 1999, 11:15 PM Mind to send me the program? if possible, the ASM code too.. THANKS Hello World!!! Dan Lewis June 17th, 1999, 10:42 PM As G² said, I recently coded a bunch of stuff for the Game of Life in ASM. If you'd like to look at the programs, or the ASM source, just download this zip file: http://members.xoom.com/psycow/life.zip [15.1kb] (If you have trouble with .zip's just e-mail me.) Several versions of the Game are included, where the rules are changed. Send me any feedback at greencow3@hotmail.com. Enjoy! Dan Lewis AIM: spworp ICQ: 22240813 WWW: www.infinitevoid.com (Temporarily Down) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |