Question: Project # 3 - Multiprocessing in Python Problem You are tasked with creating a Python program capable of executing the first 1 0 0 iterations

Project #3- Multiprocessing in Python
Problem
You are tasked with creating a Python program capable of executing the first 100 iterations of a modified cellular life simulator. This simulator will receive the path to the input file as an argument containing the starting cellular matrix. The program must then simulate the next 100 iterations based on the algorithm discussed on the next few pages. The simulation is guided by a handful of simplistic rules that will result in a seemingly complex simulation of cellular organisms.
Guidance and Rules
The following two sections outline the guiding principles for your simulation application and suggest a sequential framework for tackling the problem. Your approach should be divided into two distinct phases: the serial computation phase and the concurrent computation phase. Each phase is broken into one or more stages and after completing each stage, it is highly recommended to rigorously test your program before proceeding to the subsequent one.
Phase 1- Serial Computation
Stage 1.1- Data Retrieval
Your solution should begin by parsing and verifying the command line arguments as they are described in the Command Line Argunents section on page 6.
Stage 1.2- Reading and Writing Matrix Files
Stage 1.2.1- Reading the Matrix Fike
Once your solution has verified the command line arguments, it should read in the matrix written into the input file given by the command line argument '-1'. This file will follow the specification as described in the Input File Speafication section on page 7. This matrix will represent the starting matrix (Time Step 0) from which matrix processing will occur as discussed in Stage 1.3- Matrix Processing.
Stage 1.2.2- Writing the Matrix File
Upon completion of all 100 generations from Slage 1.3- Matrix Processing, your solution must write the generated matrix (Time Step 100) to an output file. The name and location of this output file is determined by the command line argument '-o'. This output file will follow the specification as described in the Output File Specififation section on page 7.
Stage 1.3- Matrix Processing
Your solution will accept the starting matrix (Time Step 0) from a file given in the '-1' command line argument and then simulate steps 1 through 100. The final matrix (Time Step 100) will then be written to an output file whose name and path is dictated by a separate command line argument. These files must contain a copy of your matrix with each row of the matrix printed on separate lines and no characters in between the columns.
Using the matrix retrieved from the input file given, your solution must then process the next 100 steps of a simulation that uses the following symbols and rules to dictate what occurs during each time step.
Stage 1.3.1- Symbols
Your solution should be able to read and handle the following symbols, with each symbol representing a specific integer value.
Cells that contain a capital letter 'O' are considered "Healthy O Cells" during this iteration.
Cells that contain a capital letter 'X' are considered "Healthy X Cells" during this iteration.
Cells that contain a lowercase letter 'o' are considered "Weakened O Cells" during this iteration.
Cells that contain a lowercase letter 'x' are considered "Weakened X Cells" during this iteration.
Cells that contain a period (?-.) are considered "dead" during this iteration.
Stage 1.3.2- Iterative Rules
Your solution will need to read the data from the current iteration matrix and write output to the next iteration. This is necessary to ensure that each cell is calculated irrespective of what the other cells are doing in the same iteration. For each of the 100 iterations, the following rules must be applied to each cell in the matrix in the order they are written below:
For each cell of the matrix, sum up the neighboring cells using the following rules:
a. Neighboring cells that are "Healthy O Cells" are equal to two (+2).
b. Neighboring cells that are "Weakened O Cells" are equal to one (+1).
c. Neighboring cells that are "dead" are equal to zero (0).
d. Neighboring cells that are "Weakened X Cells" are equal to negative one (-1).
e. Neighboring cells that are "Healthy X Cells" are equal to negative two (-2).
If the current cell is a healthy ' O ' cell
a. If the sum of neighbor values is a power of 2, the cell immediately dies.
b. Otherwise, if the sum of neighbor values is less than 10, then it becomes a weakened '0' cell.
c. Otherwise, the cell remains unchanged.
If the current cell is a weakened 'o' cell
a. If the sum of neighbor values is less than or equal to 0, the cell immediately dies.
b. Otherwise, if the sum of neighbor values is greater than or equal to 8, then it becomes a healthy 'O' cell.
c. Otherwise, the cell remains unchanged.
If the current cell is a dead cell
a. If the sum of neighbor values is a prime number, the cell
Project # 3 - Multiprocessing in Python Problem

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!