Thread: life simulation

  1. #1
    Registered User
    Join Date
    Oct 2002

    Question life simulation


    My Challenge: to populate a 20x20 array with 100 random numbers which will represent organisms which will then die out based on their neighbours' existence.

    My approach: I've generated the 100 numbers between 0 and 400 using srand, which to my simple mind I would like to use to represent the random positions in the array, then I would like to place an asterisk in the positions, representing the life-forms.

    Is this too complex an approach 'cause for the life of me I can't get them read into the array.

  2. #2
    Join Date
    Aug 2001
    Groningen (NL)
    > I can't get them read into the array.

    Use two for-loops to enter the data into the array.

    for (x = 0; x < 20; x++)
      for (y = 0; y < 20; y++)
        array [x][y] = value;

  3. #3
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    It's a multi-dimensional array, you could first populate him, by asking the user, or just generating instead one random number, two random numbers, like this:
    int x,y;
    x = rand()%20+1;
    y = rand()%20+1; 
    colony[x][y] = '*';
    Also, it's not difficult to make the game... you need few functions, some of them to see how many neighbours a simple citizen have. The most funny in this game is the rules, this game is used in a lot of researches, really funny.

    Remember, you don't fill all the array in the first time, just add some citizens and see the evolution.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Artificial Life: Where to Start?
    By Mr.Sellars in forum General AI Programming
    Replies: 11
    Last Post: 09-22-2007, 02:03 AM
  2. Game of life
    By JoshR in forum C++ Programming
    Replies: 30
    Last Post: 04-03-2005, 02:17 PM
  3. The Meaning of Life: A Trick Question?
    By chix/w/guns in forum A Brief History of
    Replies: 14
    Last Post: 07-12-2004, 07:53 PM
  4. The more intelligent risks you take in life, the more you'll achieve
    By Terrance in forum A Brief History of
    Replies: 6
    Last Post: 05-20-2003, 05:23 PM
  5. Life, The Universe, and everything else
    By ZooTrigger1191 in forum A Brief History of
    Replies: 7
    Last Post: 03-29-2003, 05:33 PM