CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Guest

    the game of life

    Can some one help me with some pointers on the game of life.


  2. #2
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: the game of life

    you know the rules?

    Sally


  3. #3
    Guest

    Re: the game of life

    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. ;-)


  4. #4
    Guest

    Re: the game of life

    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!


  5. #5
    Join Date
    May 1999
    Location
    Greenville, SC, USA
    Posts
    33

    Re: the game of life

    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²


  6. #6
    Join Date
    Apr 1999
    Location
    Malaysia
    Posts
    224

    Re: the game of life

    No rules in our life..this is the only rule we have

    Hello World!!!

  7. #7
    Join Date
    Apr 1999
    Location
    Malaysia
    Posts
    224

    Re: the game of life

    Mind to send me the program?
    if possible, the ASM code too..
    THANKS


    Hello World!!!

  8. #8
    Join Date
    Jun 1999
    Posts
    1

    Re: the game of life

    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 [email protected]. Enjoy!

    Dan Lewis
    AIM: spworp
    ICQ: 22240813
    WWW: www.infinitevoid.com (Temporarily Down)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured