SlideShare a Scribd company logo
Need help writing Conway's Game of Life. These are the instructions:
The game of Life is intended to model life in a society of organisms. Consider a rectangular
array of cells, each of which may contain an organism. If the array is considered to extend
indefinitely in both directions, then each cell has eight neighbors, the eight cells surrounding it.
Births and deaths occur according to the following rules:
An organism is born in any empty cell having exactly three neighbors.
An organism dies from isolation if it has fewer than two neighbors.
An organism dies from overcrowding if it has more than three neighbors.
All other organisms survive to the next generation.
Write a program to play the game of Life and investigate the patterns produced by various initial
configurations. Some configurations die off rather rapidly; others repeat after a certain number of
generations; others change shape and size and may move across the array.
NOTE:
For representing each organism, use "@" characters.
For an array of cells, use 30x30 two-dimensional array.
Each generation should be displayed on the screen and should be paused.
(You can use cin.get( ) library function to pause running your program.)
4. The source file should be called life.cpp
5. All assignments are expected to be INDIVIDUAL work. All work handed in must be original.
Duplicate or very similar programs receive zero points.
Input
A set of initial cells will be given using the interactive way using a keyboard.
The followings are the prompt for the input:
Please Enter the number of initial cells: 4
The position of cell is 10 10
The position of cell is 10 11
The position of cell is 10 12
The position of cell is 11 11
How many generations do you want to display? 3
Output
The program then display each generation of organisms at a time.
The 1-generation
@@@
@
Press any key to continue!!
(This picture should be displayed on the new screen.)
The 2-generation
@
@@@
@@@
Press any key to continue!!
The 3-generation
@@@
@ @
@
Do you want to do it again?(Yes/No) N
Solution
Note: User given template is used.
Answer:
#include
#include
#include
#include
#include
using namespace std;
int orAry[30][30];
void initilaize()
{
for(int kk=0;kk<30;kk++)
{
for(int bb=0;bb<30;bb++)
{
orAry[kk][bb]=0;
}
}
}
void disply()
{
cout<=0 )
{
cc++;
}
if( orAry[kk+1][aa-1]==1 && kk+1<30 && aa-1>=0)
{
cc++;
}
if( orAry[kk+1][aa]==1 && kk+1<30)
{
cc++;
}
if( orAry[kk][aa+1]==1 && aa+1<30)
{
cc++;
}
if( orAry[kk-1][aa-1]==1 && kk-1>=0 && aa-1>=0)
{
cc++;
}
if(orAry[kk+1][aa+1]==1 && kk+1<30 && aa+1<30)
{
cc++;
}
if(orAry[kk-1][aa]==1 && kk-1>=0)
{
cc++;
}
if( orAry[kk-1][aa+1]==1 && kk-1>=0 && aa+1<30)
{
cc++;
}
return cc;
}
void runLife()
{
int bCnt=0;
int dCnt=0;
for(int kk=0;kk<30;kk++)
{
for(int bb=0;bb<30;bb++)
{
if(orAry[kk][bb]==0)
{
bCnt=ChechNeighBourCount(kk,bb);
if(bCnt==3)
{
orAry[kk][bb]=1;
}
}
else if(orAry[kk][bb]==1)
{
dCnt=ChechNeighBourCount(kk,bb);
if(dCnt>3)
{
orAry[kk][bb]=0;
}
if(dCnt<2)
{
orAry[kk][bb]=0;
}
}
}
}
}
int main()
{
int rr,cc;
int npos=0;
int ngen=0;
int xv,yv;
char re;
srand(time(NULL));
do
{
initilaize();
cout<<"Please Enter the number of initial cells:";
cin>>npos;
for(int kk=0;kk>xv>>yv;
if(orAry[xv][yv]==0)
{
orAry[xv][yv]=1;
}
}
cout<<"How many generations do you want to display?";
cin>>ngen;
for(int kk=0;kk>re;
}while(re!='N');
return 0;
}
Sample Output:
Please Enter the number of initial cells:4
The position of cell is
10 10
The position of cell is
10 11
The position of cell is
10 12
The position of cell is
11 11
How many generations do you want to display?3
1 - generation
@@@
@
Press any key to continue
2 - generation
@@
@ @
@
Press any key to continue
3 - generation
@@
@ @
@
Press any key to continue
Do you want to do it again?(Yes/No) N
Exit code: 0 (normal program termination)

More Related Content

Similar to Need help writing Conways Game of Life. These are the instructions.pdf

Amcat automata questions
Amcat   automata questionsAmcat   automata questions
Amcat automata questions
ESWARANM92
 
Amcat automata questions
Amcat   automata questionsAmcat   automata questions
Amcat automata questions
ESWARANM92
 
## Part B- Conway's Game of Life ### Introduction John Conway's Ga.pdf
## Part B- Conway's Game of Life   ### Introduction   John Conway's Ga.pdf## Part B- Conway's Game of Life   ### Introduction   John Conway's Ga.pdf
## Part B- Conway's Game of Life ### Introduction John Conway's Ga.pdf
BANSALANKIT1077
 
Python programming
Python  programmingPython  programming
Python programming
Ashwin Kumar Ramasamy
 
Cs in science_guides
Cs in science_guidesCs in science_guides
Cs in science_guides
Barbara M. King
 
Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptx
Mrhaider4
 
5. conditionals
5. conditionals5. conditionals
5. conditionals
Nestor Benavides
 

Similar to Need help writing Conways Game of Life. These are the instructions.pdf (7)

Amcat automata questions
Amcat   automata questionsAmcat   automata questions
Amcat automata questions
 
Amcat automata questions
Amcat   automata questionsAmcat   automata questions
Amcat automata questions
 
## Part B- Conway's Game of Life ### Introduction John Conway's Ga.pdf
## Part B- Conway's Game of Life   ### Introduction   John Conway's Ga.pdf## Part B- Conway's Game of Life   ### Introduction   John Conway's Ga.pdf
## Part B- Conway's Game of Life ### Introduction John Conway's Ga.pdf
 
Python programming
Python  programmingPython  programming
Python programming
 
Cs in science_guides
Cs in science_guidesCs in science_guides
Cs in science_guides
 
Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptx
 
5. conditionals
5. conditionals5. conditionals
5. conditionals
 

More from santanadenisesarin13

What does it mean by mRNA coded for by the Operon What does it.pdf
What does it mean by mRNA coded for by the Operon What does it.pdfWhat does it mean by mRNA coded for by the Operon What does it.pdf
What does it mean by mRNA coded for by the Operon What does it.pdf
santanadenisesarin13
 
Variability of a sample can he measured use the following statistic(s.pdf
Variability of a sample can he measured use the following statistic(s.pdfVariability of a sample can he measured use the following statistic(s.pdf
Variability of a sample can he measured use the following statistic(s.pdf
santanadenisesarin13
 
What are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdfWhat are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdf
santanadenisesarin13
 
Unbiased estimators Let theta be an estimator of a parameter theta..pdf
Unbiased estimators  Let theta be an estimator of a parameter theta..pdfUnbiased estimators  Let theta be an estimator of a parameter theta..pdf
Unbiased estimators Let theta be an estimator of a parameter theta..pdf
santanadenisesarin13
 
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdf
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdfThomas Lewis said “the capacity to blunder slightly is the real marv.pdf
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdf
santanadenisesarin13
 
The strongest attractive forces between molecules of H_2O are ionic.pdf
The strongest attractive forces between molecules of H_2O are  ionic.pdfThe strongest attractive forces between molecules of H_2O are  ionic.pdf
The strongest attractive forces between molecules of H_2O are ionic.pdf
santanadenisesarin13
 
Q1. An individual who accepts the risks and opportunities entailed b.pdf
Q1. An individual who accepts the risks and opportunities entailed b.pdfQ1. An individual who accepts the risks and opportunities entailed b.pdf
Q1. An individual who accepts the risks and opportunities entailed b.pdf
santanadenisesarin13
 
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdfQuestion 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
santanadenisesarin13
 
Place the following formulas in their proper order A. ALE, residu.pdf
Place the following formulas in their proper order A. ALE, residu.pdfPlace the following formulas in their proper order A. ALE, residu.pdf
Place the following formulas in their proper order A. ALE, residu.pdf
santanadenisesarin13
 
please help i have 40 minsItem 1In the case below, the original .pdf
please help i have 40 minsItem 1In the case below, the original .pdfplease help i have 40 minsItem 1In the case below, the original .pdf
please help i have 40 minsItem 1In the case below, the original .pdf
santanadenisesarin13
 
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdf
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdfNon-Euclidean GeometryWhat statement, if any, can be made about th.pdf
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdf
santanadenisesarin13
 
Java ProgrammingA Swing button can have more than one action liste.pdf
Java ProgrammingA Swing button can have more than one action liste.pdfJava ProgrammingA Swing button can have more than one action liste.pdf
Java ProgrammingA Swing button can have more than one action liste.pdf
santanadenisesarin13
 
JAVA Write a class called F.pdf
JAVA  Write a class called F.pdfJAVA  Write a class called F.pdf
JAVA Write a class called F.pdf
santanadenisesarin13
 
In the adult, red bone marrow would normally be found in the sternu.pdf
In the adult, red bone marrow would normally be found in the  sternu.pdfIn the adult, red bone marrow would normally be found in the  sternu.pdf
In the adult, red bone marrow would normally be found in the sternu.pdf
santanadenisesarin13
 
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdfI need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
santanadenisesarin13
 
I dont understand the min and max Find the smallest positive value.pdf
I dont understand the min and max Find the smallest positive value.pdfI dont understand the min and max Find the smallest positive value.pdf
I dont understand the min and max Find the smallest positive value.pdf
santanadenisesarin13
 
How can the activation of effector molecules within cells be restric.pdf
How can the activation of effector molecules within cells be restric.pdfHow can the activation of effector molecules within cells be restric.pdf
How can the activation of effector molecules within cells be restric.pdf
santanadenisesarin13
 
Explain how the skin of reptiles adaptive for terrestial existence. .pdf
Explain how the skin of reptiles adaptive for terrestial existence. .pdfExplain how the skin of reptiles adaptive for terrestial existence. .pdf
Explain how the skin of reptiles adaptive for terrestial existence. .pdf
santanadenisesarin13
 
Distinguish the roles of the four economic actors in economicsSo.pdf
Distinguish the roles of the four economic actors in economicsSo.pdfDistinguish the roles of the four economic actors in economicsSo.pdf
Distinguish the roles of the four economic actors in economicsSo.pdf
santanadenisesarin13
 
Explain the term liquidity and how it relates to the classified bala.pdf
Explain the term liquidity and how it relates to the classified bala.pdfExplain the term liquidity and how it relates to the classified bala.pdf
Explain the term liquidity and how it relates to the classified bala.pdf
santanadenisesarin13
 

More from santanadenisesarin13 (20)

What does it mean by mRNA coded for by the Operon What does it.pdf
What does it mean by mRNA coded for by the Operon What does it.pdfWhat does it mean by mRNA coded for by the Operon What does it.pdf
What does it mean by mRNA coded for by the Operon What does it.pdf
 
Variability of a sample can he measured use the following statistic(s.pdf
Variability of a sample can he measured use the following statistic(s.pdfVariability of a sample can he measured use the following statistic(s.pdf
Variability of a sample can he measured use the following statistic(s.pdf
 
What are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdfWhat are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdf
 
Unbiased estimators Let theta be an estimator of a parameter theta..pdf
Unbiased estimators  Let theta be an estimator of a parameter theta..pdfUnbiased estimators  Let theta be an estimator of a parameter theta..pdf
Unbiased estimators Let theta be an estimator of a parameter theta..pdf
 
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdf
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdfThomas Lewis said “the capacity to blunder slightly is the real marv.pdf
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdf
 
The strongest attractive forces between molecules of H_2O are ionic.pdf
The strongest attractive forces between molecules of H_2O are  ionic.pdfThe strongest attractive forces between molecules of H_2O are  ionic.pdf
The strongest attractive forces between molecules of H_2O are ionic.pdf
 
Q1. An individual who accepts the risks and opportunities entailed b.pdf
Q1. An individual who accepts the risks and opportunities entailed b.pdfQ1. An individual who accepts the risks and opportunities entailed b.pdf
Q1. An individual who accepts the risks and opportunities entailed b.pdf
 
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdfQuestion 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
 
Place the following formulas in their proper order A. ALE, residu.pdf
Place the following formulas in their proper order A. ALE, residu.pdfPlace the following formulas in their proper order A. ALE, residu.pdf
Place the following formulas in their proper order A. ALE, residu.pdf
 
please help i have 40 minsItem 1In the case below, the original .pdf
please help i have 40 minsItem 1In the case below, the original .pdfplease help i have 40 minsItem 1In the case below, the original .pdf
please help i have 40 minsItem 1In the case below, the original .pdf
 
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdf
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdfNon-Euclidean GeometryWhat statement, if any, can be made about th.pdf
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdf
 
Java ProgrammingA Swing button can have more than one action liste.pdf
Java ProgrammingA Swing button can have more than one action liste.pdfJava ProgrammingA Swing button can have more than one action liste.pdf
Java ProgrammingA Swing button can have more than one action liste.pdf
 
JAVA Write a class called F.pdf
JAVA  Write a class called F.pdfJAVA  Write a class called F.pdf
JAVA Write a class called F.pdf
 
In the adult, red bone marrow would normally be found in the sternu.pdf
In the adult, red bone marrow would normally be found in the  sternu.pdfIn the adult, red bone marrow would normally be found in the  sternu.pdf
In the adult, red bone marrow would normally be found in the sternu.pdf
 
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdfI need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
 
I dont understand the min and max Find the smallest positive value.pdf
I dont understand the min and max Find the smallest positive value.pdfI dont understand the min and max Find the smallest positive value.pdf
I dont understand the min and max Find the smallest positive value.pdf
 
How can the activation of effector molecules within cells be restric.pdf
How can the activation of effector molecules within cells be restric.pdfHow can the activation of effector molecules within cells be restric.pdf
How can the activation of effector molecules within cells be restric.pdf
 
Explain how the skin of reptiles adaptive for terrestial existence. .pdf
Explain how the skin of reptiles adaptive for terrestial existence. .pdfExplain how the skin of reptiles adaptive for terrestial existence. .pdf
Explain how the skin of reptiles adaptive for terrestial existence. .pdf
 
Distinguish the roles of the four economic actors in economicsSo.pdf
Distinguish the roles of the four economic actors in economicsSo.pdfDistinguish the roles of the four economic actors in economicsSo.pdf
Distinguish the roles of the four economic actors in economicsSo.pdf
 
Explain the term liquidity and how it relates to the classified bala.pdf
Explain the term liquidity and how it relates to the classified bala.pdfExplain the term liquidity and how it relates to the classified bala.pdf
Explain the term liquidity and how it relates to the classified bala.pdf
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 

Need help writing Conways Game of Life. These are the instructions.pdf

  • 1. Need help writing Conway's Game of Life. These are the instructions: The game of Life is intended to model life in a society of organisms. Consider a rectangular array of cells, each of which may contain an organism. If the array is considered to extend indefinitely in both directions, then each cell has eight neighbors, the eight cells surrounding it. Births and deaths occur according to the following rules: An organism is born in any empty cell having exactly three neighbors. An organism dies from isolation if it has fewer than two neighbors. An organism dies from overcrowding if it has more than three neighbors. All other organisms survive to the next generation. Write a program to play the game of Life and investigate the patterns produced by various initial configurations. Some configurations die off rather rapidly; others repeat after a certain number of generations; others change shape and size and may move across the array. NOTE: For representing each organism, use "@" characters. For an array of cells, use 30x30 two-dimensional array. Each generation should be displayed on the screen and should be paused. (You can use cin.get( ) library function to pause running your program.) 4. The source file should be called life.cpp 5. All assignments are expected to be INDIVIDUAL work. All work handed in must be original. Duplicate or very similar programs receive zero points. Input A set of initial cells will be given using the interactive way using a keyboard. The followings are the prompt for the input: Please Enter the number of initial cells: 4 The position of cell is 10 10 The position of cell is 10 11 The position of cell is 10 12 The position of cell is 11 11 How many generations do you want to display? 3 Output The program then display each generation of organisms at a time. The 1-generation @@@ @ Press any key to continue!!
  • 2. (This picture should be displayed on the new screen.) The 2-generation @ @@@ @@@ Press any key to continue!! The 3-generation @@@ @ @ @ Do you want to do it again?(Yes/No) N Solution Note: User given template is used. Answer: #include #include #include #include #include using namespace std; int orAry[30][30]; void initilaize() { for(int kk=0;kk<30;kk++) { for(int bb=0;bb<30;bb++) { orAry[kk][bb]=0; } } } void disply() {
  • 3. cout<=0 ) { cc++; } if( orAry[kk+1][aa-1]==1 && kk+1<30 && aa-1>=0) { cc++; } if( orAry[kk+1][aa]==1 && kk+1<30) { cc++; } if( orAry[kk][aa+1]==1 && aa+1<30) { cc++; } if( orAry[kk-1][aa-1]==1 && kk-1>=0 && aa-1>=0) { cc++; } if(orAry[kk+1][aa+1]==1 && kk+1<30 && aa+1<30) { cc++; } if(orAry[kk-1][aa]==1 && kk-1>=0) { cc++; } if( orAry[kk-1][aa+1]==1 && kk-1>=0 && aa+1<30) { cc++; } return cc; } void runLife()
  • 4. { int bCnt=0; int dCnt=0; for(int kk=0;kk<30;kk++) { for(int bb=0;bb<30;bb++) { if(orAry[kk][bb]==0) { bCnt=ChechNeighBourCount(kk,bb); if(bCnt==3) { orAry[kk][bb]=1; } } else if(orAry[kk][bb]==1) { dCnt=ChechNeighBourCount(kk,bb); if(dCnt>3) { orAry[kk][bb]=0; } if(dCnt<2) { orAry[kk][bb]=0; } } } } } int main() { int rr,cc;
  • 5. int npos=0; int ngen=0; int xv,yv; char re; srand(time(NULL)); do { initilaize(); cout<<"Please Enter the number of initial cells:"; cin>>npos; for(int kk=0;kk>xv>>yv; if(orAry[xv][yv]==0) { orAry[xv][yv]=1; } } cout<<"How many generations do you want to display?"; cin>>ngen; for(int kk=0;kk>re; }while(re!='N'); return 0; } Sample Output: Please Enter the number of initial cells:4 The position of cell is 10 10 The position of cell is 10 11 The position of cell is 10 12 The position of cell is 11 11 How many generations do you want to display?3 1 - generation
  • 6. @@@ @ Press any key to continue 2 - generation
  • 7. @@ @ @ @ Press any key to continue 3 - generation
  • 8. @@ @ @ @ Press any key to continue Do you want to do it again?(Yes/No) N Exit code: 0 (normal program termination)