Write a c program to simulate the conways game of life

Assignment Help C/C++ Programming
Reference no: EM131877884

Assignment: Game of Life

Write a C program to simulate the Conway's game of life.

In a game of life of size n by n, the universe is two dimensional and consists of n by n cells. Each cell is in one of two possible states, "live"/"dead" (or "populated"/"unpopulated"). Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

Any live cell with fewer than two live neighbours dies, as if caused by under-population. Any live cell with two or three live neighbours lives on to the next generation. Any live cell with more than three live neighbours dies, as if by over-population. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed; births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick. The rules continue to be applied repeatedly to create further generations.

What about boundary conditions? We treat the borders of the 2D world as if they wrap around. In a universe of n x n cells, let's refer to the top-left cell as in position (0,0) and the bottom right cell as in position (n-1,n-1). If borders wrap around, then the 8 neighbors of (i,j) are:

((i+1)%n,j) right neighbor
((i-1)%n,j) left neighbor
(i,(j+1)%n) top neighbor
(i,(j-1)%n) bottom neighbor
((i+1)%n,(j+1)%n) topright neighbor
((i-1)%n,(j+1)%n) topleft neighbor
((i+1)%n,(j-1)%n) bottomright neighbor
((i-1)%n,(j-1)%n) bottomleft neighbor

Your executable file must be named gameoflife. It should take two arguments. The first argument is the name of a seed pattern file. The second argument is the number of ticks to run for the simulation. The seed pattern file contains one line per row of the universe. If the cell is "dead", its position is marked with the '.' character. If the cell is "live", the position is marked with the 'x' character. The seed file also effectively specifies the size of the universe to simulate.

For example, the contents of an example seed file example_seed are as follows:

$ cat example_seed
.....
.....
.xxx.
.....
.....
Then, the expected output of the command ./gameoflife example_seed 1 should be:

$ ./gameoflife example_seed 1
.....
..x..
..x..

..x..
.....
The expected output of the command ./gameoflife example_seed 2 should be:

$ ./gameoflife example_seed 2
.....
.....
.xxx.
.....
.....
Like in exercise 1 and 2, you should write a Makefile to compile your program and write your own unit tests to check the correctness. During grading, we'll test your program using seed files of our own choosing.

Once finished, add relevant source files and Makefile to your git repo by typing git add *.c *.h Makefile. Commit and push git commit -am "gameoflife"; git push origin.

Reference no: EM131877884

Questions Cloud

What is the appropriate reorder point quantity : What is the appropriate reorder point quantity, given that the company desires a service level of 95 percent.
Diameter of your car tire : A twist of 0.03 radians on a shaft equal to the diameter of your car tire, with a G = 65 GPa on a length equal to your height in meters, will it produce a shear
What is the total gross estate deductions : While working at Evil Inc. Heinz established a 401(k) plan. What is the total gross estate? What is the total gross estate deductions
What is the deflection in radians : If the shaft is 0.5 m long and the G = 25 GPa what is the deflection in radians? Show work.
Write a c program to simulate the conways game of life : Write a C program to simulate the Conway's game of life. In a game of life of size n by n, the universe is two dimensional and consists of n by n cells.
Analyze the market and competition for ford model : Identify and analyze the market and competition for Ford's Model T. Include the products meeting the transportation needs prior to and during the introduction.
What is the angular deflection in radians and degrees : If the material has a G value of 275 GPa, what is the angular deflection in radians and degrees? Show work.
Using your job from your team project how would you recruit : What are the most important considerations and limitations when looking for the most qualified person to fill an opening?
What is total gross estate deductions : In 2011 Heinz Doofenshmirtz made $2,000,000 in taxable gifts paying $500,000 in gift taxes. What is total gross estate? What is total gross estate deductions

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd