By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,193 Members | 826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,193 IT Pros & Developers. It's quick & easy.

Multidimension Using Arrays

P: 22
I Have Been Going On With This Problem I Just Cannot Do It:


U Have To A Program Of The Genetis Law For Survival,birth,death.
The Game Will Be Played On A Board That Consists Of 25 Squares In The Horizontal And
Vertical.each Square Can Be Empty Or Contain X(presence Of Organisms).each Square Has
Eight Neighbours.
Birth=>an Organism Will Be Born In Each Empty Location That Has Three Neighbours
Death=>an Organism Has Four Or More Neighbours And Will Die Due To Overcrowding And An
Organism With Fewer Than Two Neighbours Will Also Die Due To Loneliness
Survival=>an Organism With 2 0r 3 Neighbours Will Survive To The Next Generation
Mar 23 '07 #1
Share this Question
Share on Google+
2 Replies


DeMan
100+
P: 1,806
Unfortunately, you will not find homework solutions here, although we may be able to help you through some of the difficulty.

To get help you will need to show that you have made some sort of effort, or be able to describe the exact trouble you are having getting started, so that we can best address your problem.
You may like to speak to the teacher that gave you the assignment (after all they must know what they expect, and I'm sure they would be more than happy to assist with any difficulty)

The problem sounds very similar to something called "The Game of Life" (which you might like to look up on the net, because it may give you some ideas)

Good Luck with your assignment, and feel free to post again, but please understand we can't know your problem based on the assignment description.
Mar 23 '07 #2

P: 22
Unfortunately, you will not find homework solutions here, although we may be able to help you through some of the difficulty.

To get help you will need to show that you have made some sort of effort, or be able to describe the exact trouble you are having getting started, so that we can best address your problem.
You may like to speak to the teacher that gave you the assignment (after all they must know what they expect, and I'm sure they would be more than happy to assist with any difficulty)

The problem sounds very similar to something called "The Game of Life" (which you might like to look up on the net, because it may give you some ideas)

Good Luck with your assignment, and feel free to post again, but please understand we can't know your problem based on the assignment description.
I HAVE MADE SOME EFFORT TO GET STARTED BUT STILL IT SEEMS AS IF I AM NOT GOIN ANYWAY HERE IS WHAT I HAVE DONE SO FAR
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. #include<stdlib.h>
  4. #define MAX 25
  5. #define ORGANISMS x
  6. #define NO_ORGANISMS ' '
  7.  
  8.  
  9. int birth(int life[][MAX],int x,int ' ');
  10. int  survival(int life[][MAX],int x,int ' ');
  11. int  death(int life[][MAX],int x,int ' ');
  12.  
  13.  
  14. int main( void )    
  15. {
  16.     printf("enter the generation which you want,\n");
  17.     scanf("%d");
  18. int birth(int life[][MAX])
  19.     {
  20.     int i,j;
  21.     randomize ();
  22.     for (i=0;i <=MAX;i++);
  23.         for (j=0;j <=MAX;j++);
  24.         {life[i]=rand()%100 / 2;
  25.             }
  26.     if (life[i][j]==x && life[i][j+1]==' ' && life[i+1][j]== x && life[i][j-1]== ' ' &&life[i-1][j]== x);
  27.     return 0;
  28.     };
  29.  
  30. int  survival(int life[][MAX])
  31.  
  32. {    int i,j;
  33. for (i=0;i >=MAX;i++);
  34.         for (j=0;j >=MAX;j++);
  35.             if( life[i][j]== x){
  36.                 life[i][j]=rand()%100 / 2;
  37.             }
  38.  
  39.         if (life[i][j]==x && life[i][j+1]==' ' && life[i+1][j]== x && life[i][j-1]== ' ' &&life[i-1][j]== x);
  40.                 return 0;
  41.     }
  42.  
  43.  
  44. int death(int life[][MAX])
  45. { int i,j;
  46.     for(i=0;i<=MAX;i++)
  47.         for(j=0;j<=MAX;j++)
  48.             if(life[i][j]==x && life[i][j+1]==' ' && life[i+1][j]== x && life[i][j-1]== ' ' &&life[i-1][j]== x);
  49.                 return 0;
  50.         }
Mar 24 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.