CSE30: Computer Organization and Systems, Spring 2023 Assignment 4: Life
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Assignment 4: Life
CSE30: Computer Organization and Systems, Spring 2023
Due Dates:
Midpoint: Sunday May 7th, 2023 @ 7:00 PM
Final: Wednesday May 10th, 2023 @ 7:00 PM
Important notes:
● Please read over the entire assignment before starting to get a sense of what you will need to get done in the next week.
● START EARLY - DO NOT WAIT. YOU CANNOT DO THIS ASSIGNMENT
IN ONE DAY
● This assignment must be run on the pi-cluster. We are using custom libraries that are only available on the pi-cluster for this assignment. Use Cloudlabs or ssh: You will not be able to compile or run the assignment otherwise.
Table of contents
a. Arguments
7. Midpoint
Learning Goals
● Dynamic memory allocation and deallocation
● Array processing
● Structs and Pointers
Assignment Overview
You are a biologist researching for life in extreme conditions. You visit Death Valley National park in the height of summer to look for the existence of life there. The temperature reads 130 degrees and there is no one at the Furnace Creek visitor center. However, on closer inspection, you find a century old scroll and on it, you find instructions to play the Game of Life. Using your skills from CSE 30, you decide to give it a shot.
Developing Your Program
You MUST compile and run your programs on the pi-cluster. To access the server, you will need your cs30sp23xxx student account, and know how to SSH into the cluster.
Need help or instructions? SeeEdstem FAQ. (Do NOT wait until the end to try this. There will be limited or no ETS support on the weekends!)
We’ve provided you with the starter code at the following link:
https://github.com/cse30-sp23https://github.com/cse30-sp23/HW4-starter/HW4-starter
Note: DO NOT make your code a public repo on github to avoid Academic Integrity violations. (this includes forking the starter code repo)
1. Download the files in the repository. Use
git clone https ://github .com/cse30-sp23/HW4-starter directly from pi-cluster
2. Fill out the fields in the README before turning in.
We’ve provided you with a Makefile so compiling your program should be easy!
Additionally, we’ve placed the reference solution binary at:
/home/linux/ieng6/cs30sp23/public/bin/swlife
Copy this file to your HW4 working directory to use it.
Makefile: The Makefile provided will create a swlife executable from the source files provided. Compile it by typing make into the terminal. By default, it will run with warnings turned on. To compile without warnings, run make WARN= instead. Run make clean to remove files generated by make.
valgrind: to run with valgrind, the command is valgrind ./ [executable] [arguments] for more details see the testingsection.
The Game of Life
Developed by John Conway, the Game of Life is a mathematical simulation of a simplified evolution process. The simulation occurs on a two-dimensional grid of cells over a series of discrete timesteps. At any given timestep, each cell will either be “alive” or “dead” (encoded as 1 and 0 respectively), and each cell’s value for the next timestep will be computed based on the current values of its 8 direct neighbors. The next-state rules are defined as follows:
For an alive cell:
If 0 or 1 neighbors are alive, it will die in the next timestep from loneliness. If 2 or 3 neighbors are alive, it will remain alive in the next timestep.
If 4+ neighbors are alive, it will die in the next timestep from overpopulation.
For a dead cell:
If exactly 3 neighbors are alive, it will become alive in the next timestep. Otherwise, it will remain dead in the next timestep.
See this site for an interactive example of the Game of Life. See the Wikipedia page on Example Patterns to see moving gifs of common patterns (toad, glider, etc).
Neighbors and Wrapping
The original life algorithm assumes an infinite plane of cells. In our implementation, we are working with limited memory so we will have a finite board that wraps around the edges. This creates a torus - [link] For example, in any given board, the rightmost column is connected to the leftmost column and top row is connected to bottom row.
For example, consider the following case where we have a 5 x 10 board. In the corresponding figure of the board below, cells with text are live.
[ 1] |
b
|
|
|
|
|
|
|
|
|
a |
|
|
|
|
g |
h |
|
|
f
|
m |
|
|
|
|
[2] |
|
|
j |
[3] |
|
|
|
|
|
i
|
|
|
|
k |
c |
d |
|
|
|
|
|
|
|
e |
Cell [1] (0,0) has 6 live neighbors (a, b, c, d, e, f), Cell[2] (2, 5) has 3 live neighbors (g, h i), and cell [3] has 5 live neighbors (f, j, k, a, m). In the next timestep, cells [1] and [3] are guaranteed to die if they were alive, while cell [2] is guaranteed to become alive.
A closer look at the corner case - again the boundary cells wrap around and can be considered connected to the cells on the opposite side of the board:
|
k |
|
|
|
k |
|
|
|
|
e |
c |
d |
|
e |
c |
d |
|
|
|
[1] |
b |
|
|
[1] |
b |
|
|
f |
a |
|
|
f |
a |
|
|
|
|
m |
|
|
|
m |
|
|
● This program loads an input file, defining the initial board layout of dead/alive cells.
● You are able to interactively step through the program to see how the board evolves through each timestep.
● All argument processing is handled by the provided main .c. Please do not edit main .c as we will be testing with our own copy of the file. See arguments and interactive commands below for details.
Format for calling this executable with arguments:
./life filename
Arguments |
Description |
filename (required) |
The name of the input file to initialize the dead/alive cells of the array. See below for details on the format. |
After running the executable in either mode, interact with it by entering the following commands:
Command |
Description |
N |
Simulate N steps, displaying the |
2023-05-07