C program game of life




















Although this is the most common practice in C , we will not yet have studied pointers at a suitable depth before this project is due. Therefore, you should not use this approach unless you already know what you are doing.

For example, the following is legal in C :—. When the function Life is entered, it allocates the three arrays on the stack based on the integer parameters x and y. To play the game, you should set up a function such as. This can be called by the function Life using:—. PlayOne x, y, A, B ;. The result is that PlayOneGen reads the contents of the first array argument and updates the array of the second argument. Subsequent generation might be called by.

PlayOne x, y, B, C ;. PlayOne x, y, C, A ;. To test for termination conditions, you could adapt PlayOneGen to return values of zero or non-zero to indicate whether anything has changed. You could also construct another function to compare two arrays, returning zero if they are the same and non-zero if they are different, for example. You should test your Game of Life with several initial conditions, including patterns that you find on the web. When the graders test your program, they will use one or more standard input files comprising one initial line followed by several pattern lines.

You must provide the following:—. The executable program must be called life. Also, if you borrowed all or part of the algorithm for this assignment, be sure to cite your sources and explain in detail how it works. Programs submitted after pm on due date January 28 will be tagged as late, and will be subject to the late homework policy.

This assignment is worth thirty 30 points. Your program must compile without errors in order to receive any credit. Learn more.

Game of life in C Ask Question. Asked 5 years, 3 months ago. Active 5 years, 3 months ago. Viewed 6k times. Improve this question. Eka Eka 6 6 silver badges 15 15 bronze badges. That's not typical for the Game of Life. Add a comment. Active Oldest Votes. Improve this answer. Sign up or log in Sign up using Google.

One interacts with the Game of Life by creating an initial configuration and observing how it evolves, or, for advanced "players", by creating patterns with particular properties. Any live cell with fewer than two live neighbours dies, as if caused by under-population.

Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. 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:.

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 in other words, each generation is a pure function of the preceding one.

The rules continue to be applied repeatedly to create further generations. Skip to content. Star



0コメント

  • 1000 / 1000